Skip to content

Commit 2aca06a

Browse files
committed
chore: added system status check to anvil-cmg tests (#4108) (#4115)
* 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)
1 parent 6d4b8b4 commit 2aca06a

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

Diff for: .github/workflows/run-playwright-tests-anvil-cmg.yml

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
run: |
1818
cd explorer
1919
npm ci
20+
- name: Check Backend System Status - TEST RESULTS ARE NOT VALID IF THIS FAILS
21+
run: |
22+
cd explorer
23+
npm run check-system-status:anvil-cmg
2024
- name: Install Playwright Browsers
2125
run: |
2226
cd explorer
@@ -25,6 +29,10 @@ jobs:
2529
run: |
2630
cd explorer
2731
npm run test:anvil-cmg
32+
- name: Check backend status again - TEST RESULTS ARE NOT VALID IF THIS FAILS
33+
run: |
34+
cd explorer
35+
npm run check-system-status:anvil-cmg
2836
- uses: actions/upload-artifact@v3
2937
if: always()
3038
with:

Diff for: explorer/e2e/anvil/anvil-check-system-status.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { checkIsIndexing } from "../checkIsIndexing";
2+
const ANVIL_CMG_SYSTEM_STATUS_URL =
3+
"https://service.anvil.gi.ucsc.edu/health/progress";
4+
5+
/**
6+
* Check system status for Anvil-CMG
7+
*/
8+
async function anvilCheckIsIndexing(): Promise<void> {
9+
await checkIsIndexing(ANVIL_CMG_SYSTEM_STATUS_URL);
10+
}
11+
12+
anvilCheckIsIndexing();

Diff for: explorer/e2e/checkIsIndexing.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Check the system status, including whether the backend is currently indexing
3+
* @param systemStatusUrl - a url to the system status api
4+
*/
5+
export async function checkIsIndexing(systemStatusUrl: string): Promise<void> {
6+
const systemStatusResponse = await fetch(systemStatusUrl);
7+
if (systemStatusResponse.status != 200) {
8+
console.log(
9+
"ERROR: The System Status API is currently unavailable, or an incorrect url was passed. Please rerun tests when this is resolved."
10+
);
11+
process.exit(1);
12+
}
13+
const systemStatusJson = await systemStatusResponse.json();
14+
const isUp = systemStatusJson.up && systemStatusJson.progress.up;
15+
const isIndexing =
16+
systemStatusJson.progress.unindexed_bundles > 0 ||
17+
systemStatusJson.progress.unindexed_documents > 0;
18+
if (!isUp) {
19+
console.log(
20+
"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."
21+
);
22+
process.exit(1);
23+
} else if (isIndexing) {
24+
console.log(
25+
"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."
26+
);
27+
process.exit(1);
28+
} else {
29+
console.log("The System Status is currently good!");
30+
process.exit(0);
31+
}
32+
}

Diff for: explorer/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"test:e2e": "playwright test",
3434
"get-cellxgene-projects-hca": "esrun ./site-config/hca-dcp/dev/scripts/get-cellxgene-projects.ts ",
3535
"test:anvil-cmg": "playwright test -c playwright_anvil.config.ts --trace retain-on-failure",
36-
"test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts --trace retain-on-failure"
36+
"test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts --trace retain-on-failure",
37+
"check-system-status:anvil-cmg": "esrun e2e/anvil/anvil-check-system-status.ts"
3738
},
3839
"dependencies": {
3940
"@databiosphere/findable-ui": "9.1.0",

0 commit comments

Comments
 (0)