From fbedcebe7cf3ed8713e4e7e215b29d7402d38643 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 11:59:00 +0200 Subject: [PATCH 1/9] chore: turn on some debug logging Signed-off-by: blam --- packages/e2e-test/src/commands/run.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index 89a46704c2..930cd93f55 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -357,6 +357,7 @@ async function testAppServe(pluginName: string, appDir: string) { for (let attempts = 1; ; attempts++) { try { const browser = new Browser(); + browser.debug(); await waitForPageWithText(browser, '/', 'My Company Catalog'); await waitForPageWithText( From 6f923c9e1d5ea2c0ceec745e6c61be5f3e3e51e1 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 12:00:26 +0200 Subject: [PATCH 2/9] chore: increase the attempts Signed-off-by: blam --- packages/e2e-test/src/commands/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index 930cd93f55..3db860e647 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -370,7 +370,7 @@ async function testAppServe(pluginName: string, appDir: string) { successful = true; break; } catch (error) { - if (attempts >= 5) { + if (attempts >= 20) { throw new Error(`App serve test failed, ${error}`); } console.log(`App serve failed, trying again, ${error}`); From 82a79983753224790fe2d376816123e972ab151d Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 12:15:33 +0200 Subject: [PATCH 3/9] chore: run the e2e-tests when the correct path changes Signed-off-by: blam --- .github/workflows/e2e-win.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index f39a89e8c6..62428d29e2 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -7,7 +7,7 @@ on: paths: - '.github/workflows/e2e-win.yml' - 'packages/cli/**' - - 'packages/e2e/**' + - 'packages/e2e-test/**' - 'packages/create-app/**' jobs: From b92b436efcc922c474492fd14b7381f072fad830 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 12:33:19 +0200 Subject: [PATCH 4/9] chore: use the debug module Signed-off-by: blam --- .github/workflows/e2e-win.yml | 2 +- packages/e2e-test/src/commands/run.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index 62428d29e2..0e004ca1a6 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -47,4 +47,4 @@ jobs: - name: yarn build run: yarn build --ignore example-app --ignore example-backend --ignore @techdocs/cli - name: run E2E test - run: yarn e2e-test run + run: DEBUG=zombie yarn e2e-test run diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index 3db860e647..b0db715f25 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -357,7 +357,6 @@ async function testAppServe(pluginName: string, appDir: string) { for (let attempts = 1; ; attempts++) { try { const browser = new Browser(); - browser.debug(); await waitForPageWithText(browser, '/', 'My Company Catalog'); await waitForPageWithText( From 0235260c9f0809111c7d9a282189455bbd4bd955 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 12:56:51 +0200 Subject: [PATCH 5/9] chore: added env Signed-off-by: blam --- .github/workflows/e2e-win.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-win.yml b/.github/workflows/e2e-win.yml index 0e004ca1a6..73ec0c782d 100644 --- a/.github/workflows/e2e-win.yml +++ b/.github/workflows/e2e-win.yml @@ -47,4 +47,6 @@ jobs: - name: yarn build run: yarn build --ignore example-app --ignore example-backend --ignore @techdocs/cli - name: run E2E test - run: DEBUG=zombie yarn e2e-test run + run: yarn e2e-test run + env: + DEBUG: zombie From f733a19f8519d962ebecaf8bbb3043d0711abfc2 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 13:38:30 +0200 Subject: [PATCH 6/9] chore: exponential backoff for all errors not just timeouts Signed-off-by: blam --- packages/e2e-test/src/lib/helpers.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/e2e-test/src/lib/helpers.ts b/packages/e2e-test/src/lib/helpers.ts index f326311f07..9a9c2010c9 100644 --- a/packages/e2e-test/src/lib/helpers.ts +++ b/packages/e2e-test/src/lib/helpers.ts @@ -131,12 +131,12 @@ export async function waitForPageWithText( browser: any, path: string, text: string, - { intervalMs = 1000, maxLoadAttempts = 50 } = {}, + { intervalMs = 1000, maxFindAttempts = 50 } = {}, ) { - let loadAttempts = 0; + let findAttempts = 0; for (;;) { try { - const waitTimeMs = intervalMs * (Math.log10(loadAttempts + 1) + 1); + const waitTimeMs = intervalMs * (Math.log10(findAttempts + 1) + 1); console.log(`Attempting to load page at ${path}, waiting ${waitTimeMs}`); await new Promise(resolve => setTimeout(resolve, waitTimeMs)); await browser.visit(path); @@ -150,15 +150,12 @@ export async function waitForPageWithText( break; } catch (error) { assertError(error); - if (error.message.match(EXPECTED_LOAD_ERRORS)) { - loadAttempts++; - if (loadAttempts >= maxLoadAttempts) { - throw new Error( - `Failed to load page '${path}', max number of attempts reached`, - ); - } - } else { - throw error; + + findAttempts++; + if (findAttempts >= maxFindAttempts) { + throw new Error( + `Failed to load page '${path}', max number of attempts reached`, + ); } } } From 1af1f76cb8cda4936d341f3c88909d23947e4cad Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 13:40:45 +0200 Subject: [PATCH 7/9] chore: add another exponential delay to wait for the page to load too Signed-off-by: blam --- packages/e2e-test/src/lib/helpers.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/e2e-test/src/lib/helpers.ts b/packages/e2e-test/src/lib/helpers.ts index 9a9c2010c9..1b42af2110 100644 --- a/packages/e2e-test/src/lib/helpers.ts +++ b/packages/e2e-test/src/lib/helpers.ts @@ -139,8 +139,11 @@ export async function waitForPageWithText( const waitTimeMs = intervalMs * (Math.log10(findAttempts + 1) + 1); console.log(`Attempting to load page at ${path}, waiting ${waitTimeMs}`); await new Promise(resolve => setTimeout(resolve, waitTimeMs)); + await browser.visit(path); + await new Promise(resolve => setTimeout(resolve, waitTimeMs)); + const escapedText = text.replace(/"|\\/g, '\\$&'); browser.assert.evaluate( `Array.from(document.querySelectorAll("*")).some(el => el.textContent === "${escapedText}")`, From 38ad8746c0ac4247c64c3cdbf438ad0853384635 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 13:45:04 +0200 Subject: [PATCH 8/9] chore: fixing typescript EXPECTED_LOAD_ERRORS Signed-off-by: blam --- packages/e2e-test/src/lib/helpers.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/e2e-test/src/lib/helpers.ts b/packages/e2e-test/src/lib/helpers.ts index 1b42af2110..d7b3ee4232 100644 --- a/packages/e2e-test/src/lib/helpers.ts +++ b/packages/e2e-test/src/lib/helpers.ts @@ -25,9 +25,6 @@ import { promisify } from 'util'; const execFile = promisify(execFileCb); -const EXPECTED_LOAD_ERRORS = - /ECONNREFUSED|ECONNRESET|did not get to load all resources/; - export function spawnPiped(cmd: string[], options?: SpawnOptions) { function pipeWithPrefix(stream: NodeJS.WriteStream, prefix = '') { return (data: Buffer) => { From 65bf24bc1db2873a72bfcfa97b0b33a6a4572958 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Oct 2021 14:27:33 +0200 Subject: [PATCH 9/9] chore: removing the log10 and just do linear backoff Signed-off-by: blam --- packages/e2e-test/src/lib/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-test/src/lib/helpers.ts b/packages/e2e-test/src/lib/helpers.ts index d7b3ee4232..5193db08ec 100644 --- a/packages/e2e-test/src/lib/helpers.ts +++ b/packages/e2e-test/src/lib/helpers.ts @@ -133,7 +133,7 @@ export async function waitForPageWithText( let findAttempts = 0; for (;;) { try { - const waitTimeMs = intervalMs * (Math.log10(findAttempts + 1) + 1); + const waitTimeMs = intervalMs * (findAttempts + 1); console.log(`Attempting to load page at ${path}, waiting ${waitTimeMs}`); await new Promise(resolve => setTimeout(resolve, waitTimeMs));