Skip to content

Commit fc81d2e

Browse files
Fix storage perf (Azure#49082)
* add datamovement perf to main storage sln * Fix blob perf. Use token credentials via DefaultAzureCredential. Some tests still require shared key for SAS. Generally we are locked out of shared key by default, but these tests are probably still important. Made shared key an optional variable to be fetched. Those tests will probably still break, but they were already broken. This at least compiles. * convert shares and datalake to tokencreds * revert sln * missing env var
1 parent 0076189 commit fc81d2e

File tree

8 files changed

+63
-45
lines changed

8 files changed

+63
-45
lines changed

sdk/storage/Azure.Storage.Blobs/perf.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ extends:
3838
Iterations: ${{ parameters.Iterations }}
3939
Profile: ${{ parameters.Profile }}
4040
AdditionalArguments: ${{ parameters.AdditionalArguments }}
41+
EnvVars:
42+
AZURE_AUTHORITY_HOST: $(AZURE_STORAGE_BLOBS_AZURE_AUTHORITY_HOST)

sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/PerfTestEnvironment.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ internal sealed class PerfTestEnvironment : TestEnvironment
2525
/// The name of the Blob storage account to test against.
2626
/// </summary>
2727
/// <value>The Blob storage account name, read from the "AZURE_STORAGE_ACCOUNT_NAME" environment variable.</value>
28-
public string BlobStorageAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME");
28+
public string StorageAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME");
2929

3030
/// <summary>
3131
/// The shared access key of the Blob storage account to test against.
3232
/// </summary>
3333
/// <value>The Blob storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value>
34-
public string BlobStorageAccountKey => GetVariable("AZURE_STORAGE_ACCOUNT_KEY");
34+
public string StorageAccountKey => GetOptionalVariable("AZURE_STORAGE_ACCOUNT_KEY");
3535

3636
/// <summary>
37-
/// The connection string for accessing the Blob storage account used for testing.
37+
/// The Blob storage endpoint.
3838
/// </summary>
39-
public string BlobStorageConnectionString { get; }
39+
public Uri StorageEndpoint { get; }
4040

4141
/// <summary>
4242
/// Initializes a new instance of the <see cref="PerfTestEnvironment"/> class.
4343
/// </summary>
4444
public PerfTestEnvironment()
4545
{
46-
BlobStorageConnectionString = $"DefaultEndpointsProtocol={Uri.UriSchemeHttps};AccountName={BlobStorageAccountName};AccountKey={BlobStorageAccountKey};EndpointSuffix={StorageEndpointSuffix}";
46+
StorageEndpoint = new Uri($"https://{StorageAccountName}.blob.{StorageEndpointSuffix}");
4747
}
4848
}
4949
}

sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/ServiceTest.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ public ServiceTest(TOptions options) : base(options)
1616
? clientOptionsOptions.ClientOptions
1717
: new BlobClientOptions();
1818
BlobServiceClient = new BlobServiceClient(
19-
PerfTestEnvironment.Instance.BlobStorageConnectionString, ConfigureClientOptions(clientOptions));
19+
PerfTestEnvironment.Instance.StorageEndpoint,
20+
PerfTestEnvironment.Instance.Credential,
21+
ConfigureClientOptions(clientOptions));
2022

21-
StorageSharedKeyCredential = new StorageSharedKeyCredential(
22-
PerfTestEnvironment.Instance.BlobStorageAccountName, PerfTestEnvironment.Instance.BlobStorageAccountKey);
23+
// Can't do shared key tests if shared key wasn't provided
24+
if (PerfTestEnvironment.Instance.StorageAccountKey != null)
25+
{
26+
StorageSharedKeyCredential = new StorageSharedKeyCredential(
27+
PerfTestEnvironment.Instance.StorageAccountName, PerfTestEnvironment.Instance.StorageAccountKey);
28+
}
2329
}
2430
}
2531
}

sdk/storage/Azure.Storage.Files.DataLake/perf/Azure.Storage.Files.DataLake.Perf/Infrastructure/PerfTestEnvironment.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,21 @@ public sealed class PerfTestEnvironment : TestEnvironment
2727
public new string StorageEndpointSuffix => base.StorageEndpointSuffix ?? "core.windows.net";
2828

2929
/// <summary>
30-
/// The name of the Data Lake storage account to test against.
30+
/// The name of the Blob storage account to test against.
3131
/// </summary>
32-
///
33-
/// <value>The Data Lake storage account name, read from the "DATALAKE_STORAGE_ACCOUNT_NAME" environment variable.</value>
34-
///
35-
public string DataLakeAccountName => GetVariable("DATALAKE_STORAGE_ACCOUNT_NAME");
32+
/// <value>The Blob storage account name, read from the "AZURE_STORAGE_ACCOUNT_NAME" environment variable.</value>
33+
public string StorageAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME");
3634

