From 427923fd192112510ecd7e68fb4fd84fee9f64fa Mon Sep 17 00:00:00 2001 From: peter-zheng-g <43967553+peter-zheng-g@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:40:31 -0700 Subject: [PATCH] build: make quickstart sample tests more stable (#547) * CloudAsset: Update asset lib to v1 for ListAssets sample code * CloudAsset: Fix flakiness of test of BatchGetAssetsHistory sample code * CloudAsset: Remove unneeded output line in sample test Co-authored-by: Benjamin E. Coe Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> --- .../google-cloud-asset/samples/test/sample.test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-asset/samples/test/sample.test.js b/packages/google-cloud-asset/samples/test/sample.test.js index ec52cc3b9ce0..fa474f58dea8 100644 --- a/packages/google-cloud-asset/samples/test/sample.test.js +++ b/packages/google-cloud-asset/samples/test/sample.test.js @@ -79,8 +79,14 @@ describe('quickstart sample tests', () => { // the newly created bucket: it('should get assets history successfully', async () => { const assetName = `//storage.googleapis.com/${bucketName}`; - const stdout = execSync(`node getBatchAssetHistory ${assetName}`); - assert.include(stdout, assetName); + let waitMs = 1000; + let included = false; + for (let retry = 0; retry < 3 && !included; ++retry) { + await sleep((waitMs *= 2)); + const stdout = execSync(`node getBatchAssetHistory ${assetName}`); + included = stdout.includes(assetName); + } + assert.ok(included); }); it('should run the quickstart', async () => {