-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy patha_split_index.js
More file actions
93 lines (74 loc) 路 3.4 KB
/
Copy patha_split_index.js
File metadata and controls
93 lines (74 loc) 路 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { IM_PLUGIN_NAME, BASE_PATH } from "../../../utils/constants";
const sampleIndex = "index-split";
const sampleAlias = "alias-split";
let splitNumber = 2;
let replicaNumber = 1;
describe("Split Index", () => {
before(() => {
cy.window().then((win) => {
win.localStorage.clear();
win.sessionStorage.clear();
win.localStorage.setItem("home:welcome:show", "false");
});
});
describe("can be created and updated", () => {
beforeEach(() => {
// Clear session data between tests
Cypress.session.clearCurrentSessionData();
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/indices`, {
timeout: 30000,
onBeforeLoad: (win) => {
win.sessionStorage.clear();
win.localStorage.clear();
},
});
// Wait for page load with proper assertion
cy.contains("Rows per page", { timeout: 20000 }).should("be.visible");
});
it("Create an index successfully", () => {
// enter create page
cy.get('[data-test-subj="Create IndexButton"]').click();
cy.contains("Create index");
// type field name
cy.get('[placeholder="Specify a name for the new index."]').type(sampleIndex).blur();
cy.wait(1000);
cy.get('[data-test-subj="comboBoxSearchInput"]').focus().type(`${sampleAlias}{enter}`).end();
// click create
cy.get('[data-test-subj="createIndexCreateButton"]').click().end();
// The index should exist
cy.get(`#_selection_column_${sampleIndex}-checkbox`).should("have.exist").end();
cy.get(`[data-test-subj="viewIndexDetailButton-${sampleIndex}"]`).click().end();
cy.get("#indexDetailModalSettings").click().end();
cy.get('[data-test-subj="form-name-index.number_of_shards"] .euiText').then(($shardNumber) => {
splitNumber = $shardNumber.attr("title") * 2;
});
cy.get("#indexDetailModalAlias").click().end();
cy.get(`[title="${sampleAlias}"]`).should("exist").end();
// Update Index status to blocks write otherwise we can't apply split operation on it
cy.updateIndexSettings(sampleIndex, {
"index.blocks.write": "true",
}).end();
}); //create the index
it("Split successfully", () => {
const targetIndex = `${sampleIndex}` + "-target";
cy.get(`[data-test-subj="checkboxSelectRow-${sampleIndex}"]`).click().end();
cy.wait(3000);
cy.get('[data-test-subj="moreAction"]').click().end().get('[data-test-subj="Split Action"]').click().end();
// Target Index Name is required
cy.get('[data-test-subj="targetIndexNameInput"]').type(`${targetIndex}`).end();
// Number of shards after split is required
cy.get('[data-test-subj="numberOfShardsInput"]').type(`${splitNumber}{downArrow}{enter}`).end();
cy.get('[data-test-subj="numberOfReplicasInput"]').clear().type(`${replicaNumber}`).end();
cy.get('[data-test-subj="splitButton"]').click().end();
cy.wait(3000);
cy.get(`[data-test-subj="viewIndexDetailButton-${targetIndex}"]`).click().end();
cy.get("#indexDetailModalSettings").click().end();
cy.get('[data-test-subj="form-name-index.number_of_shards"] .euiText').should("have.text", `${splitNumber}`).end();
cy.get('[data-test-subj="form-name-index.number_of_replicas"] input').should("have.value", `${replicaNumber}`).end();
}); // Split
});
});