Skip to content

Commit 2c567b0

Browse files
authored
test: add delay to metadata updates in bucket kms tests (#2229)
* test: add delay to metadata updates in bucket kms tests * add comment
1 parent ae83421 commit 2c567b0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

system-test/storage.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const RUNNING_IN_VPCSC = !!process.env['GOOGLE_CLOUD_TESTS_IN_VPCSC'];
5959

6060
const UNIFORM_ACCESS_TIMEOUT = 60 * 1000; // 60s see: https://cloud.google.com/storage/docs/consistency#eventually_consistent_operations
6161
const UNIFORM_ACCESS_WAIT_TIME = 5 * 1000; // 5s
62+
const BUCKET_METADATA_UPDATE_WAIT_TIME = 1000; // 1s buckets have a max rate of one metadata update per second.
6263

6364
// block all attempts to chat with the metadata server (kokoro runs on GCE)
6465
nock('http://metadata.google.internal')
@@ -2554,6 +2555,9 @@ describe('storage', () => {
25542555
});
25552556

25562557
beforeEach(async () => {
2558+
await new Promise(res =>
2559+
setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME)
2560+
);
25572561
await bucket.setMetadata({
25582562
encryption: {
25592563
defaultKmsKeyName: kmsKeyName,
@@ -2562,6 +2566,9 @@ describe('storage', () => {
25622566
});
25632567

25642568
afterEach(async () => {
2569+
await new Promise(res =>
2570+
setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME)
2571+
);
25652572
await bucket.setMetadata({
25662573
encryption: null,
25672574
});
@@ -2583,6 +2590,9 @@ describe('storage', () => {
25832590
const newKmsKeyName = generateKmsKeyName(cryptoKeyId);
25842591

25852592
await createCryptoKeyAsync(cryptoKeyId);
2593+
await new Promise(res =>
2594+
setTimeout(res, BUCKET_METADATA_UPDATE_WAIT_TIME)
2595+
);
25862596
await bucket.setMetadata({
25872597
encryption: {
25882598
defaultKmsKeyName: newKmsKeyName,

0 commit comments

Comments
 (0)