-
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.
Snapshot Restore, basic restore functionality with basic options. Ini…
…tial PR (opensearch-project#276) * Change alignment of Snapshot Management panels in pages/Main/Main.tsx Signed-off-by: Chris Hesterman <[email protected]> * Unify vertical button alignment across panels, ContentPanel.tsx Signed-off-by: Chris Hesterman <[email protected]> * Update jest snapshots, add ROUTE_STYLE variable Signed-off-by: Chris Hesterman <[email protected]> * Add placeholder restore button to Snapshots panel Signed-off-by: Chris Hesterman <[email protected]> * Comment out line 20 rollups_spec.js in cypress/integration/ Signed-off-by: Chris Hesterman <[email protected]> * Remove unused code and comment cypress/integration/rollups_spec.js Signed-off-by: Chris Hesterman <[email protected]> * Starting adaptation/use of existing code for Restore functionality Signed-off-by: Chris Hesterman <[email protected]> * Adapt Snapshots.tsx to include RestoreSnapshotFlyout Signed-off-by: Chris Hesterman <[email protected]> * Add restoreSnapshot method to SMservice,RestoreSnapshotResponse int Signed-off-by: Chris Hesterman <[email protected]> * Implement RestoreSnapshotFlyout open/close Signed-off-by: Chris Hesterman <[email protected]> * Make Snapshot name appear on RestoreSnapshotFlyout Signed-off-by: Chris Hesterman <[email protected]> * Add/adapt restoreSnapshot to server/SnapshotManagementService Signed-off-by: Chris Hesterman <[email protected]> * Add route for restoreSnapshot in server/routes.ts Signed-off-by: Chris Hesterman <[email protected]> * Rudimentary restore from snapshot functionality reached, buggy Signed-off-by: Chris Hesterman <[email protected]> * Fix index list-snapshot restore, restrict restore to single selection Signed-off-by: Chris Hesterman <[email protected]> * Remove console.logs, commented out code Signed-off-by: Chris Hesterman <[email protected]> * Create Advanced options accordion for Snapshot restore. Signed-off-by: Chris Hesterman <[email protected]> Currently only visually functional. TODO - make it apply the options Signed-off-by: Chris Hesterman <[email protected]> * Add initial restore/rename options to ui. Only visual functionality Signed-off-by: Chris Hesterman <[email protected]> * Resolve radio button events not firing Signed-off-by: Chris Hesterman <[email protected]> Split radio buttons into SnapshotRestoreOption and SnapshotRenameOptions Signed-off-by: Chris Hesterman <[email protected]> Move 'restore' button between 'delete' and 'take snapshot' Signed-off-by: Chris Hesterman <[email protected]> Set default rename option to 'add prefix' Signed-off-by: Chris Hesterman <[email protected]> * Add AddPrefixInput, remove unused component RestoreSnapshotInitialOptions Signed-off-by: Chris Hesterman <[email protected]> * Fix issues with restore specific indices Signed-off-by: Chris Hesterman <[email protected]> Implement first 4 Advanced restore options functionality Signed-off-by: Chris Hesterman <[email protected]> * Begin cypress testing for snapshots Signed-off-by: Chris Hesterman <[email protected]> Passing tests for create repo and create snapshot Signed-off-by: Chris Hesterman <[email protected]> * Begin cypress testing Snapshots. Create repo and Create snapshot done Signed-off-by: Chris Hesterman <[email protected]> * Implement add_prefix functionality for snapshot restore Signed-off-by: Chris Hesterman <[email protected]> * Implement rename indices option for restore snapshot Signed-off-by: Chris Hesterman <[email protected]> * Remove console.logs, unusted variables in SnapshotFlyout, SMservice Signed-off-by: Chris Hesterman <[email protected]> * Add full stop to help text/errors, add RESTORE_OPTIONS enum Signed-off-by: Chris Hesterman <[email protected]> * Add back line 20 in rollups_spec, required by changes in 2.3 release. Signed-off-by: Chris Hesterman <[email protected]> * Remove unused getRepos func, add repo prop, trim state in RestoreFlyout Signed-off-by: Chris Hesterman <[email protected]> * Add increment to 2.3.0 Signed-off-by: Chris Hesterman <[email protected]> * Change 2.3 to 2.3.0, cypress-workflow.yml Signed-off-by: Chris Hesterman <[email protected]> * Comment out line 20 rollups_spec.js causing error in PR E2E Signed-off-by: Chris Hesterman <[email protected]> * Change 2.2 to 2.3 unit-tests-workflow.yml Signed-off-by: Chris Hesterman <[email protected]> * Uncomment line 19, rollups_spec.js to attempt E2E success on github Signed-off-by: Chris Hesterman <[email protected]> * Fix url, change "Sample" to "sample" rollups_spec lines 17, 21 Signed-off-by: Chris Hesterman <[email protected]> * Change "sample data" to "Add data" rollops_spec.js Signed-off-by: Chris Hesterman <[email protected]> All of these variations pass seamlessly when run locally. Signed-off-by: Chris Hesterman <[email protected]> * Add 10s wait line19, rollups_spec to help find button next step Signed-off-by: Chris Hesterman <[email protected]> Signed-off-by: Chris Hesterman <[email protected]>
- Loading branch information
1 parent
7f9c2c5
commit f7db4af
Showing
28 changed files
with
1,019 additions
and
12 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,102 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PLUGIN_NAME } from "../support/constants"; | ||
|
||
describe("Snapshots", () => { | ||
before(() => { | ||
// Delete any existing indices | ||
cy.deleteAllIndices(); | ||
|
||
// Load ecommerce data | ||
cy.request({ | ||
method: "POST", | ||
url: `${Cypress.env("opensearch_dashboards")}/api/sample_data/ecommerce`, | ||
headers: { | ||
"osd-xsrf": true, | ||
}, | ||
}).then((response) => { | ||
expect(response.status).equal(200); | ||
}); | ||
|
||
// Load flight data | ||
cy.request({ | ||
method: "POST", | ||
url: `${Cypress.env("opensearch_dashboards")}/api/sample_data/flights`, | ||
headers: { | ||
"osd-xsrf": true, | ||
}, | ||
}).then((response) => { | ||
expect(response.status).equal(200); | ||
}); | ||
|
||
// Load web log data | ||
cy.request({ | ||
method: "POST", | ||
url: `${Cypress.env("opensearch_dashboards")}/api/sample_data/logs`, | ||
headers: { | ||
"osd-xsrf": true, | ||
}, | ||
}).then((response) => { | ||
expect(response.status).equal(200); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Set welcome screen tracking to false | ||
localStorage.setItem("home:welcome:show", "false"); | ||
|
||
// Visit ISM Snapshots Dashboard | ||
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/snapshots`); | ||
|
||
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load | ||
cy.contains("Restore", { timeout: 60000 }); | ||
}); | ||
|
||
describe("Repository can be created", () => { | ||
it("successfully creates a new repository", () => { | ||
// Create repository to store snapshots | ||
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/repositories`); | ||
|
||
// Route to create repository page | ||
cy.contains("Create repository").click({ force: true }); | ||
|
||
// Type in repository name | ||
cy.get(`input[data-test-subj="repoNameInput"]`).focus().type("test_repo"); | ||
|
||
// Type in repository location | ||
cy.get(`input[placeholder="e.g., /mnt/snapshots"]`).focus().type("~/Desktop"); | ||
|
||
// Click Add button | ||
cy.get("button").contains("Add").click({ force: true }); | ||
|
||
// Confirm repository created | ||
cy.contains("test_repo"); | ||
}); | ||
}); | ||
|
||
describe("Snapshot can be created", () => { | ||
it("successfully creates a new snapshot", () => { | ||
// Click Take snapshot button | ||
cy.get("button").contains("Take snapshot").click({ force: true }); | ||
|
||
// Type in Snapshot name | ||
cy.get(`input[data-test-subj="snapshotNameInput"]`).type("test_snapshot{enter}"); | ||
|
||
// Select indexes to be included | ||
cy.get(`[data-test-subj="indicesComboBoxInput"]`).type("open*{enter}"); | ||
|
||
// Confirm test_repo exists | ||
cy.contains("test_repo"); | ||
|
||
// Click 'Add' button to create snapshot | ||
cy.get("button").contains("Add").click({ force: true }); | ||
|
||
// check for success status and snapshot name | ||
cy.contains("In_progress"); | ||
cy.contains("test_snapshot"); | ||
}); | ||
}); | ||
}); |
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
36 changes: 36 additions & 0 deletions
36
public/pages/Snapshots/components/AddPrefixInput/AddPrefixInput.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,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiFormRow, EuiFieldText, EuiSpacer } from "@elastic/eui"; | ||
import React, { useState, ChangeEvent } from "react"; | ||
import CustomLabel from "../../../../components/CustomLabel"; | ||
|
||
interface AddPrefixesInputProps { | ||
getPrefix: (prefix: string) => void; | ||
} | ||
|
||
const AddPrefixesInput = ({ getPrefix }: AddPrefixesInputProps) => { | ||
const [prefix, setPrefix] = useState(""); | ||
|
||
const onPrefixChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
setPrefix(e.target.value); | ||
getPrefix(e.target.value); | ||
}; | ||
|
||
return ( | ||
<> | ||
<EuiSpacer size="l" /> | ||
|
||
<CustomLabel title="Specify prefix for restored index names" helpText="A prefix will be added to any restored index names." /> | ||
<EuiFormRow> | ||
<EuiFieldText value={prefix} onChange={onPrefixChange} /> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
</> | ||
); | ||
}; | ||
|
||
export default AddPrefixesInput; |
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,8 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import AddPrefixInput from "./AddPrefixInput"; | ||
|
||
export default AddPrefixInput; |
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
53 changes: 53 additions & 0 deletions
53
public/pages/Snapshots/components/RenameInput/RenameInput.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,53 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiFormRow, EuiFieldText, EuiSpacer } from "@elastic/eui"; | ||
import React, { useState, ChangeEvent } from "react"; | ||
import CustomLabel from "../../../../components/CustomLabel"; | ||
|
||
interface RenameInputProps { | ||
getRenamePattern: (prefix: string) => void; | ||
getRenameReplacement: (prefix: string) => void; | ||
} | ||
|
||
const RenameInput = ({ getRenamePattern, getRenameReplacement }: RenameInputProps) => { | ||
const [renamePattern, setRenamePattern] = useState(""); | ||
const [renameReplacement, setRenameReplacement] = useState(""); | ||
|
||
const onPatternChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
setRenamePattern(e.target.value); | ||
getRenamePattern(e.target.value); | ||
}; | ||
|
||
const onReplacementChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
setRenameReplacement(e.target.value); | ||
getRenameReplacement(e.target.value); | ||
}; | ||
|
||
const patternHelpText = | ||
"Use regular expressiojn to define how index names will be renamed. By default, input (.+) to reuse the entire index name. [Learn more]"; | ||
const replacementHelpText = | ||
"Define the format of renamed indices. Use $0 to include the entire matching index name, $1 to include the content of the first capture group, etc. [Learn more]"; | ||
|
||
return ( | ||
<> | ||
<EuiSpacer size="l" /> | ||
|
||
<CustomLabel title="Rename Pattern" helpText={patternHelpText} /> | ||
<EuiFormRow> | ||
<EuiFieldText value={renamePattern} onChange={onPatternChange} /> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<CustomLabel title="Rename Replacement" helpText={replacementHelpText} /> | ||
<EuiFormRow> | ||
<EuiFieldText value={renameReplacement} onChange={onReplacementChange} /> | ||
</EuiFormRow> | ||
</> | ||
); | ||
}; | ||
|
||
export default RenameInput; |
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,8 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import RenameInput from "./RenameInput"; | ||
|
||
export default RenameInput; |
Oops, something went wrong.