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-1954: Use JahiaCypress for waiting SAM to become green before test #85

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 7 additions & 22 deletions tests/cypress/e2e/api/findDependencies.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import {findDependencies, healthCheck} from '../../support/gql';
import {findDependencies} from '../../support/gql';

describe('Dependencies tool test', () => {

Check failure on line 3 in tests/cypress/e2e/api/findDependencies.spec.ts

View workflow job for this annotation

GitHub Actions / Static Analysis (linting, vulns)

Block must not be padded by blank lines
const waitUntilOptions = {
interval: 500,
timeout: 10000,
errorMsg: 'Failed to verify configuration update'
};

const waitUntilHealth = (health: string, probeName: string) => {
cy.waitUntil(() =>
healthCheck({includes: probeName, severity: 'LOW'}).then(result => {
return result.probes.find(probe => probe.name === probeName).status.health === health;
}), waitUntilOptions);
};

it('Check that module state probe is green by default', () => {
healthCheck({includes: 'ModuleState', severity: 'LOW'}).should(r => {
expect(r.status.health).to.eq('GREEN');
const moduleSpringUsageProbe = r.probes.find(probe => probe.name === 'ModuleState');
expect(moduleSpringUsageProbe.status.health).to.eq('GREEN');
});

it('Wait until SAM returns GREEN for medium severity', () => {
// The timeout of 3mn (180) is there to allow for the cluster to finish its synchronization
waitUntilSAMStatusGreen('MEDIUM', 180000);
});

describe('Test deployment of provider module and dependent modules to call the findDependencies tool', () => {
Expand Down Expand Up @@ -53,7 +38,7 @@
cy.runProvisioningScript([{startBundle: 'module-dependant-case33/1.0.0'}]);
cy.installBundle('findDependenciesTool/module-dependant-case34-1.0.0.jar');
cy.runProvisioningScript([{startBundle: 'module-dependant-case34/1.0.0'}]);
waitUntilHealth('GREEN', 'ModuleState');
waitUntilSAMStatusGreen('MEDIUM', 180000);
});

after(() => {
Expand All @@ -72,7 +57,7 @@
cy.runProvisioningScript([{uninstallBundle: 'module-dependant-case33/1.0.0'}]);
cy.runProvisioningScript([{uninstallBundle: 'module-dependant-case34/1.0.0'}]);
cy.runProvisioningScript([{uninstallBundle: 'module-provider/1.1.0'}]);
waitUntilHealth('GREEN', 'ModuleState');
waitUntilSAMStatusGreen('MEDIUM', 180000);
});

it('Test finding module that prevent minor upgrades', () => {
Expand Down
22 changes: 0 additions & 22 deletions tests/cypress/fixtures/healthcheck.graphql

This file was deleted.

24 changes: 0 additions & 24 deletions tests/cypress/support/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,12 @@ interface AuthMethod {
password?: string
}

type HealthCheckArguments = {
severity: string,
includes?: string | Array<string>
health?: 'GREEN' | 'YELLOW' | 'RED'
auth?: AuthMethod
}

type FindDependenciesArguments = {
regexp: string,
strictVersionsOnly?: boolean,
auth?: AuthMethod
}

export const healthCheck = ({severity, includes, auth, health}: HealthCheckArguments): Chainable<any> => {
if (auth) {
cy.apolloClient(auth);
}

return cy
.apollo({
queryFile: 'healthcheck.graphql',
variables: {severity, includes, health},
errorPolicy: 'all'
})
.then((response: any) => {
console.log(response);
return response.data.admin.jahia.healthCheck;
});
};

export const findDependencies = ({regexp, strictVersionsOnly, auth}: FindDependenciesArguments): Chainable<any> => {
if (auth) {
cy.apolloClient(auth);
Expand Down
Loading