Skip to content

Commit

Permalink
chore: added system status check to anvil-cmg tests (#4108) (#4115)
Browse files Browse the repository at this point in the history
* chore: added system status check to anvil-cmg tests (#4108)

* chore: added second system status check after tests run to ensure reliability (#4108)

* chore: check that indexing checks fail appropriately (#4108)

* chore: undo test failure check (#4108)
  • Loading branch information
jpaten authored Aug 18, 2024
1 parent ac50c2d commit e37768b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/run-playwright-tests-anvil-cmg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions explorer/e2e/anvil/anvil-check-system-status.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
await checkIsIndexing(ANVIL_CMG_SYSTEM_STATUS_URL);
}

anvilCheckIsIndexing();
32 changes: 32 additions & 0 deletions explorer/e2e/checkIsIndexing.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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);
}
}
3 changes: 2 additions & 1 deletion explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e37768b

Please sign in to comment.