3735
/// <summary>
38-
/// The shared access key of the Data Lake storage account to test against.
36+
/// The shared access key of the Blob storage account to test against.
3937
/// </summary>
40-
///
41-
/// <value>The Data Lake storage account key, read from the "DATALAKE_STORAGE_ACCOUNT_KEY" environment variable.</value>
42-
///
43-
public string DataLakeAccountKey => GetVariable("DATALAKE_STORAGE_ACCOUNT_KEY");
38+
/// <value>The Blob storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value>
39+
public string StorageAccountKey => GetOptionalVariable("AZURE_STORAGE_ACCOUNT_KEY");
4440

4541
/// <summary>
46-
/// The fully-qualified URI for the Data Lake storage account to test against.
42+
/// The Blob storage endpoint.
4743
/// </summary>
48-
///
49-
public Uri DataLakeServiceUri { get; }
44+
public Uri StorageEndpoint { get; }
5045

5146
/// <summary>
5247
/// The credential for accessing the Data Lake storage account used for testing.
@@ -62,8 +57,11 @@ public sealed class PerfTestEnvironment : TestEnvironment
6257
///
6358
public PerfTestEnvironment()
6459
{
65-
DataLakeServiceUri = new Uri($"{ Uri.UriSchemeHttps }{ Uri.SchemeDelimiter }{ DataLakeAccountName }.dfs.{ StorageEndpointSuffix }");
66-
DataLakeCredential = new StorageSharedKeyCredential(DataLakeAccountName, DataLakeAccountKey);
60+
StorageEndpoint = new Uri($"{ Uri.UriSchemeHttps }{ Uri.SchemeDelimiter }{ StorageAccountName }.dfs.{ StorageEndpointSuffix }");
61+
if (StorageAccountKey != null)
62+
{
63+
DataLakeCredential = new StorageSharedKeyCredential(StorageAccountName, StorageAccountKey);
64+
}
6765
}
6866
}
6967
}

sdk/storage/Azure.Storage.Files.DataLake/perf/Azure.Storage.Files.DataLake.Perf/Infrastructure/ServiceTest.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ public ServiceTest(TOptions options) : base(options)
1616
? clientOptionsProvider.ClientOptions
1717
: new DataLakeClientOptions();
1818
DataLakeServiceClient = new DataLakeServiceClient(
19-
PerfTestEnvironment.Instance.DataLakeServiceUri,
20-
PerfTestEnvironment.Instance.DataLakeCredential,
19+
PerfTestEnvironment.Instance.StorageEndpoint,
20+
PerfTestEnvironment.Instance.Credential,
2121
ConfigureClientOptions(clientOptions));
2222

23-
StorageSharedKeyCredential = new StorageSharedKeyCredential(
24-
PerfTestEnvironment.Instance.DataLakeAccountName, PerfTestEnvironment.Instance.DataLakeAccountKey);
23+
// Can't do shared key tests if shared key wasn't provided
24+
if (PerfTestEnvironment.Instance.StorageAccountKey != null)
25+
{
26+
StorageSharedKeyCredential = new StorageSharedKeyCredential(
27+
PerfTestEnvironment.Instance.StorageAccountName, PerfTestEnvironment.Instance.StorageAccountKey);
28+
}
2529
}
2630
}
2731
}

