File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,9 @@ async function main(dumpFilePath) {
4949 // Do things with with the response.
5050 console . log ( result ) ;
5151 }
52- exportAssets ( ) ;
52+ exportAssets ( ) . catch ( ( err ) => {
53+ throw err ;
54+ } ) ;
5355 // [END asset_quickstart_export_assets]
5456}
5557
Original file line number Diff line number Diff line change @@ -26,6 +26,20 @@ const storage = new Storage();
2626const bucketName = `asset-nodejs-${ uuid . v4 ( ) } ` ;
2727const bucket = storage . bucket ( bucketName ) ;
2828
29+ // Some of these tests can take an extremely long time, and occasionally
30+ // timeout, see:
31+ // "Timeout of 180000ms exceeded. For async tests and hooks".
32+ const delay = async test => {
33+ const retries = test . currentRetry ( ) ;
34+ if ( retries === 0 ) return ; // no retry on the first failure.
35+ // see: https://cloud.google.com/storage/docs/exponential-backoff:
36+ const ms = Math . pow ( 2 , retries ) * 1000 + Math . random ( ) * 2000 ;
37+ return new Promise ( done => {
38+ console . info ( `retrying "${ test . title } " in ${ ms } ms` ) ;
39+ setTimeout ( done , ms ) ;
40+ } ) ;
41+ } ;
42+
2943describe ( 'quickstart sample tests' , ( ) => {
3044 before ( async ( ) => {
3145 await bucket . create ( ) ;
@@ -35,7 +49,9 @@ describe('quickstart sample tests', () => {
3549 await bucket . delete ( ) ;
3650 } ) ;
3751
38- it ( 'should export assets to specified path' , async ( ) => {
52+ it ( 'should export assets to specified path' , async function ( ) {
53+ this . retries ( 2 ) ;
54+ await delay ( this . test ) ;
3955 const dumpFilePath = `gs://${ bucketName } /my-assets.txt` ;
4056 execSync ( `node exportAssets ${ dumpFilePath } ` ) ;
4157 const file = await bucket . file ( 'my-assets.txt' ) ;
You can’t perform that action at this time.
0 commit comments