Skip to content

Commit

Permalink
Merge pull request #1993 from openkfw/1992-e2e-provision
Browse files Browse the repository at this point in the history
provisioning: In case of failure, retry before quitting
  • Loading branch information
MartinJurcoGlina authored Sep 26, 2024
2 parents 559ecde + 871ff9c commit a387032
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions api/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
"caseInsensitive": true
}
}
],
"no-restricted-imports": [
"warn",
{
"patterns": ["^[a-zA-Z]"]
}
]
}
}
3 changes: 2 additions & 1 deletion e2e-test/cypress/integration/project_edit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ describe("Project Edit", function () {
.then((additionalData) => {
previousAddtionalData = additionalData;
});
cy.get(".jse-value").click().type("-changed{enter}");
cy.get(".jse-value").click();
cy.get(".jse-value").type("-changed{enter}");
});

cy.get(`[data-test=project-additional-data]`).click();
Expand Down
5 changes: 3 additions & 2 deletions e2e-test/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ beforeEach(() => {
});

Cypress.Commands.add("login", (username = "mstein", password = "test", opts = { language: "en-gb" }) => {
const loginRequest = (retries = 3) => {
const loginRequest = (retries = 5) => {
return cy
.request({
url: `${baseUrl}/api/user.authenticate`,
Expand All @@ -46,7 +46,8 @@ Cypress.Commands.add("login", (username = "mstein", password = "test", opts = {
})
.then((response) => {
if (response.status === 502 && retries > 0) {
cy.wait(1000);
console.log("api/user.authenticate responded with 502. Retrying login request.");
cy.wait(3000);
return loginRequest(retries - 1);
} else if (response.status >= 400) {
throw new Error(`Request failed with status ${response.status}`);
Expand Down
10 changes: 7 additions & 3 deletions provisioning/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,12 @@ if (isBeta) {
process.exit(0);
});
} else {
provisionBlockchain(protocol, host, port, rootSecret, organization).then(() => {
log.info("\x1b[32m%s\x1b[0m", "Successfully provisioned Trubudget!");
(async () => {
for (let i = 0; i < 5; i++) {
await provisionBlockchain(protocol, host, port, rootSecret, organization);
log.info("\x1b[32m%s\x1b[0m", `Successfully provisioned Trubudget! Iteration: ${i + 1}`);
await new Promise(resolve => setTimeout(resolve, 20000)); // Wait for 20 seconds
}
process.exit(0);
});
})();
}

0 comments on commit a387032

Please sign in to comment.