Skip to content

Commit 3c9dbe1

Browse files
authored
Speed up KV tests (Azure#20640)
1 parent 3fc56b2 commit 3c9dbe1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

sdk/keyvault/Microsoft.Azure.KeyVault/tests/TestFramework/KeyVaultTestFixture.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@ public class KeyVaultTestFixture : IDisposable
3131
public string keyVersion;
3232
public KeyIdentifier keyIdentifier;
3333
public ClientCredential clientCredential;
34-
public RetryPolicy retryExecutor;
34+
public RetryPolicy retryExecutor
35+
{
36+
get
37+
{
38+
switch (HttpMockServer.Mode)
39+
{
40+
case HttpRecorderMode.None:
41+
return new RetryPolicy<SoftDeleteErrorDetectionStrategy>(new FixedIntervalRetryStrategy(5, TimeSpan.FromSeconds(5.0)));
42+
case HttpRecorderMode.Record:
43+
return new RetryPolicy<SoftDeleteErrorDetectionStrategy>(new ExponentialBackoffRetryStrategy(8, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(5)));
44+
case HttpRecorderMode.Playback:
45+
return new RetryPolicy<SoftDeleteErrorDetectionStrategy>(new FixedIntervalRetryStrategy(5, TimeSpan.Zero));
46+
default:
47+
throw new NotSupportedException($"{HttpMockServer.Mode} is not supported");
48+
}
49+
}
50+
}
51+
3552
public string StorageResourceUrl1;
3653
public string StorageResourceUrl2;
3754

@@ -58,10 +75,6 @@ public KeyVaultTestFixture()
5875
keyVersion = keyIdentifier.Version;
5976
tokenCache = new TokenCache();
6077
_deviceCodeForStorageTests = null;
61-
retryExecutor = new RetryPolicy<SoftDeleteErrorDetectionStrategy>(new ExponentialBackoffRetryStrategy(8, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(5)));
62-
} else
63-
{
64-
retryExecutor = new RetryPolicy<SoftDeleteErrorDetectionStrategy>( new FixedIntervalRetryStrategy( 5, TimeSpan.FromSeconds( 5.0 ) ) );
6578
}
6679
}
6780

0 commit comments

Comments
 (0)