Skip to content

Commit

Permalink
Permit more retries in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Siegel committed Sep 7, 2020
1 parent feee306 commit f906ec6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.data.tables;

import com.azure.core.http.HttpClient;
import com.azure.core.http.policy.ExponentialBackoff;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.RetryPolicy;
Expand All @@ -25,7 +26,7 @@
* Tests methods for {@link TableServiceAsyncClient}.
*/
public class TableServiceAsyncClientTest extends TestBase {
private static final Duration TIMEOUT = Duration.ofSeconds(30);
private static final Duration TIMEOUT = Duration.ofSeconds(100);
private CosmosThrottled<TableServiceAsyncClient> runner;

@BeforeAll
Expand All @@ -52,7 +53,8 @@ protected void beforeTest() {
if (!interceptorManager.isLiveMode()) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}
builder.addPolicy(new RetryPolicy());
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}

runner = CosmosThrottled.get(builder.buildAsyncClient(), interceptorManager.isPlaybackMode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.data.tables;

import com.azure.core.http.HttpClient;
import com.azure.core.http.policy.ExponentialBackoff;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.RetryPolicy;
Expand All @@ -12,6 +13,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.time.Duration;

public class TableServiceClientTest extends TestBase {
private CosmosThrottled<TableServiceClient> runner;

Expand All @@ -29,7 +32,8 @@ protected void beforeTest() {
if (!interceptorManager.isLiveMode()) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}
builder.addPolicy(new RetryPolicy());
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}
runner = CosmosThrottled.get(builder.buildClient(), interceptorManager.isPlaybackMode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.data.tables;

import com.azure.core.http.HttpClient;
import com.azure.core.http.policy.ExponentialBackoff;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpPipelinePolicy;
Expand All @@ -12,6 +13,8 @@
import com.azure.data.tables.models.ListEntitiesOptions;
import com.azure.data.tables.models.TableEntity;
import com.azure.data.tables.models.UpdateMode;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import reactor.test.StepVerifier;
Expand All @@ -31,12 +34,22 @@
* Tests {@link TableAsyncClient}.
*/
public class TablesAsyncClientTest extends TestBase {
private static final Duration TIMEOUT = Duration.ofSeconds(30);
private static final Duration TIMEOUT = Duration.ofSeconds(100);

private CosmosThrottled<TableAsyncClient> runner;
private HttpPipelinePolicy recordPolicy;
private HttpClient playbackClient;

@BeforeAll
static void beforeAll() {
StepVerifier.setDefaultTimeout(TIMEOUT);
}

@AfterAll
static void afterAll() {
StepVerifier.resetDefaultTimeout();
}

@Override
protected void beforeTest() {
final String tableName = testResourceNamer.randomName("tableName", 20);
Expand All @@ -55,7 +68,8 @@ protected void beforeTest() {
recordPolicy = interceptorManager.getRecordPolicy();
builder.addPolicy(recordPolicy);
}
builder.addPolicy(new RetryPolicy());
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}

runner = CosmosThrottled.get(builder.buildAsyncClient(), interceptorManager.isPlaybackMode());
Expand All @@ -79,7 +93,8 @@ void createTableAsync() {
if (!interceptorManager.isLiveMode()) {
builder.addPolicy(recordPolicy);
}
builder.addPolicy(new RetryPolicy());
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}

final CosmosThrottled<TableAsyncClient> runner2 = CosmosThrottled.get(builder.buildAsyncClient(),
Expand Down Expand Up @@ -108,7 +123,8 @@ void createTableWithResponseAsync() {
if (!interceptorManager.isLiveMode()) {
builder.addPolicy(recordPolicy);
}
builder.addPolicy(new RetryPolicy());
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}

final CosmosThrottled<TableAsyncClient> runner2 = CosmosThrottled.get(builder.buildAsyncClient(),
Expand Down Expand Up @@ -355,7 +371,7 @@ void updateEntityWithResponseAsync(UpdateMode mode) {
createdEntity.addProperty(newPropertyKey, "valueB");

// Act & Assert
if (mode == UpdateMode.MERGE && runner.getClient().getTableUrl().contains("cosmos.azure.com")) {
if (mode == UpdateMode.MERGE && runner.isCosmos()) {
// This scenario is currently broken when using the CosmosDB Table API
StepVerifier.create(runner.run(tableClient -> tableClient.updateEntityWithResponse(createdEntity, true, mode)))
.expectError(com.azure.data.tables.implementation.models.TableServiceErrorException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.AddHeadersPolicy;
import com.azure.core.http.policy.ExponentialBackoff;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
Expand Down Expand Up @@ -56,7 +57,7 @@
* This class tests the Autorest code for the Tables track 2 SDK
*/
public class AzureTableImplTest extends TestBase {
private static final int TIMEOUT_IN_MS = 5000;
private static final int TIMEOUT_IN_MS = 100_000;

private final QueryOptions defaultQueryOptions = new QueryOptions()
.setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA);
Expand Down Expand Up @@ -104,7 +105,7 @@ protected void beforeTest() {
HttpPipelinePolicy recordPolicy = interceptorManager.getRecordPolicy();
policies.add(recordPolicy);
}
policies.add(new RetryPolicy());
policies.add(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500), Duration.ofSeconds(100))));
}

HttpPipeline pipeline = new HttpPipelineBuilder()
Expand Down

0 comments on commit f906ec6

Please sign in to comment.