-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheckIsIndexing.ts
32 lines (32 loc) · 1.4 KB
/
checkIsIndexing.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
}
}