Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit ee5aee9

Browse files
authored
test: introduce slight delay to file acl test (#1944)
* test: introduce slight delay to file acl test * improve logic in acl tests to wait for eventually consistent operations * simplify logic with busy loop instead of IIFE
1 parent a9c4c18 commit ee5aee9

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

system-test/storage.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ import {IdempotencyStrategy} from '../src/storage';
4848
// running inside VPCSC.
4949
const RUNNING_IN_VPCSC = !!process.env['GOOGLE_CLOUD_TESTS_IN_VPCSC'];
5050

51+
const UNIFORM_ACCESS_TIMEOUT = 60 * 1000; // 60s see: https://cloud.google.com/storage/docs/consistency#eventually_consistent_operations
52+
const UNIFORM_ACCESS_WAIT_TIME = 5 * 1000; // 5s
53+
5154
// block all attempts to chat with the metadata server (kokoro runs on GCE)
5255
nock('http://metadata.google.internal')
5356
.get(() => true)
@@ -1026,9 +1029,17 @@ describe('storage', () => {
10261029
await setUniformBucketLevelAccess(bucket, true);
10271030
await setUniformBucketLevelAccess(bucket, false);
10281031

1029-
const [aclAfter] = await bucket.acl.default.get();
1030-
assert.deepStrictEqual(aclAfter, aclBefore);
1031-
});
1032+
// Setting uniform bucket level access is eventually consistent and may take up to a minute to be reflected
1033+
for (;;) {
1034+
try {
1035+
const [aclAfter] = await bucket.acl.default.get();
1036+
assert.deepStrictEqual(aclAfter, aclBefore);
1037+
break;
1038+
} catch {
1039+
await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME));
1040+
}
1041+
}
1042+
}).timeout(UNIFORM_ACCESS_TIMEOUT);
10321043

10331044
it('should preserve file ACL', async () => {
10341045
const file = bucket.file(`file-${uuid.v4()}`);
@@ -1040,9 +1051,17 @@ describe('storage', () => {
10401051
await setUniformBucketLevelAccess(bucket, true);
10411052
await setUniformBucketLevelAccess(bucket, false);
10421053

1043-
const [aclAfter] = await file.acl.get();
1044-
assert.deepStrictEqual(aclAfter, aclBefore);
1045-
});
1054+
// Setting uniform bucket level access is eventually consistent and may take up to a minute to be reflected
1055+
for (;;) {
1056+
try {
1057+
const [aclAfter] = await file.acl.get();
1058+
assert.deepStrictEqual(aclAfter, aclBefore);
1059+
break;
1060+
} catch {
1061+
await new Promise(res => setTimeout(res, UNIFORM_ACCESS_WAIT_TIME));
1062+
}
1063+
}
1064+
}).timeout(UNIFORM_ACCESS_TIMEOUT);
10461065
});
10471066
});
10481067

0 commit comments

Comments
 (0)