Skip to content

Commit 7600467

Browse files
Add perf tests for MS Azure File Storage (T1) API (Azure#17555)
* Add perf tests for MS Azure File Storage (T1) API
1 parent 59a2698 commit 7600467

File tree

9 files changed

+304
-50
lines changed

9 files changed

+304
-50
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
<PackageReference Update="Microsoft.Azure.ResourceManager" Version="[1.1.0-preview]" />
168168
<PackageReference Update="Microsoft.Azure.Services.AppAuthentication" Version="[1.0.3, 2.0.0)" />
169169
<PackageReference Update="Microsoft.Azure.Storage.Blob" Version="11.1.7" />
170+
<PackageReference Update="Microsoft.Azure.Storage.File" Version="11.2.2" />
170171
<PackageReference Update="Microsoft.Azure.Storage.Queue" Version="11.1.7" />
171172
<PackageReference Update="Microsoft.Azure.Test.HttpRecorder" Version="[1.13.3, 2.0.0)" />
172173
<PackageReference Update="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"solution": {
3+
"path": "..\\..\\Azure.Storage.sln",
4+
"projects": [
5+
"..\\..\\common\\Perf\\Azure.Test.Perf\\Azure.Test.Perf.csproj",
6+
"..\\core\\Azure.Core.TestFramework\\src\\Azure.Core.TestFramework.csproj",
7+
"Azure.Storage.Common\\src\\Azure.Storage.Common.csproj",
8+
"Azure.Storage.Files.Shares\\perf\\Azure.Storage.Files.Shares.Perf\\Azure.Storage.Files.Shares.Perf.csproj",
9+
"Azure.Storage.Files.Shares\\perf\\Microsoft.Azure.Storage.File.Perf\\Microsoft.Azure.Storage.File.Perf.csproj",
10+
"Azure.Storage.Files.Shares\\src\\Azure.Storage.Files.Shares.csproj"
11+
]
12+
}
13+
}

