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

Feature: rollover #607

Merged
merged 34 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e38da05
feat: update
SuZhou-Joe Dec 30, 2022
88e95b2
feat: update
SuZhou-Joe Dec 30, 2022
411e2aa
feat: update
SuZhou-Joe Dec 30, 2022
9c97e52
feat: add write index in aliases
SuZhou-Joe Feb 9, 2023
1aa06dc
feat: remove conditions section
SuZhou-Joe Feb 10, 2023
0b74b6b
feat: update
SuZhou-Joe Feb 10, 2023
426aae7
feat: update
SuZhou-Joe Feb 12, 2023
6b0ea13
feat: merge data streams
SuZhou-Joe Feb 12, 2023
4f95100
feat: update
SuZhou-Joe Feb 12, 2023
9bbe580
feat: update
SuZhou-Joe Feb 12, 2023
a645274
feat: add rollover cypress test
SuZhou-Joe Feb 12, 2023
307ff5e
feat: update
SuZhou-Joe Feb 12, 2023
16dbc8f
feat: update
SuZhou-Joe Feb 12, 2023
fdee963
feat: make cypress run
SuZhou-Joe Feb 13, 2023
fa82516
feat cypress optimize
SuZhou-Joe Feb 13, 2023
586b24f
fix: rollover with mappings
SuZhou-Joe Feb 14, 2023
68d7598
feat: update
SuZhou-Joe Feb 14, 2023
e32e688
feat: make rollover works in index form
SuZhou-Joe Feb 15, 2023
d41c4a1
feat: update
SuZhou-Joe Feb 15, 2023
788740f
feat: update
SuZhou-Joe Feb 15, 2023
30a8083
feat: update
SuZhou-Joe Feb 15, 2023
6a04ecd
feat: update
SuZhou-Joe Feb 15, 2023
5f01829
feat: update
SuZhou-Joe Feb 15, 2023
d88d848
feat: add placeholder
SuZhou-Joe Feb 16, 2023
52ff76e
feat: alignment
SuZhou-Joe Feb 18, 2023
424acf2
feat: update
SuZhou-Joe Feb 18, 2023
110fb4d
feat: update rollover description
SuZhou-Joe Feb 18, 2023
eff598e
feat: update
SuZhou-Joe Feb 18, 2023
510561b
feat: update snapshot
SuZhou-Joe Feb 20, 2023
39da6cd
feat: make cypress and unit test run
SuZhou-Joe Feb 20, 2023
4b2a67d
feat: update
SuZhou-Joe Feb 20, 2023
bcf955b
feat: update
SuZhou-Joe Feb 20, 2023
d23c779
feat: update
SuZhou-Joe Feb 20, 2023
fc3ba3f
feat: merge
SuZhou-Joe Feb 22, 2023
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/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
path: index-management
repository: opensearch-project/index-management
ref: 'main'
ref: '2.5'
- name: Run opensearch with plugin
run: |
cd index-management
Expand Down
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.x'
OPENSEARCH_DASHBOARDS_VERSION: '2.5'
jobs:
tests:
name: Run unit tests
Expand Down
90 changes: 90 additions & 0 deletions cypress/integration/data_streams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";

