Skip to content

Commit ac87b8b

Browse files
authored
TECH-1844: Updated the wait logic in waitUntilSAMStatusGreen (#75)
1 parent 9847d87 commit ac87b8b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jahia/cypress",
3-
"version": "3.20.0",
3+
"version": "3.20.1",
44
"scripts": {
55
"build": "tsc",
66
"lint": "eslint src -c .eslintrc.json --ext .ts"

src/utils/SAMHelper.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 1000) : void => {
1+
/*
2+
When Jahia is starting or performing provisioning operations
3+
it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
4+
5+
The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
6+
provisioning operation.
7+
8+
Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
9+
GREEN status was returned a number of consecutive times (greenMatchCount).
10+
*/
11+
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
12+
let greenCount = 0;
213
cy.waitUntil(() =>
314
cy.apollo({
415
fetchPolicy: 'no-cache',
@@ -9,7 +20,8 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
920
}).then(result => {
1021
const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
1122
if (healthStatus) {
12-
return healthStatus.health === 'GREEN';
23+
greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
24+
return greenCount >= greenMatchCount;
1325
}
1426
}),
1527
{

0 commit comments

Comments
 (0)