| 36 | // See examples like: https://github.com/googleapis/nodejs-monitoring/issues/190, |
| 37 | // https://github.com/googleapis/nodejs-monitoring/issues/191. |
| 38 | const delay = async test => { |
| 39 | const retries = test.currentRetry(); |
| 40 | if (retries === 0) return; // no retry on the first failure. |
| 41 | // see: https://cloud.google.com/storage/docs/exponential-backoff: |
| 42 | const ms = Math.pow(2, retries) * 500 + Math.random() * 1000; |
| 43 | return new Promise(done => { |
| 44 | console.info(`retrying "${test.title}" in ${ms}ms`); |
| 45 | setTimeout(done, ms); |
| 46 | }); |
| 47 | }; |
| 48 | |
| 49 | const getInstance = async (projectId, zone, instanceName) => { |
| 50 | const [instance] = await instancesClient.get({ |