@@ -13,6 +13,7 @@ const { getRealAwsConfig } =
1313const {
1414 CreateBucketCommand,
1515 DeleteBucketCommand,
16+ HeadBucketCommand,
1617} = require ( '@aws-sdk/client-s3' ) ;
1718
1819const credentialOne = 'gcpbackend' ;
@@ -92,6 +93,21 @@ function emptyBucket(gcpClient, bucketName, cb) {
9293 } ) ;
9394}
9495
96+ function waitForBucketReady ( gcpClient , bucketName ) {
97+ const cmd = new HeadBucketCommand ( { Bucket : bucketName } ) ;
98+ return gcpRetry ( gcpClient , cmd , {
99+ maxAttempts : 6 ,
100+ shouldRetry : err => err && (
101+ err . name === 'NoSuchBucket'
102+ || err . name === 'NotFound'
103+ || err . $metadata ?. httpStatusCode === 404
104+ || err . name === 'SlowDown'
105+ || err . $metadata ?. httpStatusCode === 429
106+ ) ,
107+ getDelayMs : attempt => ( attempt + 1 ) * 1000 ,
108+ } ) ;
109+ }
110+
95111describe ( 'GCP: Complete MPU' , function testSuite ( ) {
96112 this . timeout ( 600000 ) ;
97113 let config ;
@@ -107,6 +123,7 @@ describe('GCP: Complete MPU', function testSuite() {
107123 const cmd = new CreateBucketCommand ( { Bucket : bucket . Name } ) ;
108124 try {
109125 await gcpRetry ( gcpClient , cmd ) ;
126+ await waitForBucketReady ( gcpClient , bucket . Name ) ;
110127 } catch ( err ) {
111128 process . stdout . write ( `err in creating bucket ${ err } \n` ) ;
112129 throw err ;
0 commit comments