Skip to content

Commit

Permalink
Merge/index operation (#534)
Browse files Browse the repository at this point in the history
* Feature/common 2.5 (#519)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* Feature/index management 2.5 (#520)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* fix: detail of data stream

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* Temp/template management 2.5 (#523)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: fix template error

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* Temp/alias management 2.5 (#524)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* Feature/unittest fix 2.5 (#525)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* Merge/index operation reindex (#526)

* Feature/common 2.5 (#506)

* feat: split to common change

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>

* enable fullwidth for JSON editor (#479)

* enable fullwidth for JSON editor

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* update width of import settings & mappings

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* wording change

Signed-off-by: Hailong Cui <ihailong@amazon.com>

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* advanced settings

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* fix integration test

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* wording change

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* filter system index and alias from destination

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* fix code merge issue

Signed-off-by: Hailong Cui <ihailong@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Co-authored-by: suzhou <suzhou@amazon.com>

* Add split index operation

Signed-off-by: Xuesong Luo <lxuesong@amazon.com>

* Add split index operation

Signed-off-by: Xuesong Luo <lxuesong@amazon.com>

Signed-off-by: suzhou <suzhou@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: Xuesong Luo <lxuesong@amazon.com>
Co-authored-by: suzhou <suzhou@amazon.com>
Co-authored-by: Hailong-amzn <ihailong@amazon.com>
  • Loading branch information
3 people committed Jan 6, 2023
1 parent 84d4d62 commit 9613b85
Show file tree
Hide file tree
Showing 13 changed files with 1,337 additions and 59 deletions.
184 changes: 184 additions & 0 deletions cypress/integration/split_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";

const sampleIndex = "index-split";
const sampleAlias = "alias-split";

describe("Split Index", () => {
before(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
cy.deleteAllIndices();
});

describe("can be created and updated", () => {
beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/indices`);
cy.contains("Rows per page", { timeout: 60000 });
});

let splitNumber = 2;
let replicaNumber = 1;
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).end();

cy.get('[data-test-subj="comboBoxSearchInput"]').focus().type(`${sampleAlias}`).end();

// click create
cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true }).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 index

it("Split successfully", () => {
const targetIndex = `${sampleIndex}` + "-target";
cy.get(`[data-test-subj="checkboxSelectRow-${sampleIndex}"]`)
.click()
.end()
.get('[data-test-subj="moreAction"]')
.click()
.end()
.get('[data-test-subj="Split Action"]')
.click()
.end()
// Target Index Name is required
.get('[data-test-subj="targetIndexNameInput"]')
.type(`${targetIndex}`)
.end()
// Number of shards after split is required
.get('[data-test-subj="numberOfShardsInput"]')
.type(`${splitNumber}{downArrow}{enter}`)
.end()
.get('[data-test-subj="numberOfReplicasInput"]')
.clear()
.type(`${replicaNumber}`)
.end()
.get('[data-test-subj="splitButton"]')
.click()
.end();

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"] .euiText').should("have.text", `${replicaNumber}`).end();
}); // Split

it("Split successfully with advanced setting", () => {
const targetIndex = `${sampleIndex}` + "-setting";
cy.get(`[data-test-subj="checkboxSelectRow-${sampleIndex}"]`)
.click()
.end()
.get('[data-test-subj="moreAction"]')
.click()
.end()
.get('[data-test-subj="Split Action"]')
.click()
.end()
.get("[data-test-subj=targetIndexNameInput]")
.type(`${targetIndex}`)
.end()
// Instead of input shard number at shard field, another option is to populate it in advanced setting
.get('[aria-controls="accordionForCreateIndexSettings"]')
.click()
.end()
.get('[data-test-subj="codeEditorContainer"] textarea')
.focus()
// Need to remove the default {} in advanced setting
.clear()
.type(`{"index.number_of_shards": "${splitNumber}", "index.number_of_replicas": "${replicaNumber}"}`, {
parseSpecialCharSequences: false,
})
.end()
.get('[data-test-subj="splitButton"]')
.click()
.end();

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"] .euiText').should("have.text", `${replicaNumber}`).end();
}); // advanced setting

it("Split successfully with alias", () => {
const targetIndex = `${sampleIndex}` + "-alias";
const newAlias = "alias-new";
cy.get(`[data-test-subj="checkboxSelectRow-${sampleIndex}"]`)
.click()
.end()
.get('[data-test-subj="moreAction"]')
.click()
.end()
.get('[data-test-subj="Split Action"]')
.click()
.end()
.get("[data-test-subj=targetIndexNameInput]")
.type(`${targetIndex}`)
.end()
.get('[data-test-subj="numberOfShardsInput"]')
.type(`${splitNumber}{downArrow}{enter}`)
.end()
// Assign to an existing alias and a new alias
.get('[data-test-subj="form-name-aliases"] [data-test-subj="comboBoxSearchInput"]')
.type(`${sampleAlias}{enter}${newAlias}{enter}`)
.end()
.get('[data-test-subj="splitButton"]')
.click()
.end();

cy.get(`[data-test-subj="viewIndexDetailButton-${targetIndex}"]`).click().end();
// Verify alias associated with the new index
cy.get("#indexDetailModalAlias").click().end();
cy.get(`[title="${newAlias}"]`).should("exist").end();
cy.get(`[title="${sampleAlias}"]`).should("exist").end();
}); // Create with alias

it("Update blocks write to true", () => {
// Set index to not blocks write
cy.updateIndexSettings(sampleIndex, { "index.blocks.write": "false" }).end();
cy.get(`[data-test-subj="checkboxSelectRow-${sampleIndex}"]`)
.click()
.end()
.get('[data-test-subj="moreAction"]')
.click()
.end()
.get('[data-test-subj="Split Action"]')
.click()
.end()
// Index can't be split if it's blocks write status is not true
.get('[data-test-subj="splitButton"]')
.should("have.class", "euiButton-isDisabled")
.end()
.wait(1000)
// Set index to blocks write
.get('[data-test-subj="set-indexsetting-button"]')
.click()
.end()
.get('[data-test-subj="splitButton"]')
.click()
.end();
}); // Blocks write
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HTMLCollection [
data-aria-hidden="true"
/>,
<div
class="euiOverlayMask euiOverlayMask--belowHeader"
class="euiOverlayMask euiOverlayMask--aboveHeader"
>
<div
aria-hidden="true"
Expand All @@ -20,25 +20,30 @@ HTMLCollection [
data-focus-lock-disabled="false"
>
<div
class="euiFlyout euiFlyout--medium euiFlyout--paddingLarge"
role="dialog"
tabindex="-1"
class="euiModal euiModal--maxWidth-default"
tabindex="0"
>
<div
class="euiFlyoutHeader"
<button
aria-label="Closes this modal window"
class="euiButtonIcon euiButtonIcon--text euiButtonIcon--empty euiButtonIcon--xSmall euiModal__closeIcon"
type="button"
>
Create
alias
</div>
EuiIconMock
</button>
<div
class="euiFlyoutBody"
class="euiModal__flex"
>
<div
class="euiFlyoutBody__overflow"
tabindex="0"
class="euiModalHeader"
>
Create
alias
</div>
<div
class="euiModalBody"
>
<div
class="euiFlyoutBody__overflowContent"
class="euiModalBody__overflow"
>
<div
class="euiForm"
Expand Down Expand Up @@ -166,46 +171,47 @@ HTMLCollection [
</div>
</div>
</div>
<div
class="euiSpacer euiSpacer--l"
/>
</div>
</div>
</div>
<div
class="euiFlyoutFooter"
>
<div
style="display: flex; justify-content: flex-end;"
class="euiModalFooter"
>
<button
class="euiButton euiButton--primary"
data-test-subj="cancelCreateAliasButton"
style="margin-right: 20px;"
type="button"
>
<span
class="euiButtonContent euiButton__content"
<div>
<button
class="euiButton euiButton--primary"
data-test-subj="cancelCreateAliasButton"
style="margin-right: 20px;"
type="button"
>
<span
class="euiButton__text"
class="euiButtonContent euiButton__content"
>
Cancel
<span
class="euiButton__text"
>
Cancel
</span>
</span>
</span>
</button>
<button
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createAliasButton"
type="button"
>
<span
class="euiButtonContent euiButton__content"
</button>
<button
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createAliasButton"
type="button"
>
<span
class="euiButton__text"
class="euiButtonContent euiButton__content"
>
Create alias
<span
class="euiButton__text"
>
Create alias
</span>
</span>
</span>
</button>
</button>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
INDEX_NAMING_MESSAGE,
REPLICA_NUMBER_MESSAGE,
INDEX_SETTINGS_URL,
INDEX_NAMING_PATTERN,
} from "../../../../utils/constants";
import { Modal } from "../../../../components/Modal";
import FormGenerator, { IField, IFormGeneratorRef } from "../../../../components/FormGenerator";
Expand Down Expand Up @@ -336,7 +337,7 @@ const IndexDetail = (
},
rules: [
{
pattern: /^[^\s:,A-Z-_"*+/\\|?#<>][^\s:,A-Z"*+/\\|?#<>]*$/,
pattern: INDEX_NAMING_PATTERN,
message: "Invalid index name.",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,6 @@ exports[`container <IndexDetail /> spec render the component 2`] = `
>
Health
</dt>
<dd
class="euiDescriptionList__description"
>
<span>
green
</span>
</dd>
</div>
<div
data-test-subj="index-detail-overview-item-Status"
style="display: inline-block; width: 33%; vertical-align: top; margin-bottom: 20px; padding: 0px 1%;"
>
<dt
class="euiDescriptionList__title"
>
Status
</dt>
<dd
class="euiDescriptionList__description"
>
Expand All @@ -196,6 +179,25 @@ exports[`container <IndexDetail /> spec render the component 2`] = `
</div>
</dd>
</div>
<div
data-test-subj="index-detail-overview-item-Status"
style="display: inline-block; width: 33%; vertical-align: top; margin-bottom: 20px; padding: 0px 1%;"
>
<dt
class="euiDescriptionList__title"
>
Status
</dt>
<dd
class="euiDescriptionList__description"
>
<span
class="camel-first-letter"
>
open
</span>
</dd>
</div>
<div
data-test-subj="index-detail-overview-item-Creation date"
style="display: inline-block; width: 33%; vertical-align: top; margin-bottom: 20px; padding: 0px 1%;"
Expand Down
Loading

0 comments on commit 9613b85

Please sign in to comment.