Skip to content

chore: retry flaky tests for exceed administrative requests per minute quota error #1149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 18, 2020
Merged
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
38 changes: 29 additions & 9 deletions system-test/spanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from '../src/transaction';
import {Row} from '../src/partial-result-stream';
import {GetDatabaseConfig} from '../src/database';
import {grpc} from 'google-gax';
import {grpc, CallOptions} from 'google-gax';
import {google} from '../protos/protos';
import CreateDatabaseMetadata = google.spanner.admin.database.v1.CreateDatabaseMetadata;
import CreateBackupMetadata = google.spanner.admin.database.v1.CreateBackupMetadata;
Expand All @@ -44,6 +44,24 @@ const spanner = new Spanner({
projectId: process.env.GCLOUD_PROJECT,
apiEndpoint: process.env.API_ENDPOINT,
});
const GAX_OPTIONS: CallOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Is it possible to add the same logic to the samples tests? The quota issue can happen in both types of tests.

retry: {
retryCodes: [
grpc.status.RESOURCE_EXHAUSTED,
grpc.status.DEADLINE_EXCEEDED,
grpc.status.UNAVAILABLE,
],
backoffSettings: {
initialRetryDelayMillis: 1000,
retryDelayMultiplier: 1.3,
maxRetryDelayMillis: 32000,
initialRpcTimeoutMillis: 60000,
rpcTimeoutMultiplier: 1,
maxRpcTimeoutMillis: 60000,
totalTimeoutMillis: 600000,
},
},
};

const CURRENT_TIME = Math.round(Date.now() / 1000).toString();

Expand Down Expand Up @@ -97,7 +115,7 @@ describe('Spanner', () => {
await Promise.all(
RESOURCES_TO_CLEAN.filter(
resource => resource instanceof Backup
).map(backup => backup.delete())
).map(backup => backup.delete(GAX_OPTIONS))
);
/**
* Deleting instances created during this test.
Expand All @@ -107,7 +125,7 @@ describe('Spanner', () => {
await Promise.all(
RESOURCES_TO_CLEAN.filter(
resource => resource instanceof Instance
).map(instance => instance.delete())
).map(instance => instance.delete(GAX_OPTIONS))
);
} else {
/**
Expand All @@ -117,7 +135,9 @@ describe('Spanner', () => {
*/
const limit = pLimit(5);
await Promise.all(
RESOURCES_TO_CLEAN.map(resource => limit(() => resource.delete()))
RESOURCES_TO_CLEAN.map(resource =>
limit(() => resource.delete(GAX_OPTIONS))
)
);
}
});
Expand Down Expand Up @@ -1040,6 +1060,7 @@ describe('Spanner', () => {
AlbumId STRING(1024) NOT NULL,
AlbumTitle STRING(1024) NOT NULL,
) PRIMARY KEY(AlbumId)`,
gaxOptions: GAX_OPTIONS,
});
await database2CreateOperation.promise();
RESOURCES_TO_CLEAN.push(database2);
Expand All @@ -1053,10 +1074,12 @@ describe('Spanner', () => {
const [, backup1Operation] = await backup1.create({
databasePath: database1.formattedName_,
expireTime: backupExpiryDate,
gaxOptions: GAX_OPTIONS,
});
const [, backup2Operation] = await backup2.create({
databasePath: database2.formattedName_,
expireTime: backupExpiryDate,
gaxOptions: GAX_OPTIONS,
});

assert.strictEqual(
Expand Down Expand Up @@ -1383,15 +1406,12 @@ describe('Spanner', () => {
Accents ARRAY<STRING(1024)>,
PhoneNumbers ARRAY<INT64>,
HasGear BOOL,
) PRIMARY KEY(SingerId)`
) PRIMARY KEY(SingerId)`,
GAX_OPTIONS
)
.then(onPromiseOperationComplete);
});

after(() => {
return table.delete().then(onPromiseOperationComplete);
});

it('should throw an error for non-existant tables', done => {
const table = DATABASE.table(generateName('nope'));

Expand Down