Skip to content

Commit

Permalink
feat: merge
Browse files Browse the repository at this point in the history
Signed-off-by: suzhou <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Feb 22, 2023
2 parents 8e289a7 + 497d5f1 commit 1be89f7
Show file tree
Hide file tree
Showing 43 changed files with 2,242 additions and 148 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.5'
OPENSEARCH_VERSION: '2.5.0-SNAPSHOT'
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
OPENSEARCH_VERSION: '2.6.0-SNAPSHOT'
jobs:
tests:
name: Run Cypress E2E tests
Expand All @@ -29,7 +29,7 @@ jobs:
with:
path: index-management
repository: opensearch-project/index-management
ref: '2.5'
ref: '2.6'
- 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.5'
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
jobs:
tests:
name: Run unit tests
Expand Down
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
4 changes: 2 additions & 2 deletions 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.1",
"version": "2.6.0.0",
"opensearchDashboardsVersion": "2.6.0",
"configPath": ["opensearch_index_management"],
"requiredPlugins": ["navigation", "opensearchDashboardsReact"],
"server": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensearch_index_management_dashboards",
"version": "2.5.0.0",
"version": "2.6.0.0",
"description": "Opensearch Dashboards plugin for Index Management",
"main": "index.js",
"license": "Apache-2.0",
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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

0 comments on commit 1be89f7

Please sign in to comment.