-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add perf tests for MS Azure File Storage (T1) API (#17555)
* Add perf tests for MS Azure File Storage (T1) API
- Loading branch information
1 parent
59a2698
commit 7600467
Showing
9 changed files
with
304 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
sdk/storage/Azure.Storage.Files.Shares/perf/Azure.Storage.File.Perf.slnf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"solution": { | ||
"path": "..\\..\\Azure.Storage.sln", | ||
"projects": [ | ||
"..\\..\\common\\Perf\\Azure.Test.Perf\\Azure.Test.Perf.csproj", | ||
"..\\core\\Azure.Core.TestFramework\\src\\Azure.Core.TestFramework.csproj", | ||
"Azure.Storage.Common\\src\\Azure.Storage.Common.csproj", | ||
"Azure.Storage.Files.Shares\\perf\\Azure.Storage.Files.Shares.Perf\\Azure.Storage.Files.Shares.Perf.csproj", | ||
"Azure.Storage.Files.Shares\\perf\\Microsoft.Azure.Storage.File.Perf\\Microsoft.Azure.Storage.File.Perf.csproj", | ||
"Azure.Storage.Files.Shares\\src\\Azure.Storage.Files.Shares.csproj" | ||
] | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
...age.Files.Shares/perf/Azure.Storage.Files.Shares.Perf/Azure.Storage.Files.Shares.Perf.sln
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...Files.Shares/perf/Microsoft.Azure.Storage.File.Perf/Infrastructure/PerfTestEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core.TestFramework; | ||
|
||
namespace Microsoft.Azure.Storage.File.Perf | ||
{ | ||
/// <summary> | ||
/// Represents the ambient environment in which the test suite is being run, offering access to information such as environment variables. | ||
/// </summary> | ||
internal sealed class PerfTestEnvironment : TestEnvironment | ||
{ | ||
/// <summary> | ||
/// The shared instance of the <see cref="PerfTestEnvironment"/> to be used during test runs. | ||
/// </summary> | ||
public static PerfTestEnvironment Instance { get; } = new PerfTestEnvironment(); | ||
|
||
/// <summary> | ||
/// The storage account endpoint suffix of the cloud to use for testing. | ||
/// </summary> | ||
public new string StorageEndpointSuffix => base.StorageEndpointSuffix ?? "core.windows.net"; | ||
|
||
/// <summary> | ||
/// The name of the Files Shares storage account to test against. | ||
/// </summary> | ||
/// <value>The Files Shares storage account name, read from the "AZURE_STORAGE_ACCOUNT_NAME" environment variable.</value> | ||
public string FilesSharesAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME"); | ||
|
||
/// <summary> | ||
/// The shared access key of the Files Shares storage account to test against. | ||
/// </summary> | ||
/// <value>The Files Shares storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value> | ||
public string FilesSharesAccountKey => GetVariable("AZURE_STORAGE_ACCOUNT_KEY"); | ||
|
||
/// <summary> | ||
/// The connection string for accessing the Files Shares storage account used for testing. | ||
/// </summary> | ||
public string FileShareAddressString { get; } | ||
|
||
/// <summary> | ||
/// Credentials used to authenticate access to the Microsoft Azure storage account used for testing. | ||
/// </summary> | ||
public Auth.StorageCredentials StorageCredentials { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PerfTestEnvironment"/> class. | ||
/// </summary> | ||
public PerfTestEnvironment() | ||
{ | ||
FileShareAddressString = $"{Uri.UriSchemeHttps}://{FilesSharesAccountName}.file.{StorageEndpointSuffix}"; | ||
|
||
StorageCredentials = new Auth.StorageCredentials(FilesSharesAccountName, FilesSharesAccountKey); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...es.Shares/perf/Microsoft.Azure.Storage.File.Perf/Microsoft.Azure.Storage.File.Perf.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Storage.File" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj" /> | ||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj" /> | ||
</ItemGroup> | ||
</Project> |
7 changes: 7 additions & 0 deletions
7
sdk/storage/Azure.Storage.Files.Shares/perf/Microsoft.Azure.Storage.File.Perf/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Reflection; | ||
using Azure.Test.Perf; | ||
|
||
await PerfProgram.Main(Assembly.GetEntryAssembly(), args); |
94 changes: 94 additions & 0 deletions
94
...ure.Storage.Files.Shares/perf/Microsoft.Azure.Storage.File.Perf/Scenarios/DownloadFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Test.Perf; | ||
|
||
namespace Microsoft.Azure.Storage.File.Perf.Scenarios | ||
{ | ||
/// <summary> | ||
/// The performance test scenario focused on downloading files from the Microsoft Azure File Shares storage. | ||
/// </summary> | ||
/// <seealso cref="Azure.Test.Perf.PerfTest{SizeOptions}" /> | ||
public sealed class DownloadFile : PerfTest<SizeOptions> | ||
{ | ||
/// <summary> | ||
/// Reference to the Share used by the test in the Microsoft Azure File service. | ||
/// </summary> | ||
private CloudFileShare _cloudFileShare; | ||
|
||
/// <summary> | ||
/// Reference to the file used by the test in the Microsoft Azure File service. | ||
/// </summary> | ||
private CloudFile _cloudFile; | ||
|
||
/// <summary> | ||
/// Local stream uploaded to Microsoft Azure File service. | ||
/// </summary> | ||
private readonly Stream _stream; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DownloadFile"/> class. | ||
/// </summary> | ||
/// <param name="options">The set of options to consider for configuring the scenario.</param> | ||
public DownloadFile(SizeOptions options) : base(options) | ||
{ | ||
_stream = RandomStream.Create(options.Size); | ||
} | ||
|
||
public override void Dispose(bool disposing) | ||
{ | ||
_stream.Dispose(); | ||
base.Dispose(disposing); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a cloud file share to be used by the test. | ||
/// Also, creates a file reference in the cloud file share and uploads data stream to the cloud file. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override async Task SetupAsync() | ||
{ | ||
await base.SetupAsync(); | ||
|
||
PerfTestEnvironment testEnvironment = PerfTestEnvironment.Instance; | ||
_cloudFileShare = new CloudFileShare(new Uri($"{testEnvironment.FileShareAddressString}/{Guid.NewGuid()}"), testEnvironment.StorageCredentials); | ||
|
||
await _cloudFileShare.CreateAsync(); | ||
|
||
_cloudFile = _cloudFileShare.GetRootDirectoryReference().GetFileReference(Path.GetRandomFileName()); | ||
await _cloudFile.CreateAsync(Options.Size); | ||
await _cloudFile.UploadFromStreamAsync(_stream); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the cloud file share created by the test. | ||
/// </summary> | ||
public override async Task CleanupAsync() | ||
{ | ||
await _cloudFileShare.DeleteAsync(); | ||
await base.CleanupAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.DownloadToStream(Stream, AccessCondition, FileRequestOptions, OperationContext)"/>. | ||
/// </summary> | ||
/// <param name="cancellationToken">The token used to signal cancellation request.</param> | ||
public override void Run(CancellationToken cancellationToken) | ||
{ | ||
_cloudFile.DownloadToStream(Stream.Null); | ||
} | ||
|
||
/// <summary> | ||
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.DownloadToStreamAsync(Stream, AccessCondition, FileRequestOptions, OperationContext, CancellationToken)"/>. | ||
/// </summary> | ||
/// <param name="cancellationToken">The token used to signal cancellation request.</param> | ||
public override async Task RunAsync(CancellationToken cancellationToken) | ||
{ | ||
await _cloudFile.DownloadToStreamAsync(Stream.Null, cancellationToken); | ||
} | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...Azure.Storage.Files.Shares/perf/Microsoft.Azure.Storage.File.Perf/Scenarios/UploadFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Test.Perf; | ||
|
||
namespace Microsoft.Azure.Storage.File.Perf.Scenarios | ||
{ | ||
/// <summary> | ||
/// The performance test scenario focused on uploading files to the Microsoft Azure File Shares storage. | ||
/// </summary> | ||
/// <seealso cref="Azure.Test.Perf.PerfTest{SizeOptions}" /> | ||
public sealed class UploadFile : PerfTest<SizeOptions> | ||
{ | ||
/// <summary> | ||
/// Reference to the Share used by the test in the Microsoft Azure File service. | ||
/// </summary> | ||
private CloudFileShare _cloudFileShare; | ||
|
||
/// <summary> | ||
/// Reference to the file used by the test in the Microsoft Azure File service. | ||
/// </summary> | ||
private CloudFile _cloudFile; | ||
|
||
/// <summary> | ||
/// Local stream uploaded to Microsoft Azure File service. | ||
/// </summary> | ||
private readonly Stream _stream; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UploadFile"/> class. | ||
/// </summary> | ||
/// <param name="options">The set of options to consider for configuring the scenario.</param> | ||
public UploadFile(SizeOptions options) : base(options) | ||
{ | ||
_stream = RandomStream.Create(options.Size); | ||
} | ||
|
||
public override void Dispose(bool disposing) | ||
{ | ||
_stream.Dispose(); | ||
base.Dispose(disposing); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a cloud file share to be used by the test. | ||
/// Also, creates a file reference in the cloud file share. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override async Task SetupAsync() | ||
{ | ||
await base.SetupAsync(); | ||
|
||
PerfTestEnvironment testEnvironment = PerfTestEnvironment.Instance; | ||
_cloudFileShare = new CloudFileShare(new Uri($"{testEnvironment.FileShareAddressString}/{Guid.NewGuid()}"), testEnvironment.StorageCredentials); | ||
|
||
await _cloudFileShare.CreateAsync(); | ||
|
||
_cloudFile = _cloudFileShare.GetRootDirectoryReference().GetFileReference(Path.GetRandomFileName()); | ||
await _cloudFile.CreateAsync(Options.Size); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes the cloud file share created by the test. | ||
/// </summary> | ||
public override async Task CleanupAsync() | ||
{ | ||
await _cloudFileShare.DeleteAsync(); | ||
await base.CleanupAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.UploadFromStream(Stream, AccessCondition, FileRequestOptions, OperationContext)"/>. | ||
/// </summary> | ||
/// <param name="cancellationToken">The token used to signal cancellation request.</param> | ||
public override void Run(CancellationToken cancellationToken) | ||
{ | ||
_stream.Seek(0, SeekOrigin.Begin); | ||
|
||
_cloudFile.UploadFromStream(_stream); | ||
} | ||
|
||
/// <summary> | ||
/// Downloads a file from the Microsoft Azure File service by calling <see cref="CloudFile.UploadFromStreamAsync(Stream, AccessCondition, FileRequestOptions, OperationContext, CancellationToken)"/>. | ||
/// </summary> | ||
/// <param name="cancellationToken">The token used to signal cancellation request.</param> | ||
public override async Task RunAsync(CancellationToken cancellationToken) | ||
{ | ||
_stream.Seek(0, SeekOrigin.Begin); | ||
|
||
await _cloudFile.UploadFromStreamAsync(_stream, cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.