Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH-1844: Updated the wait logic in waitUntilSAMStatusGreen #75

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading