diff --git a/sdk/tables/Azure.Data.Tables/tests/TableServiceClientLiveTests.cs b/sdk/tables/Azure.Data.Tables/tests/TableServiceClientLiveTests.cs index 2b3f63e7726a..a1245b84935e 100644 --- a/sdk/tables/Azure.Data.Tables/tests/TableServiceClientLiveTests.cs +++ b/sdk/tables/Azure.Data.Tables/tests/TableServiceClientLiveTests.cs @@ -245,17 +245,13 @@ public async Task GetPropertiesReturnsProperties() await service.SetPropertiesAsync(responseToChange).ConfigureAwait(false); - // Wait 20 sec if on Live mode to ensure properties are updated in the service - // Minimum time: Sync - 20 sec; Async - 12 sec - - if (Mode != RecordedTestMode.Playback) - { - await Task.Delay(20000); - } - // Get configured properties + // A delay is required to ensure properties are updated in the service - TableServiceProperties changedResponse = await service.GetPropertiesAsync().ConfigureAwait(false); + TableServiceProperties changedResponse = await RetryUntilExpectedResponse( + async () => await service.GetPropertiesAsync().ConfigureAwait(false), + result => result.Value.Logging.Read == responseToChange.Logging.Read, + 15000).ConfigureAwait(false); // Test each property diff --git a/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs b/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs index 942561e9b73e..4b231d8b5bac 100644 --- a/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs +++ b/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs @@ -262,6 +262,27 @@ protected async Task CosmosThrottleWrapper(Func> } } + protected async Task RetryUntilExpectedResponse(Func> action, Func equalityAction, int initialDelay) + { + int retryCount = 0; + int delay = initialDelay; + while (true) + { + var actual = await action().ConfigureAwait(false); + + if (++retryCount > 3 || equalityAction(actual)) + { + return actual; + } + // Disable retry throttling in Playback mode. + if (Mode != RecordedTestMode.Playback) + { + await Task.Delay(delay); + delay *= 2; + } + } + } + protected async Task CreateTestEntities(List entitiesToCreate) where T : class, ITableEntity, new() { foreach (var entity in entitiesToCreate)