Skip to content

Commit

Permalink
Merge branch '2.x' into backport961
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenlan-amzn committed Jan 18, 2024
2 parents a634312 + 5da75d1 commit 98c3d1b
Show file tree
Hide file tree
Showing 109 changed files with 2,545 additions and 837 deletions.
33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

const LICENSE_HEADER = `
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
`;

module.exports = {
root: true,
extends: ["@elastic/eslint-config-kibana", "plugin:@elastic/eui/recommended"],
rules: {
// "@osd/eslint/require-license-header": "off"
},
overrides: [
{
files: ["**/*.{js,ts,tsx}"],
rules: {
"@osd/eslint/require-license-header": [
"error",
{
licenses: [LICENSE_HEADER],
},
],
"no-console": 0,
},
},
],
};
4 changes: 3 additions & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
installation_id: 22958780

- name: Backport
uses: VachaShah/backport@v1.1.4
uses: VachaShah/backport@v2.2.0
with:
github_token: ${{ steps.github_app_token.outputs.token }}
branch_name: backport/backport-${{ github.event.number }}
labels_template: "<%= JSON.stringify([...labels, 'autocut']) %>"
failure_labels: "failed backport"
2 changes: 1 addition & 1 deletion .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Run OpenSearch-Dashboards server
run: |
cd OpenSearch-Dashboards
yarn start --no-base-path --no-watch &
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
sleep 300
# timeout 300 bash -c 'while [[ "$(curl -s localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done'
# for now just chrome, use matrix to do all browsers later
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/dco.yml

This file was deleted.

95 changes: 0 additions & 95 deletions .github/workflows/release-workflow.yml

This file was deleted.

46 changes: 41 additions & 5 deletions .github/workflows/unit-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,50 @@ on:
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
jobs:
tests:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch-dashboards

tests-linux:
needs: Get-CI-Image-Tag
name: Run unit tests
runs-on: ubuntu-latest
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root

steps:
# Enable longer filenames for windows
- name: Checkout OpenSearch-Dashboards
uses: actions/checkout@v2
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
path: OpenSearch-Dashboards
- name: Checkout Index Management Dashboards plugin
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin
- name: Bootstrap / Run tests
run: |
chown -R 1000:1000 `pwd`
cd ./OpenSearch-Dashboards/
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
cd ./plugins/index-management-dashboards-plugin &&
whoami && yarn osd bootstrap && yarn run test:jest --coverage"
- name: Uploads coverage
uses: codecov/codecov-action@v1

tests-windows-macos:
name: Run unit tests
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
# Enable longer filenames for windows
Expand Down Expand Up @@ -52,6 +91,3 @@ jobs:
run: |
cd OpenSearch-Dashboards/plugins/index-management-dashboards-plugin
yarn run test:jest --coverage
- name: Uploads coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v1
21 changes: 14 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@

// babelrc doesn't respect NODE_PATH anymore but using require does.
// Alternative to install them locally in node_modules
module.exports = {
presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")],
plugins: [
[require("@babel/plugin-transform-runtime"), { regenerator: true }],
require("@babel/plugin-proposal-class-properties"),
require("@babel/plugin-proposal-object-rest-spread"),
],
module.exports = function (api) {
// ensure env is test so that this config won't impact build or dev server
if (api.env("test")) {
return {
presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")],
plugins: [
[require("@babel/plugin-transform-runtime"), { regenerator: true }],
require("@babel/plugin-transform-class-properties"),
require("@babel/plugin-transform-object-rest-spread"),
[require("@babel/plugin-transform-modules-commonjs"), { allowTopLevelThis: true }],
],
};
}
return {};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"policy": {
"policy_id": "test_alias_policy_id",
"description": "Example policy with an alias action.",
"default_state": "alias-state",
"states": [
{
"name": "alias-state",
"actions": [
{
"alias": {
"actions": [
{
"remove": {
"aliases": ["alias1", "alias2"]
}
},
{
"remove": {
"alias": "alias3"
}
},
{
"add": {
"aliases": ["alias4", "alias5"]
}
},
{
"add": {
"aliases": "alias6"
}
}
]
}
}
],
"transitions": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import samplePolicy from "../../../fixtures/plugins/index-management-dashboards-
const POLICY_ID = "test_policy_id";
const SAMPLE_INDEX = "sample_index";

describe("Indices", () => {
describe("Indexes", () => {
beforeEach(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
Expand Down Expand Up @@ -52,7 +52,7 @@ describe("Indices", () => {
});
});

describe("can show data stream indices", () => {
describe("can show data stream indexes", () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
Expand Down Expand Up @@ -169,7 +169,7 @@ describe("Indices", () => {
});
});

describe("can make indices deleted", () => {
describe("can make indexes deleted", () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
Expand Down Expand Up @@ -417,7 +417,7 @@ describe("Indices", () => {
cy.get('[data-test-subj="Close Action"]').should("exist").should("not.have.class", "euiContextMenuItem-isDisabled").click();

// Check for close index modal
cy.contains("Close indices");
cy.contains("Close indexes");

// Close confirm button should be disabled
cy.get('[data-test-subj="Close Confirm button"]').should("have.class", "euiButton-isDisabled");
Expand Down Expand Up @@ -457,7 +457,7 @@ describe("Indices", () => {
cy.get('[data-test-subj="Open Action"]').should("exist").should("not.have.class", "euiContextMenuItem-isDisabled").click();

// Check for open index modal
cy.contains("Open indices");
cy.contains("Open indexes");

cy.get('[data-test-subj="Open Confirm button"]').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const POLICY_ID_ROLLOVER = "test_policy_rollover";
const SAMPLE_INDEX = "sample_index";
const SAMPLE_INDEX_ROLLOVER = "sample_index-01";

describe("Managed indices", () => {
describe("Managed indexes", () => {
beforeEach(() => {
// Set welcome screen tracking to false
localStorage.setItem("home:welcome:show", "false");
Expand Down Expand Up @@ -58,13 +58,13 @@ describe("Managed indices", () => {
});

// Confirm we got a remove policy toaster
cy.contains("Removed policy from 1 managed indices");
cy.contains("Removed policy from 1 managed indexes");

// Wait some time for remove policy to execute before reload
cy.wait(3000).reload();

// Confirm we are back to empty loading state, give 20 seconds as OSD takes a while to load
cy.contains("There are no existing managed indices.", { timeout: 20000 });
cy.contains("There are no existing managed indexes.", { timeout: 20000 });
});
});

Expand Down Expand Up @@ -121,7 +121,7 @@ describe("Managed indices", () => {
cy.get(`[data-test-subj="retryModalRetryButton"]`).click({ force: true });

// Confirm we got retry toaster
cy.contains("Retried 1 managed indices");
cy.contains("Retried 1 managed indexes");

// Reload the page
cy.reload();
Expand Down Expand Up @@ -238,10 +238,10 @@ describe("Managed indices", () => {
});

// Confirm we got the change policy toaster
cy.contains("Changed policy on 1 indices");
cy.contains("Changed policy on 1 indexes");

// Click back to Managed Indices page by clicking "Managed indices" breadcrumb
cy.contains("Policy managed indices").click();
cy.contains("Policy managed indexes").click();

// Speed up execution of managed index
cy.updateManagedIndexConfigStartTime(SAMPLE_INDEX);
Expand All @@ -257,7 +257,7 @@ describe("Managed indices", () => {
});
});

describe("can manage data stream indices", () => {
describe("can manage data stream indexes", () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
Expand Down
Loading

0 comments on commit 98c3d1b

Please sign in to comment.