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

Snapshot Restore, basic restore functionality with basic options. Initial PR #276

Merged
merged 44 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ede3cb1
Change alignment of Snapshot Management panels in pages/Main/Main.tsx
phestecAMZN Aug 24, 2022
a5fa7fb
Unify vertical button alignment across panels, ContentPanel.tsx
phestecAMZN Aug 24, 2022
6145593
Update jest snapshots, add ROUTE_STYLE variable
phestecAMZN Aug 24, 2022
f86a83f
Add placeholder restore button to Snapshots panel
phestecAMZN Aug 24, 2022
7a5545c
Merge branch 'opensearch-project:main' into main
phestecAMZN Aug 26, 2022
8001349
Comment out line 20 rollups_spec.js in cypress/integration/
phestecAMZN Aug 26, 2022
f27c4e4
Remove unused code and comment cypress/integration/rollups_spec.js
phestecAMZN Aug 26, 2022
cf0917a
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 1, 2022
391159f
Starting adaptation/use of existing code for Restore functionality
phestecAMZN Aug 29, 2022
983ed48
Adapt Snapshots.tsx to include RestoreSnapshotFlyout
phestecAMZN Aug 29, 2022
3558936
Add restoreSnapshot method to SMservice,RestoreSnapshotResponse int
phestecAMZN Aug 29, 2022
b3141bd
Implement RestoreSnapshotFlyout open/close
phestecAMZN Aug 29, 2022
7bfdb86
Make Snapshot name appear on RestoreSnapshotFlyout
phestecAMZN Aug 29, 2022
845cca2
Add/adapt restoreSnapshot to server/SnapshotManagementService
phestecAMZN Aug 29, 2022
703d93b
Add route for restoreSnapshot in server/routes.ts
phestecAMZN Aug 29, 2022
78095b7
Rudimentary restore from snapshot functionality reached, buggy
phestecAMZN Aug 29, 2022
e16528b
Fix index list-snapshot restore, restrict restore to single selection
phestecAMZN Aug 29, 2022
75e1dfe
Remove console.logs, commented out code
phestecAMZN Sep 6, 2022
02d651c
Create Advanced options accordion for Snapshot restore.
phestecAMZN Aug 30, 2022
bf4a4a5
Add initial restore/rename options to ui. Only visual functionality
phestecAMZN Aug 30, 2022
e8e46ea
Resolve radio button events not firing
phestecAMZN Aug 31, 2022
5cd9afc
Add AddPrefixInput, remove unused component RestoreSnapshotInitialOpt…
phestecAMZN Sep 1, 2022
a80656f
Fix issues with restore specific indices
phestecAMZN Sep 1, 2022
aa46d71
Begin cypress testing for snapshots
phestecAMZN Sep 1, 2022
3cf3711
Begin cypress testing Snapshots. Create repo and Create snapshot done
phestecAMZN Sep 2, 2022
b9ad019
Implement add_prefix functionality for snapshot restore
phestecAMZN Sep 2, 2022
fdfb43a
Implement rename indices option for restore snapshot
phestecAMZN Sep 2, 2022
5af4208
Remove console.logs, unusted variables in SnapshotFlyout, SMservice
phestecAMZN Sep 5, 2022
5cf239f
Add full stop to help text/errors, add RESTORE_OPTIONS enum
phestecAMZN Sep 7, 2022
2637b33
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 10, 2022
fd77a64
Add back line 20 in rollups_spec, required by changes in 2.3 release.
phestecAMZN Sep 12, 2022
fb7f19e
Remove unused getRepos func, add repo prop, trim state in RestoreFlyout
phestecAMZN Sep 15, 2022
f553dbe
Add increment to 2.3.0
phestecAMZN Sep 15, 2022
653fc0d
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 16, 2022
2ba8b71
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 4, 2022
904b0b0
Change 2.3 to 2.3.0, cypress-workflow.yml
phestecAMZN Oct 5, 2022
12fd096
Comment out line 20 rollups_spec.js causing error in PR E2E
phestecAMZN Oct 5, 2022
6fcdfbb
Merge branch 'main' into basic_restore
phestecAMZN Oct 5, 2022
4b9406a
Change 2.2 to 2.3 unit-tests-workflow.yml
phestecAMZN Oct 5, 2022
7228a53
Merge branch 'basic_restore' of github.com:phestecAMZN/index-manageme…
phestecAMZN Oct 5, 2022
6ee1bd4
Uncomment line 19, rollups_spec.js to attempt E2E success on github
phestecAMZN Oct 5, 2022
f7fd12e
Fix url, change "Sample" to "sample" rollups_spec lines 17, 21
phestecAMZN Oct 5, 2022
ccd4568
Change "sample data" to "Add data" rollops_spec.js
phestecAMZN Oct 5, 2022
99c9bf3
Add 10s wait line19, rollups_spec to help find button next step
phestecAMZN Oct 5, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.2'
OPENSEARCH_DASHBOARDS_VERSION: '2.3'
jobs:
tests:
name: Run unit tests
Expand Down
8 changes: 5 additions & 3 deletions cypress/integration/rollups_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ describe("Rollups", () => {
localStorage.setItem("home:welcome:show", "true");

// Go to sample data page
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/home#/tutorial_directory/sampleData`);
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/home#/tutorial_directory`);

// Click on "Sample data" tab
cy.contains("Sample data").click({ force: true });
cy.wait(10000)

// // Click on "Sample data" tab
// cy.contains("Add data").click({ force: true });

// Load sample eCommerce data
cy.get(`button[data-test-subj="addSampleDataSetecommerce"]`).click({ force: true });
Expand Down
102 changes: 102 additions & 0 deletions cypress/integration/snapshots_spec.js
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");
});
});
});
14 changes: 14 additions & 0 deletions public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ export interface LatestActivities {
cause?: string;
};
}

