Skip to content

Commit 52fb9b7

Browse files
authored
[Storage] Run only last SV in live tests. (Azure#16826)
1 parent 7a8659e commit 52fb9b7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

sdk/core/Azure.Core.TestFramework/src/ClientTestFixtureAttribute.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ public class ClientTestFixtureAttribute : NUnitAttribute, IFixtureBuilder2, IPre
1515
{
1616
public static readonly string SyncOnlyKey = "SyncOnly";
1717
public static readonly string RecordingDirectorySuffixKey = "RecordingDirectory";
18+
public static readonly string OnlyTestLatestServiceVersionKey = "AZURE_ONLY_TEST_LATEST_SERVICE_VERSION";
19+
20+
private static readonly Lazy<bool> OnlyTestLatestServiceVersionLazy = new Lazy<bool>(() =>
21+
{
22+
bool.TryParse(Environment.GetEnvironmentVariable(OnlyTestLatestServiceVersionKey), out bool onlyTestLatestServiceVersion);
23+
return onlyTestLatestServiceVersion;
24+
});
1825

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

166+
if (OnlyTestLatestServiceVersionLazy.Value && serviceVersionNumber != _maxServiceVersion)
167+
{
168+
test.RunState = RunState.Ignored;
169+
test.Properties.Set("_SKIPREASON",
170+
$"Test ignored because {OnlyTestLatestServiceVersionKey} is set in the environment and version {serviceVersion} is not the latest.");
171+
}
172+
159173
var minServiceVersion = test.GetCustomAttributes<ServiceVersionAttribute>(true);
160174
foreach (ServiceVersionAttribute serviceVersionAttribute in minServiceVersion)
161175
{

sdk/storage/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ extends:
1010
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview)
1111
TestSetupSteps:
1212
- template: /sdk/storage/tests-install-azurite.yml
13+
EnvVars:
14+
AZURE_ONLY_TEST_LATEST_SERVICE_VERSION: true

0 commit comments

Comments
 (0)