Skip to content

Commit b65a8f0

Browse files
authored
Disables jitter for managed_indices_spec Cypress tests (#122)
Signed-off-by: Robert Downs <[email protected]>
1 parent 186f613 commit b65a8f0

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

cypress/integration/managed_indices_spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ describe("Managed indices", () => {
3636
beforeEach(() => {
3737
// Set welcome screen tracking to false
3838
localStorage.setItem("home:welcome:show", "false");
39+
// Disable jitter so ISM jobs run without an additional delay
40+
cy.disableJitter();
3941

4042
cy.wait(3000);
4143

cypress/support/commands.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,17 @@ Cypress.Commands.add("rollover", (target) => {
161161
Cypress.Commands.add("createTransform", (transformId, transformJSON) => {
162162
cy.request("PUT", `${Cypress.env("opensearch")}${API.TRANSFORM_JOBS_BASE}/${transformId}`, transformJSON);
163163
});
164+
165+
Cypress.Commands.add("disableJitter", () => {
166+
// Sets the jitter to 0 in the ISM plugin cluster settings
167+
const jitterJson = {
168+
persistent: {
169+
plugins: {
170+
index_state_management: {
171+
jitter: "0.0",
172+
},
173+
},
174+
},
175+
};
176+
cy.request("PUT", `${Cypress.env("opensearch")}/_cluster/settings`, jitterJson);
177+
});

cypress/support/index.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ declare namespace Cypress {
5151

5252
/**
5353
* Updated the managed index config's start time to
54-
* make it run in 3 seconds after calling this
54+
* make it run in 3 seconds after calling this.
55+
* Note: if you are calling this then you likely are forcing
56+
* an ISM job to run. Make sure disableJitter is called sometime
57+
* before this or else the delay may cause test flakiness.
5558
* @example
5659
* cy.updateManagedIndexConfigStartTime("some_index")
5760
*/
@@ -105,5 +108,15 @@ declare namespace Cypress {
105108
* cy.createTransform("some_transform", { "transform": { ... } })
106109
*/
107110
createTransform(transformId: string, transformJSON: object): Chainable<any>;
111+
112+
/**
113+
* Disables jitter on a cluster. The jitter is used in
114+
* index state management to add a randomized delay to the start
115+
* time of jobs. This helps spread the resource load when there are
116+
* many jobs scheduled for the same time, but can cause flakiness in tests.
117+
* @example
118+
* cy.disableJitter()
119+
*/
120+
disableJitter(): Chainable<any>;
108121
}
109122
}

0 commit comments

Comments
 (0)