Skip to content

Commit e78b047

Browse files
committed
chore: added system status check to anvil-cmg tests (#4108)
1 parent ac50c2d commit e78b047

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

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

+4
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
21+
run: |
22+
cd explorer
23+
npm run check-system-status:anvil-cmg
2024
- name: Install Playwright Browsers
2125
run: |
2226
cd explorer

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+
"WARNING: The System Status API is currently unavailable, or an incorrect url was passed. Tests may fail for unexpected reasons."
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)