From db5f39c5068723727923060a60aacc3472eb1f67 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 18 Mar 2022 14:08:51 +0000 Subject: [PATCH] puppeteer tests: Try to diagnose/fix unsubscribe flakes. Doing these in a loop may help us figure out whether the flakes are somehow related to the initial conditions when we run the test vs. some race that can happen later in the loop. I add the console statements mostly to facilitate debugging, but they appear to actually reduce the problem, as the code comments indicate. --- .../puppeteer_tests/subscriptions.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/frontend_tests/puppeteer_tests/subscriptions.ts b/frontend_tests/puppeteer_tests/subscriptions.ts index 4f7bd0ea8e..f7f2a56b98 100644 --- a/frontend_tests/puppeteer_tests/subscriptions.ts +++ b/frontend_tests/puppeteer_tests/subscriptions.ts @@ -69,14 +69,22 @@ async function test_subscription_button(page: Page): Promise { // We assume Venice is already subscribed, so the first line here // should happen immediately. button = await subscribed(); - await button!.click(); - button = await unsubscribed(); - await button!.click(); - button = await subscribed(); - await button!.click(); - button = await unsubscribed(); - await button!.click(); - button = await subscribed(); + + // Toggle subscriptions several times. This test code has been known + // to flake, so we add console statements. It appears that the console + // statements help prevent the flake, which is probably caused by some + // subtle race condition. We will hopefully diagnose the root cause of + // the flake, but I am confident that the test will mostly catch actual + // bugs in the real code, so as long as the console.info statements help + // here, we should just leave them in. + for (let i = 0; i < 10; i += 1) { + console.info(`\n unsubscribe/subscribe loop ${i}\n\n`); + await button!.click(); + button = await unsubscribed(); + await button!.click(); + button = await subscribed(); + console.info(`\n end loop ${i}\n\n`); + } } async function click_create_new_stream(page: Page): Promise {