From ff6e06e5451116d0421008ab29aa4049dd372044 Mon Sep 17 00:00:00 2001 From: Patti Shin Date: Thu, 16 Jun 2022 18:51:34 -0700 Subject: [PATCH 1/4] refactor: adding additional asserts to track flaky error --- samples/test/containerAnalysis.test.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/samples/test/containerAnalysis.test.js b/samples/test/containerAnalysis.test.js index 350e0e6..946f688 100644 --- a/samples/test/containerAnalysis.test.js +++ b/samples/test/containerAnalysis.test.js @@ -303,7 +303,7 @@ describe('polling', () => { }); }); -describe('pubsub', () => { +describe.only('pubsub', () => { before(async () => { // define project id and related vars projectId = await client.getProjectId(); @@ -402,13 +402,27 @@ describe('pubsub', () => { }); it('should delete the pubsub subscription', async function () { + // TODO: Verify first that subscription exists + // TODO: Verify that the grafeas client completed without erroring out (wrap in try/catch) + // TODO: Verify that the initial subscription checked has in fact been deleted + // TODO: Attempt to remove retries or create log trail to trace back + this.retries(3); await delay(this.test); - await client - .getGrafeasClient() - .deleteNote({name: `${formattedNoteName}-pubsub`}); - await pubsub.subscription(subscriptionId).delete(); + try { + await client + .getGrafeasClient() + .deleteNote({name: `${formattedNoteName}-pubsub`}); + } catch(err) { + assert.fail('Deletion of Grafeas note related to subscription failed with error: ', err); + } + + try { + await pubsub.subscription(subscriptionId).delete(); + } catch(err) { + assert.fail('Deletion of subscription failed with error: ', err); + } }); }); }); From 7cdc4b6a54af3c80923762f9541b22b2969dc079 Mon Sep 17 00:00:00 2001 From: Patti Shin Date: Thu, 16 Jun 2022 18:53:29 -0700 Subject: [PATCH 2/4] refactor: remove .only from test --- samples/test/containerAnalysis.test.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/samples/test/containerAnalysis.test.js b/samples/test/containerAnalysis.test.js index 946f688..9224487 100644 --- a/samples/test/containerAnalysis.test.js +++ b/samples/test/containerAnalysis.test.js @@ -303,7 +303,7 @@ describe('polling', () => { }); }); -describe.only('pubsub', () => { +describe('pubsub', () => { before(async () => { // define project id and related vars projectId = await client.getProjectId(); @@ -402,11 +402,6 @@ describe.only('pubsub', () => { }); it('should delete the pubsub subscription', async function () { - // TODO: Verify first that subscription exists - // TODO: Verify that the grafeas client completed without erroring out (wrap in try/catch) - // TODO: Verify that the initial subscription checked has in fact been deleted - // TODO: Attempt to remove retries or create log trail to trace back - this.retries(3); await delay(this.test); From f50fd001ce692da84b278f2beb4da9afa0e247bb Mon Sep 17 00:00:00 2001 From: Patti Shin Date: Thu, 16 Jun 2022 19:00:38 -0700 Subject: [PATCH 3/4] refactor: fix lint --- samples/test/containerAnalysis.test.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/samples/test/containerAnalysis.test.js b/samples/test/containerAnalysis.test.js index 9224487..3bd1fef 100644 --- a/samples/test/containerAnalysis.test.js +++ b/samples/test/containerAnalysis.test.js @@ -409,13 +409,16 @@ describe('pubsub', () => { await client .getGrafeasClient() .deleteNote({name: `${formattedNoteName}-pubsub`}); - } catch(err) { - assert.fail('Deletion of Grafeas note related to subscription failed with error: ', err); + } catch (err) { + assert.fail( + 'Deletion of Grafeas note related to subscription failed with error: ', + err + ); } - + try { await pubsub.subscription(subscriptionId).delete(); - } catch(err) { + } catch (err) { assert.fail('Deletion of subscription failed with error: ', err); } }); From 2bfd79f79f016de171a3a3a147ab67cdab9ebc21 Mon Sep 17 00:00:00 2001 From: Patti Shin Date: Wed, 22 Jun 2022 17:32:02 -0700 Subject: [PATCH 4/4] refactor: update assert.fail msg --- samples/test/containerAnalysis.test.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/samples/test/containerAnalysis.test.js b/samples/test/containerAnalysis.test.js index 3bd1fef..56fd621 100644 --- a/samples/test/containerAnalysis.test.js +++ b/samples/test/containerAnalysis.test.js @@ -410,16 +410,13 @@ describe('pubsub', () => { .getGrafeasClient() .deleteNote({name: `${formattedNoteName}-pubsub`}); } catch (err) { - assert.fail( - 'Deletion of Grafeas note related to subscription failed with error: ', - err - ); + assert.fail(err); } try { await pubsub.subscription(subscriptionId).delete(); } catch (err) { - assert.fail('Deletion of subscription failed with error: ', err); + assert.fail(err); } }); });