export enum RESTORE_OPTIONS {
restore_specific_indices = "restore_specific_indices",
restore_all_indices = "restore_all_indices",
do_not_rename = "do_not_rename",
add_prefix = "add_prefix",
rename_indices = "rename_indices",
restore_aliases = "restore_aliases",
include_global_state = "include_global_state",
ignore_unavailable = "ignore_unavailable",
partial = "partial",
customize_index_settings = "customize_index_settings",
ignore_index_settings = "ignore_index_settings",
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const SnapshotIndicesRepoInput = ({
onSearchChange={getIndexOptions}
onCreateOption={onCreateOption}
isClearable={true}
data-test-subj="indicesComboBoxInput"
/>

<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ export default class CreateRepositoryFlyout extends Component<CreateRepositoryPr
<EuiFlyoutBody>
<CustomLabel title="Repository name" />
<EuiFormRow isInvalid={!!repoNameError} error={repoNameError}>
<EuiFieldText disabled={!!editRepo} value={repoName} onChange={(e) => this.setState({ repoName: e.target.value })} />
<EuiFieldText
disabled={!!editRepo}
value={repoName}
data-test-subj="repoNameInput"
onChange={(e) => this.setState({ repoName: e.target.value })}
/>
</EuiFormRow>

<EuiSpacer size="m" />
Expand Down
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" />
</>
);
};

Copy link
Contributor Author

@phestecAMZN phestecAMZN Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links to documentation are provided in forthcoming PR, regarding line 26 help text

export default AddPrefixesInput;
8 changes: 8 additions & 0 deletions public/pages/Snapshots/components/AddPrefixInput/index.ts
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;
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export default class CreateSnapshotFlyout extends Component<CreateSnapshotProps,
onChange={(e) => {
this.setState({ snapshotId: e.target.value });
}}
data-test-subj="snapshotNameInput"
/>
</EuiFormRow>

Expand Down
53 changes: 53 additions & 0 deletions public/pages/Snapshots/components/RenameInput/RenameInput.tsx
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]";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, proper links to documentation in help text are addressed in forthcoming PR

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;
8 changes: 8 additions & 0 deletions public/pages/Snapshots/components/RenameInput/index.ts
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;
Loading