sdk/storage/Azure.Storage.Files.Shares/perf/Azure.Storage.Files.Shares.Perf/Azure.Storage.Files.Shares.Perf.sln

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using Azure.Core.TestFramework;
6+
7+
namespace Microsoft.Azure.Storage.File.Perf
8+
{
9+
/// <summary>
10+
/// Represents the ambient environment in which the test suite is being run, offering access to information such as environment variables.
11+
/// </summary>
12+
internal sealed class PerfTestEnvironment : TestEnvironment
13+
{
14+
/// <summary>
15+
/// The shared instance of the <see cref="PerfTestEnvironment"/> to be used during test runs.
16+
/// </summary>
17+
public static PerfTestEnvironment Instance { get; } = new PerfTestEnvironment();
18+
19+
/// <summary>
20+
/// The storage account endpoint suffix of the cloud to use for testing.
21+
/// </summary>
22+
public new string StorageEndpointSuffix => base.StorageEndpointSuffix ?? "core.windows.net";
23+
24+
/// <summary>
25+
/// The name of the Files Shares storage account to test against.
26+
/// </summary>
27+
/// <value>The Files Shares storage account name, read from the "AZURE_STORAGE_ACCOUNT_NAME" environment variable.</value>
28+
public string FilesSharesAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME");
29+
30+
/// <summary>
31+
/// The shared access key of the Files Shares storage account to test against.
32+
/// </summary>
33+
/// <value>The Files Shares storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value>
34+
public string FilesSharesAccountKey => GetVariable("AZURE_STORAGE_ACCOUNT_KEY");
35+
36+
/// <summary>
37+
/// The connection string for accessing the Files Shares storage account used for testing.
38+
/// </summary>
39+
public string FileShareAddressString { get; }
40+
41+
/// <summary>
42+
/// Credentials used to authenticate access to the Microsoft Azure storage account used for testing.
43+
/// </summary>
44+
public Auth.StorageCredentials StorageCredentials { get; }
45+
46+
/// <summary>
47+
/// Initializes a new instance of the <see cref="PerfTestEnvironment"/> class.
48+
/// </summary>
49+
public PerfTestEnvironment()
50+
{
51+
FileShareAddressString = $"{Uri.UriSchemeHttps}://{FilesSharesAccountName}.file.{StorageEndpointSuffix}";
52+
53+
StorageCredentials = new Auth.StorageCredentials(FilesSharesAccountName, FilesSharesAccountKey);
54+
}
55+
}
56+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<PackageReference Include="Microsoft.Azure.Storage.File" />
8+
</ItemGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj" />
12+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj" />
13+
</ItemGroup>
14+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Reflection;
5+
using Azure.Test.Perf;
6+
7+
await PerfProgram.Main(Assembly.GetEntryAssembly(), args);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.IO;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Azure.Test.Perf;
9+
10+
namespace Microsoft.Azure.Storage.File.Perf.Scenarios
11+
{
12+
/// <summary>
13+
/// The performance test scenario focused on downloading files from the Microsoft Azure File Shares storage.
14+
/// </summary>
15+
/// <seealso cref="Azure.Test.Perf.PerfTest{SizeOptions}" />
16+
public sealed class DownloadFile : PerfTest<SizeOptions>
17+
{
18+
/// <summary>
19+
/// Reference to the Share used by the test in the Microsoft Azure File service.
20+
/// </summary>
21+
private CloudFileShare _cloudFileShare;
22+
23+
/// <summary>
24+
/// Reference to the file used by the test in the Microsoft Azure File service.
25+
/// </summary>
26+
private CloudFile _cloudFile;
27+
28+
/// <summary>
29+
/// Local stream uploaded to Microsoft Azure File service.
30+
/// </summary>
31+
private readonly Stream _stream;
32+
33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="DownloadFile"/> class.
35+
/// </summary>
36+
/// <param name="options">The set of options to consider for configuring the scenario.</param>
37+
public DownloadFile(SizeOptions options) : base(options)
38+
{
39+
_stream = RandomStream.Create(options.Size);
40+
}
41+
42+
public override void Dispose(bool disposing)
43+
{
44+
_stream.Dispose();
45+
base.Dispose(disposing);
46+
}
47+
48+
/// <summary>
49+
/// Creates a cloud file share to be used by the test.
50+
/// Also, creates a file reference in the cloud file share and uploads data stream to the cloud file.
51+
/// </summary>
52+
/// <returns></returns>
53+
public override async Task SetupAsync()
54+
{
55+
await base.SetupAsync();
56+
57+
PerfTestEnvironment testEnvironment = PerfTestEnvironment.Instance;
58+
_cloudFileShare = new CloudFileShare(new Uri($"{testEnvironment.FileShareAddressString}/{Guid.NewGuid()}"), testEnvironment.StorageCredentials);
59+
60+
await _cloudFileShare.CreateAsync();
61+
62+
_cloudFile = _cloudFileShare.GetRootDirectoryReference().GetFileReference(Path.GetRandomFileName());
63+
await _cloudFile.CreateAsync(Options.Size);
64+
await _cloudFile.UploadFromStreamAsync(_stream);
65+
}
66+
67+
/// <summary>
68+
/// Deletes the cloud file share created by the test.
69+
/// </summary>
70+
public override async Task CleanupAsync()
71+
{
72+
await _cloudFileShare.DeleteAsync();
73+
await base.CleanupAsync();
74+
}
75+
76+
/// <summary>
77+
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.DownloadToStream(Stream, AccessCondition, FileRequestOptions, OperationContext)"/>.
78+
/// </summary>
79+
/// <param name="cancellationToken">The token used to signal cancellation request.</param>
80+
public override void Run(CancellationToken cancellationToken)
81+
{
82+
_cloudFile.DownloadToStream(Stream.Null);
83+
}
84+
85+
/// <summary>
86+
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.DownloadToStreamAsync(Stream, AccessCondition, FileRequestOptions, OperationContext, CancellationToken)"/>.
87+
/// </summary>
88+
/// <param name="cancellationToken">The token used to signal cancellation request.</param>
89+
public override async Task RunAsync(CancellationToken cancellationToken)
90+
{
91+
await _cloudFile.DownloadToStreamAsync(Stream.Null, cancellationToken);
92+
}
93+
}
94+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.IO;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Azure.Test.Perf;
9+
10+
namespace Microsoft.Azure.Storage.File.Perf.Scenarios
11+
{
12+
/// <summary>
13+
/// The performance test scenario focused on uploading files to the Microsoft Azure File Shares storage.
14+
/// </summary>
15+
/// <seealso cref="Azure.Test.Perf.PerfTest{SizeOptions}" />
16+
public sealed class UploadFile : PerfTest<SizeOptions>
17+
{
18+
/// <summary>
19+
/// Reference to the Share used by the test in the Microsoft Azure File service.
20+
/// </summary>
21+
private CloudFileShare _cloudFileShare;
22+
23+
/// <summary>
24+
/// Reference to the file used by the test in the Microsoft Azure File service.
25+
/// </summary>
26+
private CloudFile _cloudFile;
27+
28+
/// <summary>
29+
/// Local stream uploaded to Microsoft Azure File service.
30+
/// </summary>
31+
private readonly Stream _stream;
32+
33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="UploadFile"/> class.
35+
/// </summary>
36+
/// <param name="options">The set of options to consider for configuring the scenario.</param>
37+
public UploadFile(SizeOptions options) : base(options)
38+
{
39+
_stream = RandomStream.Create(options.Size);
40+
}
41+
42+
public override void Dispose(bool disposing)
43+
{
44+
_stream.Dispose();
45+
base.Dispose(disposing);
46+
}
47+
48+
/// <summary>
49+
/// Creates a cloud file share to be used by the test.
50+
/// Also, creates a file reference in the cloud file share.
51+
/// </summary>
52+
/// <returns></returns>
53+
public override async Task SetupAsync()
54+
{
55+
await base.SetupAsync();
56+
57+
PerfTestEnvironment testEnvironment = PerfTestEnvironment.Instance;
58+
_cloudFileShare = new CloudFileShare(new Uri($"{testEnvironment.FileShareAddressString}/{Guid.NewGuid()}"), testEnvironment.StorageCredentials);
59+
60+
await _cloudFileShare.CreateAsync();
61+
62+
_cloudFile = _cloudFileShare.GetRootDirectoryReference().GetFileReference(Path.GetRandomFileName());
63+
await _cloudFile.CreateAsync(Options.Size);
64+
}
65+
66+
/// <summary>
67+
/// Deletes the cloud file share created by the test.
68+
/// </summary>
69+
public override async Task CleanupAsync()
70+
{
71+
await _cloudFileShare.DeleteAsync();
72+
await base.CleanupAsync();
73+
}
74+
75+
/// <summary>
76+
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.UploadFromStream(Stream, AccessCondition, FileRequestOptions, OperationContext)"/>.
77+
/// </summary>
78+
/// <param name="cancellationToken">The token used to signal cancellation request.</param>
79+
public override void Run(CancellationToken cancellationToken)
80+
{
81+
_stream.Seek(0, SeekOrigin.Begin);
82+
83+
_cloudFile.UploadFromStream(_stream);
84+
}
85+
86+
/// <summary>
87+
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.UploadFromStreamAsync(Stream, AccessCondition, FileRequestOptions, OperationContext, CancellationToken)"/>.
88+
/// </summary>
89+
/// <param name="cancellationToken">The token used to signal cancellation request.</param>
90+
public override async Task RunAsync(CancellationToken cancellationToken)
91+
{
92+
_stream.Seek(0, SeekOrigin.Begin);
93+
94+
await _cloudFile.UploadFromStreamAsync(_stream, cancellationToken);
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)