Skip to content

Commit

Permalink
TECH-1844: Updated the wait logic in waitUntilSAMStatusGreen (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgerthoffert committed Jun 17, 2024
1 parent 9847d87 commit ac87b8b
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.
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 ac87b8b

Please sign in to comment.