Skip to content

Commit

Permalink
test: improve execution speed of tests (#1151)
Browse files Browse the repository at this point in the history
* test: improve execution speed of tests

* fix: address review comments + serialize scripts in ITs

* fix: add last batch to list

* fix: create new list instead of clearing it

* build: remove custom skip tests variable

* test: add test for retry admin requests
  • Loading branch information
olavloite committed May 11, 2021
1 parent cd45643 commit 6ce4c2d
Show file tree
Hide file tree
Showing 24 changed files with 1,425 additions and 1,580 deletions.
2 changes: 0 additions & 2 deletions google-cloud-spanner/pom.xml
Expand Up @@ -15,7 +15,6 @@
</parent>
<properties>
<site.installationModule>google-cloud-spanner</site.installationModule>
<skipUTs>false</skipUTs>
</properties>


Expand Down Expand Up @@ -51,7 +50,6 @@
<id>default-test</id>
<configuration>
<excludedGroups>com.google.cloud.spanner.TracerTest,com.google.cloud.spanner.IntegrationTest</excludedGroups>
<skipTests>${skipUTs}</skipTests>
</configuration>
</execution>
<execution>
Expand Down
Expand Up @@ -104,6 +104,7 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
private final DatabaseAdminStubSettings databaseAdminStubSettings;
private final Duration partitionedDmlTimeout;
private final boolean autoThrottleAdministrativeRequests;
private final RetrySettings retryAdministrativeRequestsSettings;
private final boolean trackTransactionStarter;
/**
* These are the default {@link QueryOptions} defined by the user on this {@link SpannerOptions}.
Expand Down Expand Up @@ -554,6 +555,7 @@ private SpannerOptions(Builder builder) {
}
partitionedDmlTimeout = builder.partitionedDmlTimeout;
autoThrottleAdministrativeRequests = builder.autoThrottleAdministrativeRequests;
retryAdministrativeRequestsSettings = builder.retryAdministrativeRequestsSettings;
trackTransactionStarter = builder.trackTransactionStarter;
defaultQueryOptions = builder.defaultQueryOptions;
envQueryOptions = builder.getEnvironmentQueryOptions();
Expand Down Expand Up @@ -606,6 +608,13 @@ public static class Builder
extends ServiceOptions.Builder<Spanner, SpannerOptions, SpannerOptions.Builder> {
static final int DEFAULT_PREFETCH_CHUNKS = 4;
static final QueryOptions DEFAULT_QUERY_OPTIONS = QueryOptions.getDefaultInstance();
static final RetrySettings DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofSeconds(5L))
.setRetryDelayMultiplier(2.0)
.setMaxRetryDelay(Duration.ofSeconds(60L))
.setMaxAttempts(10)
.build();
private final ImmutableSet<String> allowedClientLibTokens =
ImmutableSet.of(
ServiceOptions.getGoogApiClientLibName(),
Expand All @@ -632,6 +641,8 @@ public static class Builder
private DatabaseAdminStubSettings.Builder databaseAdminStubSettingsBuilder =
DatabaseAdminStubSettings.newBuilder();
private Duration partitionedDmlTimeout = Duration.ofHours(2L);
private RetrySettings retryAdministrativeRequestsSettings =
DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS;
private boolean autoThrottleAdministrativeRequests = false;
private boolean trackTransactionStarter = false;
private Map<DatabaseId, QueryOptions> defaultQueryOptions = new HashMap<>();
Expand Down Expand Up @@ -680,6 +691,7 @@ private Builder() {
this.databaseAdminStubSettingsBuilder = options.databaseAdminStubSettings.toBuilder();
this.partitionedDmlTimeout = options.partitionedDmlTimeout;
this.autoThrottleAdministrativeRequests = options.autoThrottleAdministrativeRequests;
this.retryAdministrativeRequestsSettings = options.retryAdministrativeRequestsSettings;
this.trackTransactionStarter = options.trackTransactionStarter;
this.defaultQueryOptions = options.defaultQueryOptions;
this.callCredentialsProvider = options.callCredentialsProvider;
Expand Down Expand Up @@ -892,6 +904,16 @@ public Builder setAutoThrottleAdministrativeRequests() {
return this;
}

/**
* Sets the retry settings for retrying administrative requests when the quote of administrative
* requests per minute has been exceeded.
*/
Builder setRetryAdministrativeRequestsSettings(
RetrySettings retryAdministrativeRequestsSettings) {
this.retryAdministrativeRequestsSettings = retryAdministrativeRequestsSettings;
return this;
}

/**
* Instructs the client library to track the first request of each read/write transaction. This
* statement will include a BeginTransaction option and will return a transaction id as part of
Expand Down Expand Up @@ -1092,6 +1114,10 @@ public boolean isAutoThrottleAdministrativeRequests() {
return autoThrottleAdministrativeRequests;
}

public RetrySettings getRetryAdministrativeRequestsSettings() {
return retryAdministrativeRequestsSettings;
}

public boolean isTrackTransactionStarter() {
return trackTransactionStarter;
}
Expand Down

0 comments on commit 6ce4c2d

Please sign in to comment.