describe("Data stream", () => {
before(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
cy.deleteTemplate("index-common-template");
cy.createIndexTemplate("index-common-template", {
index_patterns: ["ds-*"],
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/*`,
method: "DELETE",
failOnStatusCode: false,
});
});

beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/data-streams`);

// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains("Data streams", { timeout: 60000 });
});

describe("can create a data stream", () => {
it("successfully", () => {
cy.get('[data-test-subj="Create data streamButton"]').click();
cy.get('[data-test-subj="form-row-name"]').type(`ds-{enter}`);
cy.get('[data-test-subj="CreateDataStreamCreateButton"]').click();
cy.contains("ds- has been successfully created.");
});
});

describe("can be searched / sorted / paginated", () => {
it("successfully", () => {
cy.contains("ds-");
cy.contains("index-common-template");
});
});

describe("can delete a data stream", () => {
it("successfully", () => {
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="deleteAction"]')
.should("be.disabled")
.get(`#_selection_column_ds--checkbox`)
.click()
.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="deleteAction"]')
.click();
// The confirm button should be disabled
cy.get('[data-test-subj="deleteConfirmButton"]').should("be.disabled");
// type delete
cy.wait(500).get('[data-test-subj="deleteInput"]').type("delete");
cy.get('[data-test-subj="deleteConfirmButton"]').should("not.be.disabled");
// click to delete
cy.get('[data-test-subj="deleteConfirmButton"]').click();
// the alias should not exist
cy.wait(500);
cy.get(`#_selection_column_ds--checkbox`).should("not.exist");
});
});

after(() => {
cy.request({
url: `${Cypress.env("opensearch")}/_data_stream`,
method: "DELETE",
failOnStatusCode: false,
});
cy.deleteTemplate("index-common-template");
});
});
100 changes: 100 additions & 0 deletions cypress/integration/rollover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* 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("Rollover", () => {
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("rollover", () => {
it("rollover data stream successfully", () => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/rollover/${rolloverDataStream}`);
cy.contains("Configure source", { timeout: 60000 });

// click create
cy.get('[data-test-subj="rolloverSubmitButton"]').click({ force: true });

cy.contains(/has been successfully rollover./);
});

it("rollover valid alias successfully", () => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/rollover/${rolloverValidAlias}`);
cy.contains("Configure new rollover index", { timeout: 60000 });

// click create
cy.get('[data-test-subj="rolloverSubmitButton"]').click({ force: true });

cy.contains(/has been successfully rollover./);
});

it("rollover invalid alias successfully", () => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/rollover/${rolloverAliasNeedTargetIndex}`);
cy.contains("Configure new rollover index", { timeout: 60000 });

// click create
cy.get('[data-test-subj="rolloverSubmitButton"]').click({ force: true });

cy.contains("Invalid index name.");

cy.get('[data-test-subj="form-name-index"] input').type("index-test-rollover-target");

// click create
cy.get('[data-test-subj="rolloverSubmitButton"]').click({ force: true });

cy.contains(/has been successfully rollover./);
});
});

after(() => {
cy.deleteTemplate("index-common-template");
cy.deleteAllIndices();
cy.request({
url: `${Cypress.env("opensearch")}/_data_stream/*`,
method: "DELETE",
failOnStatusCode: false,
});
});
});
1 change: 1 addition & 0 deletions models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ export interface IAPICaller {
endpoint: string;
method?: string;
data?: any;
hideLog?: boolean;
}

export interface IRecoveryItem {
Expand Down
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "indexManagementDashboards",
"version": "2.5.0.0",
"opensearchDashboardsVersion": "2.5.0",
"opensearchDashboardsVersion": "2.5.1",
"configPath": ["opensearch_index_management"],
"requiredPlugins": ["navigation", "opensearchDashboardsReact"],
"server": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import React, { forwardRef, useRef } from "react";
import { EuiComboBoxProps } from "@elastic/eui";
import RemoteSelect, { RemoteSelectProps } from "../../../../components/RemoteSelect";
import { ServerResponse } from "../../../../../server/models/types";
import { filterByMinimatch } from "../../../../../utils/helper";
import { SYSTEM_ALIAS } from "../../../../../utils/constants";
import RemoteSelect, { RemoteSelectProps } from "../RemoteSelect";
import { ServerResponse } from "../../../server/models/types";
import { filterByMinimatch } from "../../../utils/helper";
import { SYSTEM_ALIAS } from "../../../utils/constants";

export interface AliasSelectProps extends Omit<EuiComboBoxProps<{ label: string; value: string }>, "value" | "onChange"> {
value?: Record<string, {}>;
Expand Down
10 changes: 5 additions & 5 deletions public/components/DescriptionListHoz/DescriptionListHoz.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EuiDescriptionList, EuiDescriptionListProps, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import { EuiDescriptionList, EuiDescriptionListProps, EuiFlexGrid, EuiFlexGridProps, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import React from "react";

const DisplayItem = (
Expand All @@ -20,15 +20,15 @@ const DisplayItem = (
);
};

export default function DescriptionListHoz(props: EuiDescriptionListProps) {
const { listItems, ...others } = props;
export default function DescriptionListHoz(props: EuiDescriptionListProps & Pick<EuiFlexGridProps, "columns">) {
const { listItems, columns = 4, ...others } = props;
return (
<EuiFlexGroup>
<EuiFlexGrid columns={columns}>
{listItems?.map((item) => (
<EuiFlexItem key={item.title as string}>
<DisplayItem listItem={item} {...others} />
</EuiFlexItem>
))}
</EuiFlexGroup>
</EuiFlexGrid>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`<DescriptionListHoz /> spec renders the component 1`] = `
<div>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--directionRow euiFlexGroup--responsive"
class="euiFlexGrid euiFlexGrid--gutterLarge euiFlexGrid--fourths euiFlexGrid--responsive"
>
<div
class="euiFlexItem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ const componentMap: Record<ComponentMapEnum, React.ComponentType<IFieldComponent
return (
<EuiComboBox
onCreateOption={(searchValue) => {
const findItem = options.find((item: { label: string }) => item.label === searchValue);
const allOptions = (options as { label: string; options?: { label: string }[] }[]).reduce((total, current) => {
if (current.options) {
return [...total, ...current.options];
} else {
return [...total, current];
}
}, [] as { label: string }[]);
const findItem = allOptions.find((item: { label: string }) => item.label === searchValue);
if (findItem) {
onChange(searchValue);
}
Expand Down
10 changes: 5 additions & 5 deletions public/components/FormGenerator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { forwardRef, useRef, useImperativeHandle, useEffect, useMemo } fr
import { EuiForm, EuiFormProps, EuiSpacer } from "@elastic/eui";
import { isEqual, omit, pick } from "lodash";
import AllBuiltInComponents, { IFieldComponentProps } from "./built_in_components";
import useField, { InitOption, FieldOption, Rule, FieldInstance, FieldName } from "../../lib/field";
import useField, { InitOption, FieldOption, Rule, FieldInstance, FieldName, transformNameToString } from "../../lib/field";
import AdvancedSettings, { IAdvancedSettingsProps, IAdvancedSettingsRef } from "../AdvancedSettings";
import CustomFormRow, { CustomFormRowProps } from "../CustomFormRow";

Expand All @@ -23,7 +23,7 @@ interface IFormGeneratorAdvancedSettings<T> extends IAdvancedSettingsProps<T> {

export interface IField {
rowProps: Pick<CustomFormRowProps, "label" | "helpText" | "fullWidth" | "position" | "direction" | "style">;
name: string;
name: FieldName;
type?: keyof typeof AllBuiltInComponents;
component?: React.ComponentType<IFieldComponentProps>;
options?: Omit<IInitOption, "name">;
Expand Down Expand Up @@ -129,10 +129,10 @@ function FormGenerator<T>(props: IFormGeneratorProps<T>, ref: React.Ref<IFormGen
return (
<CustomFormRow
data-test-subj={`form-name-${item.name}`}
key={item.name}
key={transformNameToString(item.name)}
{...item.rowProps}
error={errorMessage[item.name]}
isInvalid={!!errorMessage[item.name]}
error={errorMessage[transformNameToString(item.name)]}
isInvalid={!!errorMessage[transformNameToString(item.name)]}
>
<RenderComponent
{...field.registerField({
Expand Down
Loading