Skip to content

Commit

Permalink
Add shrink index page (#530)
Browse files Browse the repository at this point in the history
* Add shrink index page

Signed-off-by: Binlong Gao <[email protected]>

* Fix bug for shrink & close operation

Signed-off-by: Binlong Gao <[email protected]>

Signed-off-by: Binlong Gao <[email protected]>
  • Loading branch information
gaobinlong authored Jan 4, 2023
1 parent 9a2cba9 commit 9444cd2
Show file tree
Hide file tree
Showing 10 changed files with 2,069 additions and 2 deletions.
41 changes: 41 additions & 0 deletions cypress/integration/indices_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,47 @@ describe("Indices", () => {
});
});

describe("can shrink an index", () => {
before(() => {
cy.deleteAllIndices();
cy.createIndex(SAMPLE_INDEX, null, {
settings: { "index.blocks.write": true, "index.number_of_shards": 2, "index.number_of_replicas": 0 },
});
});

it("successfully shrink an index", () => {
// Type in SAMPLE_INDEX in search input
cy.get(`input[type="search"]`).focus().type(SAMPLE_INDEX);

cy.wait(1000).get(".euiTableRow").should("have.length", 1);
// Confirm we have our initial index
cy.contains(SAMPLE_INDEX);

cy.get('[data-test-subj="moreAction"]').click();
// Shrink btn should be disabled if no items selected
cy.get('[data-test-subj="Shrink Action"]').should("have.class", "euiContextMenuItem-isDisabled");

// Select an index
cy.get(`[data-test-subj="checkboxSelectRow-${SAMPLE_INDEX}"]`).check({ force: true });

cy.get('[data-test-subj="moreAction"]').click();
// Shrink btn should be enabled
cy.get('[data-test-subj="Shrink Action"]').should("exist").should("not.have.class", "euiContextMenuItem-isDisabled").click();

// Check for Shrink page
cy.contains("Shrink index");

// Enter target index name
cy.get(`input[data-test-subj="targetIndexNameInput"]`).type(`${SAMPLE_INDEX}_shrunken`);

// Click shrink index button
cy.get("button").contains("Shrink").click({ force: true });

// Check for success toast
cy.contains(`Successfully started shrinking ${SAMPLE_INDEX}. The shrunken index will be named ${SAMPLE_INDEX}_shrunken.`);
});
});

describe("can close and open an index", () => {
before(() => {
cy.deleteAllIndices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function CloseIndexModal(props: CloseIndexModalProps) {
<EuiModalBody>
<>
<EuiCallOut color="warning" hidden={!showWarning}>
You are closing system-like index, please be careful before you do any change to it.
You are closing system like index, please be careful before you do any change to it.
</EuiCallOut>
<EuiSpacer />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ HTMLCollection [
<div
class="euiTextColor euiTextColor--default"
>
You are closing system-like index, please be careful before you do any change to it.
You are closing system like index, please be careful before you do any change to it.
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import CreateIndexTemplate from "../CreateIndexTemplate";
import CreateIndex from "../CreateIndex";
import IndexDetail from "../IndexDetail";
import Reindex from "../Reindex/container/Reindex";
import ShrinkIndex from "../ShrinkIndex/container/ShrinkIndex";

enum Navigation {
IndexManagement = "Index Management",
Expand Down Expand Up @@ -480,6 +481,14 @@ export default class Main extends Component<MainProps, object> {
</div>
)}
/>
<Route
path={ROUTES.SHRINK_INDEX}
render={(props) => (
<div style={ROUTE_STYLE}>
<ShrinkIndex {...props} commonService={services.commonService} />
</div>
)}
/>
<Redirect from="/" to={landingPage} />
</Switch>
</EuiPageBody>
Expand Down
Loading

0 comments on commit 9444cd2

Please sign in to comment.