Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shrink index page #530

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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