From e78b04764c677c6870bb423c7e9b8528c929e3ba Mon Sep 17 00:00:00 2001 From: Jonah Paten Date: Fri, 16 Aug 2024 15:17:35 -0700 Subject: [PATCH 1/4] chore: added system status check to anvil-cmg tests (#4108) --- .../run-playwright-tests-anvil-cmg.yml | 4 +++ .../e2e/anvil/anvil-check-system-status.ts | 12 +++++++ explorer/e2e/checkIsIndexing.ts | 32 +++++++++++++++++++ explorer/package.json | 3 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 explorer/e2e/anvil/anvil-check-system-status.ts create mode 100644 explorer/e2e/checkIsIndexing.ts diff --git a/.github/workflows/run-playwright-tests-anvil-cmg.yml b/.github/workflows/run-playwright-tests-anvil-cmg.yml index f17f1ffda..0512379ad 100644 --- a/.github/workflows/run-playwright-tests-anvil-cmg.yml +++ b/.github/workflows/run-playwright-tests-anvil-cmg.yml @@ -17,6 +17,10 @@ jobs: run: | cd explorer npm ci + - name: Check Backend System Status + run: | + cd explorer + npm run check-system-status:anvil-cmg - name: Install Playwright Browsers run: | cd explorer diff --git a/explorer/e2e/anvil/anvil-check-system-status.ts b/explorer/e2e/anvil/anvil-check-system-status.ts new file mode 100644 index 000000000..07b22e46c --- /dev/null +++ b/explorer/e2e/anvil/anvil-check-system-status.ts @@ -0,0 +1,12 @@ +import { checkIsIndexing } from "../checkIsIndexing"; +const ANVIL_CMG_SYSTEM_STATUS_URL = + "https://service.anvil.gi.ucsc.edu/health/progress"; + +/** + * Check system status for Anvil-CMG + */ +async function anvilCheckIsIndexing(): Promise { + await checkIsIndexing(ANVIL_CMG_SYSTEM_STATUS_URL); +} + +anvilCheckIsIndexing(); diff --git a/explorer/e2e/checkIsIndexing.ts b/explorer/e2e/checkIsIndexing.ts new file mode 100644 index 000000000..9c5072f3d --- /dev/null +++ b/explorer/e2e/checkIsIndexing.ts @@ -0,0 +1,32 @@ +/** + * Check the system status, including whether the backend is currently indexing + * @param systemStatusUrl - a url to the system status api + */ +export async function checkIsIndexing(systemStatusUrl: string): Promise { + const systemStatusResponse = await fetch(systemStatusUrl); + if (systemStatusResponse.status != 200) { + console.log( + "WARNING: The System Status API is currently unavailable, or an incorrect url was passed. Tests may fail for unexpected reasons." + ); + process.exit(1); + } + const systemStatusJson = await systemStatusResponse.json(); + const isUp = systemStatusJson.up && systemStatusJson.progress.up; + const isIndexing = + systemStatusJson.progress.unindexed_bundles > 0 || + systemStatusJson.progress.unindexed_documents > 0; + if (!isUp) { + console.log( + "There is an issue with the backend server. Please rerun tests once this issue has been resolved. If tests have already been run, please ignore the results and try again later." + ); + process.exit(1); + } else if (isIndexing) { + console.log( + "ERROR: The database is currently indexing, which means that tests cannot run reliably. Please rerun tests later once indexing has stopped. If tests have already been run, please ignore the results and try again after indexing has stopped." + ); + process.exit(1); + } else { + console.log("The System Status is currently good!"); + process.exit(0); + } +} diff --git a/explorer/package.json b/explorer/package.json index 16487cfb0..e4a1ea5d5 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -33,7 +33,8 @@ "test:e2e": "playwright test", "get-cellxgene-projects-hca": "esrun ./site-config/hca-dcp/dev/scripts/get-cellxgene-projects.ts ", "test:anvil-cmg": "playwright test -c playwright_anvil.config.ts --trace retain-on-failure", - "test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts --trace retain-on-failure" + "test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts --trace retain-on-failure", + "check-system-status:anvil-cmg": "esrun e2e/anvil/anvil-check-system-status.ts" }, "dependencies": { "@databiosphere/findable-ui": "9.1.0", From 2858171638a031fba86f503215ccde8244d9ad81 Mon Sep 17 00:00:00 2001 From: Jonah Paten Date: Fri, 16 Aug 2024 15:42:25 -0700 Subject: [PATCH 2/4] chore: added second system status check after tests run to ensure reliability (#4108) --- .github/workflows/run-playwright-tests-anvil-cmg.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-playwright-tests-anvil-cmg.yml b/.github/workflows/run-playwright-tests-anvil-cmg.yml index 0512379ad..20bc651b1 100644 --- a/.github/workflows/run-playwright-tests-anvil-cmg.yml +++ b/.github/workflows/run-playwright-tests-anvil-cmg.yml @@ -17,7 +17,7 @@ jobs: run: | cd explorer npm ci - - name: Check Backend System Status + - name: Check Backend System Status - TEST RESULTS ARE NOT VALID IF THIS FAILS run: | cd explorer npm run check-system-status:anvil-cmg @@ -29,6 +29,10 @@ jobs: run: | cd explorer npm run test:anvil-cmg + - name: Check backend status again - TEST RESULTS ARE NOT VALID IF THIS FAILS + run: | + cd explorer + npm run check-system-status:anvil-cmg - uses: actions/upload-artifact@v3 if: always() with: From 102c4b568bd710c4019c2f11644c52efd33ba8f7 Mon Sep 17 00:00:00 2001 From: Jonah Paten Date: Fri, 16 Aug 2024 15:57:38 -0700 Subject: [PATCH 3/4] chore: check that indexing checks fail appropriately (#4108) --- explorer/e2e/checkIsIndexing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/explorer/e2e/checkIsIndexing.ts b/explorer/e2e/checkIsIndexing.ts index 9c5072f3d..32b289413 100644 --- a/explorer/e2e/checkIsIndexing.ts +++ b/explorer/e2e/checkIsIndexing.ts @@ -11,7 +11,7 @@ export async function checkIsIndexing(systemStatusUrl: string): Promise { process.exit(1); } const systemStatusJson = await systemStatusResponse.json(); - const isUp = systemStatusJson.up && systemStatusJson.progress.up; + const isUp = false; // systemStatusJson.up && systemStatusJson.progress.up; const isIndexing = systemStatusJson.progress.unindexed_bundles > 0 || systemStatusJson.progress.unindexed_documents > 0; From fd47d5acbae23b891f52fca15ca6ae9d83a2b71f Mon Sep 17 00:00:00 2001 From: Jonah Paten Date: Fri, 16 Aug 2024 15:59:46 -0700 Subject: [PATCH 4/4] chore: undo test failure check (#4108) --- explorer/e2e/checkIsIndexing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/explorer/e2e/checkIsIndexing.ts b/explorer/e2e/checkIsIndexing.ts index 32b289413..bde3288e6 100644 --- a/explorer/e2e/checkIsIndexing.ts +++ b/explorer/e2e/checkIsIndexing.ts @@ -6,12 +6,12 @@ export async function checkIsIndexing(systemStatusUrl: string): Promise { const systemStatusResponse = await fetch(systemStatusUrl); if (systemStatusResponse.status != 200) { console.log( - "WARNING: The System Status API is currently unavailable, or an incorrect url was passed. Tests may fail for unexpected reasons." + "ERROR: The System Status API is currently unavailable, or an incorrect url was passed. Please rerun tests when this is resolved." ); process.exit(1); } const systemStatusJson = await systemStatusResponse.json(); - const isUp = false; // systemStatusJson.up && systemStatusJson.progress.up; + const isUp = systemStatusJson.up && systemStatusJson.progress.up; const isIndexing = systemStatusJson.progress.unindexed_bundles > 0 || systemStatusJson.progress.unindexed_documents > 0;