Skip to content

Commit

Permalink
Updated the waitUntilSAMStatusGreen method to wait until green has be…
Browse files Browse the repository at this point in the history
…en returned a number of times
  • Loading branch information
Fgerthoffert committed Jun 14, 2024
1 parent 9847d87 commit e42b06c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jahia/cypress",
"version": "3.20.0",
"version": "3.20.1",
"scripts": {
"build": "tsc",
"lint": "eslint src -c .eslintrc.json --ext .ts"
Expand Down
16 changes: 14 additions & 2 deletions src/utils/SAMHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 1000) : void => {
/*
When Jahia is starting or performing provisioning operations
it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.

Check failure on line 4 in src/utils/SAMHelper.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Trailing spaces not allowed
The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
provisioning operation.
Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
GREEN status was returned a number of consecutive times (greenMatchCount).
*/
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
let greenCount = 0;
cy.waitUntil(() =>
cy.apollo({
fetchPolicy: 'no-cache',
Expand All @@ -9,7 +20,8 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
}).then(result => {
const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
if (healthStatus) {
return healthStatus.health === 'GREEN';
greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
return greenCount >= greenMatchCount;
}
}),
{
Expand Down

0 comments on commit e42b06c

Please sign in to comment.