Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1661,13 +1661,15 @@ public async Task KeyVaultReference_DifferentRefreshIntervals()
TestContext testContext = CreateTestContext("KeyVaultDifferentIntervals");
IConfigurationRefresher refresher = null;

// Create a secret in Key Vault with short refresh interval
string secretName1 = $"test-secret1-{Guid.NewGuid().ToString("N").Substring(0, 8)}";
// Create a secret in Key Vault with short refresh interval.
// Name must start with TestKeyPrefix so CleanupStaleResources() can find and delete it.
string secretName1 = $"{testContext.KeyPrefix}-secret1";
string secretValue1 = $"SecretValue1-{Guid.NewGuid().ToString("N").Substring(0, 8)}";
await _secretClient.SetSecretAsync(secretName1, secretValue1);

// Create another secret in Key Vault with long refresh interval
string secretName2 = $"test-secret2-{Guid.NewGuid().ToString("N").Substring(0, 8)}";
// Create another secret in Key Vault with long refresh interval.
// Name must start with TestKeyPrefix so CleanupStaleResources() can find and delete it.
string secretName2 = $"{testContext.KeyPrefix}-secret2";
string secretValue2 = $"SecretValue2-{Guid.NewGuid().ToString("N").Substring(0, 8)}";
await _secretClient.SetSecretAsync(secretName2, secretValue2);

Expand Down
12 changes: 6 additions & 6 deletions tests/Tests.AzureAppConfiguration/Unit/KeyVaultReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o

// Update sentinel key-value
sentinelKv = TestHelpers.ChangeValue(sentinelKv, "Value2");
Thread.Sleep(refreshInterval);
Thread.Sleep(refreshInterval + TimeSpan.FromSeconds(1)); // buffer avoids the boundary race on the refresh interval
await refresher.RefreshAsync();

Assert.Equal("Value2", config["Sentinel"]);
Expand Down Expand Up @@ -816,7 +816,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o

// Update sentinel key-value to trigger refresh operation
sentinelKv = TestHelpers.ChangeValue(sentinelKv, "Value2");
Thread.Sleep(refreshInterval);
Thread.Sleep(refreshInterval + TimeSpan.FromSeconds(1)); // buffer avoids the boundary race on the refresh interval
await refresher.RefreshAsync();

Assert.Equal("Value2", config["Sentinel"]);
Expand Down Expand Up @@ -861,7 +861,7 @@ public async Task SecretIsReloadedFromKeyVaultWhenCacheExpires()
Assert.Equal(_secretValue, config[_kv.Key]);

// Sleep to let the secret cache expire
Thread.Sleep(refreshInterval);
Thread.Sleep(refreshInterval + TimeSpan.FromSeconds(1)); // buffer avoids the boundary race on the refresh interval
await refresher.RefreshAsync();

Assert.Equal(_secretValue, config[_kv.Key]);
Expand Down Expand Up @@ -905,7 +905,7 @@ public async Task SecretsWithDefaultRefreshInterval()
Assert.Equal(_secretValue, config["TK2"]);

// Sleep to let the secret cache expire for both secrets
Thread.Sleep(shortRefreshInterval);
Thread.Sleep(shortRefreshInterval + TimeSpan.FromSeconds(1)); // buffer avoids the boundary race on the refresh interval
await refresher.RefreshAsync();

Assert.Equal(_secretValue, config["TK1"]);
Expand Down Expand Up @@ -951,8 +951,8 @@ public async Task SecretsWithDifferentRefreshIntervals()
Assert.Equal(_secretValue, config["TK1"]);
Assert.Equal(_secretValue, config["TK2"]);

// Sleep to let the secret cache expire for one secret
Thread.Sleep(shortRefreshInterval);
// Sleep past the short interval (plus a small buffer to avoid a boundary race) so only that secret's cache expires
Thread.Sleep(shortRefreshInterval + TimeSpan.FromSeconds(1));
await refresher.RefreshAsync();

Assert.Equal(_secretValue, config["TK1"]);
Expand Down
Loading