forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to add setup/cleanup methods (#1)
- Loading branch information
1 parent
c8a755b
commit 64ddc98
Showing
23 changed files
with
406 additions
and
285 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
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
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,36 @@ | ||
using Azure.Test.PerfStress; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public abstract class ContainerTest<TOptions> : ServiceTest<TOptions> where TOptions : PerfStressOptions | ||
{ | ||
private const string _containerPrefix = "perfstress"; | ||
protected static string ContainerName { get; private set; } | ||
|
||
static ContainerTest() | ||
{ | ||
ContainerName = _containerPrefix + "-" + Guid.NewGuid().ToString(); | ||
} | ||
|
||
protected BlobContainerClient BlobContainerClient { get; private set; } | ||
|
||
public ContainerTest(TOptions options) : base(options) | ||
{ | ||
BlobContainerClient = BlobServiceClient.GetBlobContainerClient(ContainerName); | ||
} | ||
|
||
public override async Task GlobalSetup() | ||
{ | ||
await base.GlobalSetup(); | ||
await BlobContainerClient.CreateAsync(); | ||
} | ||
|
||
public override async Task GlobalCleanup() | ||
{ | ||
await BlobContainerClient.DeleteAsync(); | ||
await base.GlobalCleanup(); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
net/Azure.Storage.Blobs.PerfStress/Core/ContainerV11Test.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,37 @@ | ||
using Azure.Test.PerfStress; | ||
using Microsoft.Azure.Storage.Blob; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public abstract class ContainerV11Test<TOptions> : ServiceV11Test<TOptions> where TOptions: PerfStressOptions | ||
{ | ||
private const string _containerPrefix = "perfstress"; | ||
protected static string ContainerName { get; private set; } | ||
|
||
static ContainerV11Test() | ||
{ | ||
ContainerName = _containerPrefix + "-" + Guid.NewGuid().ToString(); | ||
} | ||
|
||
protected CloudBlobContainer CloudBlobContainer { get; private set; } | ||
|
||
public ContainerV11Test(TOptions options) : base(options) | ||
{ | ||
CloudBlobContainer = CloudBlobClient.GetContainerReference(ContainerName); | ||
} | ||
|
||
public override async Task GlobalSetup() | ||
{ | ||
await base.GlobalSetup(); | ||
await CloudBlobContainer.CreateAsync(); | ||
} | ||
|
||
public override async Task GlobalCleanup() | ||
{ | ||
await CloudBlobContainer.DeleteAsync(); | ||
await base.GlobalCleanup(); | ||
} | ||
} | ||
} |
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,11 @@ | ||
using Azure.Test.PerfStress; | ||
using CommandLine; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public class CountOptions : PerfStressOptions | ||
{ | ||
[Option('c', "count", Default = 100, HelpText = "Number of blobs")] | ||
public int Count { get; set; } | ||
} | ||
} |
37 changes: 34 additions & 3 deletions
37
net/Azure.Storage.Blobs.PerfStress/Core/ParallelTransferOptionsOptions.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 |
---|---|---|
@@ -1,13 +1,44 @@ | ||
using CommandLine; | ||
using Azure.Storage.Common; | ||
using CommandLine; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public class ParallelTransferOptionsOptions : SizeOptions | ||
{ | ||
private int? _maximumTransferLength; | ||
private int? _maximumThreadCount; | ||
|
||
[Option('l', "maximumTransferLength")] | ||
public int? MaximumTransferLength { get; set; } | ||
public int? MaximumTransferLength | ||
{ | ||
get => _maximumTransferLength; | ||
set | ||
{ | ||
_maximumTransferLength = value; | ||
UpdateParallelTransferOptions(); | ||
} | ||
} | ||
|
||
[Option('t', "maximumThreadCount")] | ||
public int? MaximumThreadCount { get; set; } | ||
public int? MaximumThreadCount | ||
{ | ||
get => _maximumThreadCount; | ||
set | ||
{ | ||
_maximumThreadCount = value; | ||
UpdateParallelTransferOptions(); | ||
} | ||
} | ||
|
||
public ParallelTransferOptions ParallelTransferOptions { get; private set; } = new ParallelTransferOptions(); | ||
|
||
private void UpdateParallelTransferOptions() | ||
{ | ||
ParallelTransferOptions = new ParallelTransferOptions() | ||
{ | ||
MaximumThreadCount = MaximumThreadCount, | ||
MaximumTransferLength = MaximumTransferLength | ||
}; | ||
} | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
net/Azure.Storage.Blobs.PerfStress/Core/ParallelTransferTest.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
net/Azure.Storage.Blobs.PerfStress/Core/RandomDataV11Test.cs
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public static class RandomStream | ||
{ | ||
private static readonly Lazy<byte[]> _randomBytes = new Lazy<byte[]>(() => | ||
{ | ||
var randomData = new byte[1024 * 1024]; | ||
(new Random(0)).NextBytes(randomData); | ||
return randomData; | ||
}); | ||
|
||
public static Stream Create(long size) => new CircularStream(new MemoryStream(_randomBytes.Value, writable: false), size); | ||
} | ||
} |
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
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,27 @@ | ||
using Azure.Test.PerfStress; | ||
using Microsoft.Azure.Storage; | ||
using Microsoft.Azure.Storage.Blob; | ||
using System; | ||
|
||
namespace Azure.Storage.Blobs.PerfStress.Core | ||
{ | ||
public abstract class ServiceV11Test<TOptions> : PerfStressTest<TOptions> where TOptions : PerfStressOptions | ||
{ | ||
protected CloudBlobClient CloudBlobClient { get; private set; } | ||
|
||
public ServiceV11Test(TOptions options) : base(options) | ||
{ | ||
var connectionString = Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING"); | ||
|
||
if (string.IsNullOrEmpty(connectionString)) | ||
{ | ||
throw new InvalidOperationException("Undefined environment variable STORAGE_CONNECTION_STRING"); | ||
} | ||
|
||
CloudStorageAccount.TryParse(connectionString, out var storageAccount); | ||
|
||
|
||
CloudBlobClient = storageAccount.CreateCloudBlobClient(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.