Skip to content

Commit

Permalink
[Storage] Run only last SV in live tests. (#16826)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasobol-msft committed Nov 10, 2020
1 parent 7a8659e commit 52fb9b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public class ClientTestFixtureAttribute : NUnitAttribute, IFixtureBuilder2, IPre
{
public static readonly string SyncOnlyKey = "SyncOnly";
public static readonly string RecordingDirectorySuffixKey = "RecordingDirectory";
public static readonly string OnlyTestLatestServiceVersionKey = "AZURE_ONLY_TEST_LATEST_SERVICE_VERSION";

private static readonly Lazy<bool> OnlyTestLatestServiceVersionLazy = new Lazy<bool>(() =>
{
bool.TryParse(Environment.GetEnvironmentVariable(OnlyTestLatestServiceVersionKey), out bool onlyTestLatestServiceVersion);
return onlyTestLatestServiceVersion;
});

private readonly object[] _additionalParameters;
private readonly object[] _serviceVersions;
Expand Down Expand Up @@ -156,6 +163,13 @@ private void ProcessTest(object serviceVersion, bool isAsync, int serviceVersion
test.Properties.Add("SkipRecordings", $"Test is ignored when not running live because the service version {serviceVersion} is not the latest.");
}

if (OnlyTestLatestServiceVersionLazy.Value && serviceVersionNumber != _maxServiceVersion)
{
test.RunState = RunState.Ignored;
test.Properties.Set("_SKIPREASON",
$"Test ignored because {OnlyTestLatestServiceVersionKey} is set in the environment and version {serviceVersion} is not the latest.");
}

var minServiceVersion = test.GetCustomAttributes<ServiceVersionAttribute>(true);
foreach (ServiceVersionAttribute serviceVersionAttribute in minServiceVersion)
{
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ extends:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview)
TestSetupSteps:
- template: /sdk/storage/tests-install-azurite.yml
EnvVars:
AZURE_ONLY_TEST_LATEST_SERVICE_VERSION: true

0 comments on commit 52fb9b7

Please sign in to comment.