sdk/storage/Azure.Storage.Files.DataLake/perf/Azure.Storage.Files.DataLake.Perf/Scenarios/CreateClients.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class CreateClients : PerfTest<PerfOptions>
1717
{
1818
private static readonly TokenCredential s_tokenCredential = new ClientSecretCredential("foo", "bar", "baz");
1919
private static readonly PerfTestEnvironment s_testEnvironment = PerfTestEnvironment.Instance;
20-
private static readonly Uri s_fileSystemUri = new DataLakeUriBuilder(s_testEnvironment.DataLakeServiceUri) { FileSystemName = "foo" }.ToUri();
21-
private static readonly Uri s_directoryUri = new DataLakeUriBuilder(s_testEnvironment.DataLakeServiceUri) { FileSystemName = "foo", DirectoryOrFilePath = "bar" }.ToUri();
22-
private static readonly Uri s_fileUri = new DataLakeUriBuilder(s_testEnvironment.DataLakeServiceUri) { FileSystemName = "foo", DirectoryOrFilePath = "bar/baz" }.ToUri();
20+
private static readonly Uri s_fileSystemUri = new DataLakeUriBuilder(s_testEnvironment.StorageEndpoint) { FileSystemName = "foo" }.ToUri();
21+
private static readonly Uri s_directoryUri = new DataLakeUriBuilder(s_testEnvironment.StorageEndpoint) { FileSystemName = "foo", DirectoryOrFilePath = "bar" }.ToUri();
22+
private static readonly Uri s_fileUri = new DataLakeUriBuilder(s_testEnvironment.StorageEndpoint) { FileSystemName = "foo", DirectoryOrFilePath = "bar/baz" }.ToUri();
2323

2424
public CreateClients(PerfOptions options) : base(options)
2525
{
@@ -28,9 +28,9 @@ public CreateClients(PerfOptions options) : base(options)
2828
#pragma warning disable CA1806 // Do not ignore method results
2929
public override void Run(CancellationToken cancellationToken)
3030
{
31-
var serviceClient = new DataLakeServiceClient(s_testEnvironment.DataLakeServiceUri);
32-
new DataLakeServiceClient(s_testEnvironment.DataLakeServiceUri, s_tokenCredential);
33-
new DataLakeServiceClient(s_testEnvironment.DataLakeServiceUri, s_testEnvironment.DataLakeCredential);
31+
var serviceClient = new DataLakeServiceClient(s_testEnvironment.StorageEndpoint);
32+
new DataLakeServiceClient(s_testEnvironment.StorageEndpoint, s_tokenCredential);
33+
new DataLakeServiceClient(s_testEnvironment.StorageEndpoint, new StorageSharedKeyCredential("s_testEnvironment.StorageAccountKey", Convert.ToBase64String(Guid.NewGuid().ToByteArray())));
3434

3535
var fileSystemClient = new DataLakeFileSystemClient(s_fileSystemUri);
3636
new DataLakeFileSystemClient(s_fileSystemUri, s_tokenCredential);

sdk/storage/Azure.Storage.Files.Shares/perf/Azure.Storage.Files.Shares.Perf/Infrastructure/PerfTestEnvironment.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ internal sealed class PerfTestEnvironment : TestEnvironment
2222
public new string StorageEndpointSuffix => base.StorageEndpointSuffix ?? "core.windows.net";
2323

2424
/// <summary>
25-
/// The name of the Files Shares storage account to test against.
25+
/// The name of the Blob storage account to test against.
2626
/// </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");
27+
/// <value>The Blob storage account name, read from the "AZURE_STORAGE_ACCOUNT_NAME" environment variable.</value>
28+
public string StorageAccountName => GetVariable("AZURE_STORAGE_ACCOUNT_NAME");
2929

3030
/// <summary>
31-
/// The shared access key of the Files Shares storage account to test against.
31+
/// The shared access key of the Blob storage account to test against.
3232
/// </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");
33+
/// <value>The Blob storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value>
34+
public string StorageAccountKey => GetOptionalVariable("AZURE_STORAGE_ACCOUNT_KEY");
3535

3636
/// <summary>
37-
/// The connection string for accessing the Files Shares storage account used for testing.
37+
/// The Blob storage endpoint.
3838
/// </summary>
39-
public string FileSharesConnectionString { get; }
39+
public Uri StorageEndpoint { get; }
4040

4141
/// <summary>
4242
/// Initializes a new instance of the <see cref="PerfTestEnvironment"/> class.
4343
/// </summary>
4444
public PerfTestEnvironment()
4545
{
46-
FileSharesConnectionString = $"DefaultEndpointsProtocol={Uri.UriSchemeHttps};AccountName={FilesSharesAccountName};AccountKey={FilesSharesAccountKey};EndpointSuffix={StorageEndpointSuffix}";
46+
StorageEndpoint = new Uri($"https://{StorageAccountName}.file.{StorageEndpointSuffix}");
4747
}
4848
}
4949
}

sdk/storage/Azure.Storage.Files.Shares/perf/Azure.Storage.Files.Shares.Perf/Infrastructure/ServiceTest.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using Azure.Storage.Files.Shares.Models;
45
using Azure.Test.Perf;
56

67
namespace Azure.Storage.Files.Shares.Perf
@@ -15,11 +16,18 @@ public ServiceTest(TOptions options) : base(options)
1516
ShareClientOptions clientOptions = options is Options.IShareClientOptionsProvider clientOptionsProvider
1617
? clientOptionsProvider.ClientOptions
1718
: new ShareClientOptions();
19+
clientOptions.ShareTokenIntent = ShareTokenIntent.Backup;
1820
ShareServiceClient = new ShareServiceClient(
19-
PerfTestEnvironment.Instance.FileSharesConnectionString, ConfigureClientOptions(clientOptions));
21+
PerfTestEnvironment.Instance.StorageEndpoint,
22+
PerfTestEnvironment.Instance.Credential,
23+
ConfigureClientOptions(clientOptions));
2024

21-
StorageSharedKeyCredential = new StorageSharedKeyCredential(
22-
PerfTestEnvironment.Instance.FilesSharesAccountName, PerfTestEnvironment.Instance.FilesSharesAccountKey);
25+
// Can't do shared key tests if shared key wasn't provided
26+
if (PerfTestEnvironment.Instance.StorageAccountKey != null)
27+
{
28+
StorageSharedKeyCredential = new StorageSharedKeyCredential(
29+
PerfTestEnvironment.Instance.StorageAccountName, PerfTestEnvironment.Instance.StorageAccountKey);
30+
}
2331
}
2432
}
2533
}

0 commit comments

Comments
 (0)