-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: force merge (opensearch-project#608) (opensearch-project#634)
* temp: save Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: add validator Signed-off-by: suzhou <[email protected]> * feat: add unit test Signed-off-by: suzhou <[email protected]> * feat: add unit test Signed-off-by: suzhou <[email protected]> * feat: add cypress test Signed-off-by: suzhou <[email protected]> * feat: try to get cypress test start Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: force merge optimize Signed-off-by: suzhou <[email protected]> * feat: modify toast message Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: update validation Signed-off-by: suzhou <[email protected]> * feat: add debounce Signed-off-by: suzhou <[email protected]> * feat: update validation Signed-off-by: suzhou <[email protected]> * feat: update unit test Signed-off-by: suzhou <[email protected]> * feat: make unit test run Signed-off-by: suzhou <[email protected]> * feat: modify id Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: remove useless code Signed-off-by: suzhou <[email protected]> * feat: update message Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> * feat: add readonly detect Signed-off-by: suzhou <[email protected]> * feat: protect Signed-off-by: suzhou <[email protected]> * feat: use the specific reason when force merge failed Signed-off-by: suzhou <[email protected]> * feat: update Signed-off-by: suzhou <[email protected]> --------- Signed-off-by: suzhou <[email protected]> (cherry picked from commit a7a2ad9)
- Loading branch information
1 parent
24bd906
commit a901f75
Showing
25 changed files
with
1,999 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { PLUGIN_NAME } from "../support/constants"; | ||
|
||
const rolloverValidAlias = "rollover-valid-alias"; | ||
const rolloverAliasNeedTargetIndex = "rollover-alias-need-target-index"; | ||
const rolloverDataStream = "data-stream-rollover"; | ||
const validIndex = "index-000001"; | ||
const invalidIndex = "index-test-rollover"; | ||
|
||
describe("force_merge", () => { | ||
before(() => { | ||
// Set welcome screen tracking to false | ||
localStorage.setItem("home:welcome:show", "false"); | ||
cy.deleteTemplate("index-common-template"); | ||
cy.deleteAllIndices(); | ||
cy.request({ | ||
url: `${Cypress.env("opensearch")}/_data_stream/*`, | ||
method: "DELETE", | ||
failOnStatusCode: false, | ||
}); | ||
cy.createIndex(validIndex); | ||
cy.createIndex(invalidIndex); | ||
cy.addAlias(rolloverValidAlias, validIndex); | ||
cy.addAlias(rolloverAliasNeedTargetIndex, invalidIndex); | ||
cy.createIndexTemplate("index-common-template", { | ||
index_patterns: ["data-stream-*"], | ||
data_stream: {}, | ||
template: { | ||
aliases: { | ||
alias_for_common_1: {}, | ||
alias_for_common_2: {}, | ||
}, | ||
settings: { | ||
number_of_shards: 2, | ||
number_of_replicas: 1, | ||
}, | ||
}, | ||
}); | ||
cy.request({ | ||
url: `${Cypress.env("opensearch")}/_data_stream/${rolloverDataStream}`, | ||
method: "PUT", | ||
failOnStatusCode: false, | ||
}); | ||
}); | ||
|
||
describe("force merge", () => { | ||
it("force merge data stream / index / alias successfully", () => { | ||
// Visit ISM OSD | ||
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/force-merge`); | ||
cy.contains("Configure source index", { timeout: 60000 }); | ||
|
||
// click create | ||
cy.get('[data-test-subj="forceMergeConfirmButton"]').click({ force: true }); | ||
|
||
cy.contains("Index or data stream is required."); | ||
cy.get('[data-test-subj="sourceSelector"] [data-test-subj="comboBoxSearchInput"]').type( | ||
`${rolloverValidAlias}{downArrow}{enter}${rolloverAliasNeedTargetIndex}{downArrow}{enter}${rolloverDataStream}{downArrow}{enter}${validIndex}{downArrow}{enter}${invalidIndex}{downArrow}{enter}` | ||
); | ||
|
||
cy.get('[data-test-subj="forceMergeConfirmButton"]').click({ force: true }); | ||
|
||
cy.contains(/Some shards could not be force merged/); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteTemplate("index-common-template"); | ||
cy.deleteAllIndices(); | ||
cy.request({ | ||
url: `${Cypress.env("opensearch")}/_data_stream/*`, | ||
method: "DELETE", | ||
failOnStatusCode: false, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../pages/ForceMerge/components/ForceMergeAdvancedOptions/ForceMergeAdvancedOptions.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { render, waitFor } from "@testing-library/react"; | ||
import React from "react"; | ||
import ForceMergeAdvancedOptions, { ForceMergeOptionsProps } from "./ForceMergeAdvancedOptions"; | ||
import useField from "../../../../lib/field"; | ||
|
||
const WrappedComponent = (props: Partial<ForceMergeOptionsProps>) => { | ||
const field = useField(); | ||
return <ForceMergeAdvancedOptions {...props} field={field} />; | ||
}; | ||
|
||
describe("<ForceMergeAdvancedOptions /> spec", () => { | ||
it("renders the component", async () => { | ||
const component = render(<WrappedComponent />); | ||
// wait for one tick | ||
await waitFor(() => {}); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
74 changes: 74 additions & 0 deletions
74
public/pages/ForceMerge/components/ForceMergeAdvancedOptions/ForceMergeAdvancedOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { EuiSpacer } from "@elastic/eui"; | ||
import React from "react"; | ||
import CustomFormRow from "../../../../components/CustomFormRow"; | ||
import { AllBuiltInComponents } from "../../../../components/FormGenerator"; | ||
import { FieldInstance } from "../../../../lib/field"; | ||
import SwitchNumber from "../SwitchNumber"; | ||
|
||
export interface ForceMergeOptionsProps { | ||
field: FieldInstance; | ||
} | ||
|
||
const ForceMergeAdvancedOptions = (props: ForceMergeOptionsProps) => { | ||
const { field } = props; | ||
|
||
return ( | ||
<div style={{ padding: "10px 0px" }}> | ||
<CustomFormRow | ||
isInvalid={!!field.getError("max_num_segments")} | ||
error={field.getError("max_num_segments")} | ||
label="Segment indexes" | ||
helpText="Define how many segments to merge to." | ||
> | ||
<SwitchNumber | ||
{...field.registerField({ | ||
name: "max_num_segments", | ||
rules: [ | ||
{ | ||
validator(rule, value) { | ||
const formatValue = new Number(value); | ||
if (Number.isNaN(formatValue.valueOf())) { | ||
return Promise.resolve(""); | ||
} else if (formatValue.valueOf() % 1 !== 0 || formatValue.valueOf() < 1) { | ||
return Promise.reject("Must be an integer great than or equal to 1."); | ||
} | ||
|
||
return Promise.resolve(""); | ||
}, | ||
}, | ||
], | ||
})} | ||
/> | ||
</CustomFormRow> | ||
<EuiSpacer /> | ||
<CustomFormRow label="Flush indexes" helpText="Opensearch will perform a flush on the indexes after the force merge."> | ||
<AllBuiltInComponents.CheckBox | ||
{...field.registerField({ | ||
name: "flush", | ||
})} | ||
label="Flush indexes" | ||
/> | ||
</CustomFormRow> | ||
<EuiSpacer /> | ||
<CustomFormRow | ||
label="Expunge deleted documents" | ||
fullWidth | ||
helpText="Expunge all segments containing more than 10% of deleted documents. The percentage is configurable with the setting index.merge.policy.expunge_deletes_allowed." | ||
> | ||
<AllBuiltInComponents.CheckBox | ||
{...field.registerField({ | ||
name: "only_expunge_deletes", | ||
})} | ||
label="Only expunge delete" | ||
/> | ||
</CustomFormRow> | ||
<EuiSpacer /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ForceMergeAdvancedOptions; |
Oops, something went wrong.