diff --git a/.github/workflows/run-playwright-tests-anvil-cmg.yml b/.github/workflows/run-playwright-tests-anvil-cmg.yml index f17f1ffda..20bc651b1 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 - TEST RESULTS ARE NOT VALID IF THIS FAILS + run: | + cd explorer + npm run check-system-status:anvil-cmg - name: Install Playwright Browsers run: | cd explorer @@ -25,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: 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..bde3288e6 --- /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( + "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 = 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",