diff --git a/.github/workflows/pr_check_workflow.yml b/.github/workflows/pr_check_workflow.yml index 9d9ed4a9dd28..4f1d88060cce 100644 --- a/.github/workflows/pr_check_workflow.yml +++ b/.github/workflows/pr_check_workflow.yml @@ -23,9 +23,11 @@ env: jobs: build-lint-test: runs-on: ubuntu-latest + container: + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 + options: --user 1001 name: Build and Verify steps: - - name: Checkout code uses: actions/checkout@v2 @@ -61,6 +63,9 @@ jobs: functional-tests: runs-on: ubuntu-latest + container: + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 + options: --user 1001 name: Run functional tests strategy: matrix: @@ -82,9 +87,9 @@ jobs: npm uninstall -g yarn npm i -g yarn@1.22.10 - # github virtual env is the latest chrome + # image has the latest chrome v99 - name: Setup chromedriver - run: yarn add --dev chromedriver@100.0.0 + run: yarn add --dev chromedriver@99.0.0 - name: Run bootstrap run: yarn osd bootstrap @@ -100,3 +105,126 @@ jobs: CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} JOB: ci${{ matrix.group }} CACHE_DIR: ciGroup${{ matrix.group }} + + build-min-artifact-tests: + runs-on: ubuntu-latest + container: + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 + options: --user 1001 + name: Build min release artifacts + defaults: + run: + working-directory: ./artifacts + strategy: + matrix: + include: + - name: Linux x64 + ext: tar.gz + suffix: linux-x64 + script: build-platform --linux --skip-os-packages + - name: Linux ARM64 + ext: tar.gz + suffix: linux-arm64 + script: build-platform --linux-arm --skip-os-packages + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + path: ./artifacts + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version-file: "./artifacts/.nvmrc" + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + + - name: Get package version + run: | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV + + - name: Get artifact build name + run: | + echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV + + - name: Run bootstrap + run: yarn osd bootstrap + + - name: Build `${{ matrix.name }}` + run: yarn ${{ matrix.script }} --release + + - uses: actions/upload-artifact@v3 + if: success() + with: + name: ${{ matrix.suffix }}-${{ env.VERSION }} + path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} + retention-days: 1 + + bwc-tests: + needs: [ build-min-artifact-tests ] + runs-on: ubuntu-latest + container: + image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 + options: --user 1001 + name: Run backwards compatibility tests + defaults: + run: + working-directory: ./artifacts + strategy: + matrix: + version: [ osd-1.3.2 ] + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + path: ./artifacts + + - run: echo Running backwards compatibility tests for version ${{ matrix.version }} + - run: echo [NOTE] These tests will be ran using Linux x64 release builds without security + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version-file: "./artifacts/.nvmrc" + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + + - name: Get package version + run: | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV + + - name: Set OpenSearch URL + run: | + echo "OPENSEARCH_URL=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch/opensearch-${{ env.VERSION }}-linux-x64.tar.gz" >> $GITHUB_ENV + + - name: Verify if OpenSearch is available for version + id: verify-opensearch-exists + run: | + if curl -I -L ${{ env.OPENSEARCH_URL }}; then + echo "::set-output name=version-exists::true" + fi + + - name: Skipping tests + if: steps.verify-opensearch-exists.outputs.version-exists != 'true' + run: echo Tests were skipped because an OpenSearch release build does not exist for this version yet! + + - name: Download OpenSearch Dashboards + uses: actions/download-artifact@v3 + id: download + with: + name: linux-x64-${{ env.VERSION }} + path: ./artifacts/ + if: steps.verify-opensearch-exists.outputs.version-exists == 'true' + + - name: Run tests + if: steps.verify-opensearch-exists.outputs.version-exists == 'true' + run: | + yarn test:bwc -s false -o ${{ env.OPENSEARCH_URL }} -d ${{ steps.download.outputs.download-path }}/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz -v ${{ matrix.version }} diff --git a/TESTING.md b/TESTING.md index daffd6065dd5..15c2792d3307 100644 --- a/TESTING.md +++ b/TESTING.md @@ -67,6 +67,12 @@ To run specific versions' backwards compatibility tests, pass the versions to th `yarn test:bwc -o [test path to opensearch.tar.gz] -d [test path to opensearch-dashboards.tar.gz] -v "[test versions]"` +To generate test data that will be utilized for backwards compatibility tests: + +`yarn test:bwc -o [test path to opensearch.tar.gz] -d [test path to opensearch-dashboards.tar.gz] -g true` + +This will create an archive of the data based on the OpenSearch Dashboards version you have provided. For example, if a tarball of 2.0.0 was passed then an `osd-2.0.0.zip` will be created. This command is intended to be executed when needed per a version. For example, when end-users cannot migrate directly from `vPrevious` to `vNext`. If `osd-vCurrent.zip` does not exist, then this command be ran and the output sourced controlled for future use. + ### Additional checks Make sure you run lint checker before submitting a pull request. To run lint checker: `node scripts/precommit_hook.js --fix` diff --git a/bwctest.sh b/bwctest.sh index 25ba57d52720..fc673ed1e1de 100755 --- a/bwctest.sh +++ b/bwctest.sh @@ -13,7 +13,7 @@ set -e -DEFAULT_VERSIONS="osd-1.1.0,odfe-1.13.2,odfe-1.0.2" +DEFAULT_VERSIONS="osd-1.3.2," function usage() { echo "" @@ -75,6 +75,7 @@ done [ -z "$SECURITY_ENABLED" ] && SECURITY_ENABLED="false" [ -z "$CREDENTIAL" ] && CREDENTIAL="admin:admin" [ -z "$CI" ] && CI=1 +[ -z "$BWC_VERSIONS" ] && BWC_VERSIONS=$DEFAULT_VERSIONS # If no OpenSearch build was passed then this constructs the version if [ -z "$OPENSEARCH" ]; then @@ -96,4 +97,4 @@ if [ -z "$OPENSEARCH" ]; then OPENSEARCH="https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/latest/$PLATFORM/$ARCH/tar/dist/opensearch/opensearch-$VERSION-$PLATFORM-$ARCH.tar.gz" fi -source scripts/bwctest_osd.sh -b $BIND_ADDRESS -p $BIND_PORT -s $SECURITY_ENABLED -c $CREDENTIAL -o $OPENSEARCH -d $DASHBOARDS -v $DEFAULT_VERSIONS +source scripts/bwctest_osd.sh -b $BIND_ADDRESS -p $BIND_PORT -s $SECURITY_ENABLED -c $CREDENTIAL -o $OPENSEARCH -d $DASHBOARDS -v $BWC_VERSIONS diff --git a/cypress/integration/with-security/check_loaded_data.js b/cypress/integration/with-security/check_loaded_data.js index cd173e4a90ba..ec4b1331b8ce 100644 --- a/cypress/integration/with-security/check_loaded_data.js +++ b/cypress/integration/with-security/check_loaded_data.js @@ -47,7 +47,9 @@ describe('check previously loaded data', () => { .get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') .click(); commonUI.removeAllFilters(); - commonUI.setDateRange('Dec 1, 2021 @ 00:00:00.000', 'Nov 1, 2021 @ 00:00:00.000'); + commonUI.setDateRange( + `Dec 31, ${new Date().getFullYear()} @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000` + ); }); it('Global Flight Dashboard is loaded and funtions correctly', () => { @@ -77,7 +79,9 @@ describe('check previously loaded data', () => { .get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') .click(); commonUI.removeAllFilters(); - commonUI.setDateRange('Nov 1, 2021 @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000'); + commonUI.setDateRange( + `Dec 31, ${new Date().getFullYear()} @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000` + ); }); it('eCommerce Revenue Dashboard is loaded and functions correctly', () => { diff --git a/cypress/integration/with-security/helpers/generate_data.js b/cypress/integration/with-security/helpers/generate_data.js new file mode 100755 index 000000000000..0790c8c771b5 --- /dev/null +++ b/cypress/integration/with-security/helpers/generate_data.js @@ -0,0 +1,86 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + MiscUtils, + LoginPage, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const loginPage = new LoginPage(cy); + +describe('Generating BWC test data with security', () => { + beforeEach(() => { + miscUtils.visitPage('app/management/opensearch-dashboards/settings'); + loginPage.enterUserName('admin'); + loginPage.enterPassword('admin'); + loginPage.submit(); + }); + + afterEach(() => { + cy.clearCookies(); + }); + + it('tenant-switch-modal page should show and be clicked', () => { + cy.get('[data-test-subj="tenant-switch-modal"]'); + cy.get('[data-test-subj="confirm"]').click(); + }); + + it('adds advanced settings', () => { + miscUtils.visitPage('app/management/opensearch-dashboards/settings'); + cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click(); + cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').type( + '{selectAll}4' + ); + cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type( + '{selectAll}4' + ); + cy.get('[data-test-subj="advancedSetting-editField-defaultRoute"]') + .clear() + .type('/app/opensearch_dashboards_overview#/'); + cy.get('[data-test-subj="advancedSetting-saveButton"]').click({ force: true }); + cy.reload(); + }); + + it('adds sample data', () => { + miscUtils.addSampleData(); + }); + + it('adds filters and queries', () => { + miscUtils.visitPage('app/dashboards#'); + cy.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]').click(); + cy.get('[data-test-subj="queryInput"]').clear().type('resp=200'); + cy.get('[data-test-subj="addFilter"]').click(); + cy.get('[data-test-subj="filterFieldSuggestionList"]') + .find('[data-test-subj="comboBoxInput"]') + .type('machine.os{downArrow}{enter}'); + cy.get('[data-test-subj="filterOperatorList"]') + .find('[data-test-subj="comboBoxInput"]') + .type('{downArrow}{enter}'); + cy.get('[data-test-subj="filterParams"]') + .find('input.euiFieldText[placeholder="Enter a value"]') + .type('osx'); + cy.get('[data-test-subj="createCustomLabel"]').click(); + cy.get('[class="globalFilterItem__editorForm"]').find('input').last().type('osx filter'); + cy.get('[data-test-subj="saveFilter"]').click(); + cy.get('[data-test-subj="saved-query-management-popover-button"]').click(); + cy.get('[data-test-subj="saved-query-management-popover"]') + .find('[data-test-subj="saved-query-management-save-button"]') + .click(); + cy.get('[data-test-subj="saveQueryFormTitle"]').type('test-query'); + cy.get('[data-test-subj="savedQueryFormSaveButton"]').click(); + }); + + it('adds Timeline visualization', () => { + miscUtils.visitPage('app/visualize#'); + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[data-test-subj="newItemButton"]') + .click(); + cy.get('[data-test-subj="visType-timelion"]').click(); + cy.get('[data-test-subj="visualizeSaveButton"]').click(); + cy.get('[data-test-subj="savedObjectTitle"]').type('test-timeline'); + cy.get('[data-test-subj="confirmSaveSavedObjectButton"]').click(); + }); +}); diff --git a/cypress/integration/without-security/check_loaded_data.js b/cypress/integration/without-security/check_loaded_data.js index 5a738c539ef2..4d2c2d3e4a31 100644 --- a/cypress/integration/without-security/check_loaded_data.js +++ b/cypress/integration/without-security/check_loaded_data.js @@ -38,7 +38,9 @@ describe('check previously loaded data', () => { .get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') .click(); commonUI.removeAllFilters(); - commonUI.setDateRange('Dec 1, 2021 @ 00:00:00.000', 'Nov 1, 2021 @ 00:00:00.000'); + commonUI.setDateRange( + `Dec 31, ${new Date().getFullYear()} @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000` + ); }); it('Global Flight Dashboard is loaded when clicked', () => { @@ -71,7 +73,9 @@ describe('check previously loaded data', () => { .get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') .click(); commonUI.removeAllFilters(); - commonUI.setDateRange('Nov 1, 2021 @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000'); + commonUI.setDateRange( + `Dec 31, ${new Date().getFullYear()} @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000` + ); }); it('eCommerce Revenue Dashboard is loaded when clicked', () => { diff --git a/cypress/integration/without-security/helpers/generate_data.js b/cypress/integration/without-security/helpers/generate_data.js new file mode 100755 index 000000000000..1dee48f1aab9 --- /dev/null +++ b/cypress/integration/without-security/helpers/generate_data.js @@ -0,0 +1,69 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); + +describe('Generating BWC test data without security', () => { + before(() => { + miscUtils.visitPage('app'); + }); + it('adds advanced settings', () => { + miscUtils.visitPage('app/management/opensearch-dashboards/settings'); + cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click(); + cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').type( + '{selectAll}4' + ); + cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type( + '{selectAll}4' + ); + cy.get('[data-test-subj="advancedSetting-editField-defaultRoute"]') + .clear() + .type('/app/opensearch_dashboards_overview#/'); + cy.get('[data-test-subj="advancedSetting-saveButton"]').click({ force: true }); + cy.reload(); + }); + + it('adds sample data', () => { + miscUtils.addSampleData(); + }); + + it('adds filters and queries', () => { + miscUtils.visitPage('app/dashboards#'); + cy.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]').click(); + cy.get('[data-test-subj="queryInput"]').clear().type('resp=200'); + cy.get('[data-test-subj="addFilter"]').click(); + cy.get('[data-test-subj="filterFieldSuggestionList"]') + .find('[data-test-subj="comboBoxInput"]') + .type('machine.os{downArrow}{enter}'); + cy.get('[data-test-subj="filterOperatorList"]') + .find('[data-test-subj="comboBoxInput"]') + .type('{downArrow}{enter}'); + cy.get('[data-test-subj="filterParams"]') + .find('input.euiFieldText[placeholder="Enter a value"]') + .type('osx'); + cy.get('[data-test-subj="createCustomLabel"]').click(); + cy.get('[class="globalFilterItem__editorForm"]').find('input').last().type('osx filter'); + cy.get('[data-test-subj="saveFilter"]').click(); + cy.get('[data-test-subj="saved-query-management-popover-button"]').click(); + cy.get('[data-test-subj="saved-query-management-popover"]') + .find('[data-test-subj="saved-query-management-save-button"]') + .click(); + cy.get('[data-test-subj="saveQueryFormTitle"]').type('test-query'); + cy.get('[data-test-subj="savedQueryFormSaveButton"]').click(); + }); + + it('adds Timeline visualization', () => { + miscUtils.visitPage('app/visualize#'); + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[data-test-subj="newItemButton"]') + .click(); + cy.get('[data-test-subj="visType-timelion"]').click(); + cy.get('[data-test-subj="visualizeSaveButton"]').click(); + cy.get('[data-test-subj="savedObjectTitle"]').type('test-timeline'); + cy.get('[data-test-subj="confirmSaveSavedObjectButton"]').click(); + }); +}); diff --git a/cypress/test-data/with-security/osd-1.3.2.tar.gz b/cypress/test-data/with-security/osd-1.3.2.tar.gz new file mode 100644 index 000000000000..59404619e30b Binary files /dev/null and b/cypress/test-data/with-security/osd-1.3.2.tar.gz differ diff --git a/cypress/test-data/with-security/osd-2.0.0.tar.gz b/cypress/test-data/with-security/osd-2.0.0.tar.gz new file mode 100755 index 000000000000..4809ae9810e2 Binary files /dev/null and b/cypress/test-data/with-security/osd-2.0.0.tar.gz differ diff --git a/cypress/test-data/without-security/osd-1.3.2.tar.gz b/cypress/test-data/without-security/osd-1.3.2.tar.gz new file mode 100644 index 000000000000..8a624041f047 Binary files /dev/null and b/cypress/test-data/without-security/osd-1.3.2.tar.gz differ diff --git a/cypress/test-data/without-security/osd-2.0.0.tar.gz b/cypress/test-data/without-security/osd-2.0.0.tar.gz new file mode 100755 index 000000000000..80164b4f6f7c Binary files /dev/null and b/cypress/test-data/without-security/osd-2.0.0.tar.gz differ diff --git a/dev-tools/get-version.sh b/dev-tools/get-version.sh new file mode 100755 index 000000000000..555dd89e9e9c --- /dev/null +++ b/dev-tools/get-version.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 + +set -e + +PACKAGE_VERSION=$(cat package.json \ +| grep version \ +| head -1 \ +| awk -F: '{ print $2 }' \ +| sed 's/[",]//g' \ +| tr -d [:space:]) + +echo "$PACKAGE_VERSION" \ No newline at end of file diff --git a/package.json b/package.json index 770d1a509b50..d6eeaa199610 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json", "docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept", "osd:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook", - "spec_to_console": "node scripts/spec_to_console" + "spec_to_console": "node scripts/spec_to_console", + "pkg-version": "./dev-tools/get-version.sh" }, "repository": { "type": "git", diff --git a/scripts/bwc/generate_test_data.sh b/scripts/bwc/generate_test_data.sh new file mode 100755 index 000000000000..53b8e4b7e6e8 --- /dev/null +++ b/scripts/bwc/generate_test_data.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 + +set -e + +function run_generate_data_spec() { + echo "[ Generating test data ]" + cd "$TEST_DIR" + [ "$CI" == '1' ] && cypress_args="--browser chromium" || cypress_args="" + SPEC_FILE="$TEST_DIR/cypress/integration/$DASHBOARDS_TYPE/helpers/generate_data.js" + env NO_COLOR=1 npx cypress run $cypress_args --headless --spec $SPEC_FILE || true +} + +function archive_data() { + echo "[ Archiving test data. Beep boo-boo, boo-boo bop ]" + PACKAGE_VERSION=$(get_dashboards_package_version) + cd "$OPENSEARCH_DIR" && tar -zcvf "osd-$PACKAGE_VERSION.tar.gz" data + cp "osd-$PACKAGE_VERSION.tar.gz" "$CWD/cypress/test-data/$DASHBOARDS_TYPE" + echo "[ Archive complete. Location: $CWD/cypress/test-data/$DASHBOARDS_TYPE/osd-$PACKAGE_VERSION.tar.gz' ]" +} \ No newline at end of file diff --git a/scripts/bwc/opensearch_dashboards_service.sh b/scripts/bwc/opensearch_dashboards_service.sh index e3016433b492..79f1c56708b4 100755 --- a/scripts/bwc/opensearch_dashboards_service.sh +++ b/scripts/bwc/opensearch_dashboards_service.sh @@ -27,6 +27,6 @@ function run_dashboards() { function check_dashboards_status { echo "Checking the OpenSearch Dashboards..." cd "$DIR" - check_status $DASHBOARDS_PATH "$DASHBOARDS_MSG" $DASHBOARDS_URL "" >> /dev/null 2>&1 + check_status $DASHBOARDS_PATH "$DASHBOARDS_MSG" $DASHBOARDS_URL "$OPENSEARCH_ARGS" >> /dev/null 2>&1 echo "OpenSearch Dashboards is up!" } diff --git a/scripts/bwc/utils.sh b/scripts/bwc/utils.sh index 5400a91a9ef4..fea47b14759a 100755 --- a/scripts/bwc/utils.sh +++ b/scripts/bwc/utils.sh @@ -67,3 +67,14 @@ function upload_data() { rm "$1.tar.gz" echo "Data has been uploaded and ready to test" } + +function get_dashboards_package_version() { + DASHBOARDS_PACKAGE_VERSION=$(cat $DASHBOARDS_DIR/package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d [:space:]) + + echo "$DASHBOARDS_PACKAGE_VERSION" +} diff --git a/scripts/bwctest_osd.sh b/scripts/bwctest_osd.sh index 084225956fe5..0f9b66533ed7 100755 --- a/scripts/bwctest_osd.sh +++ b/scripts/bwctest_osd.sh @@ -8,6 +8,7 @@ set -e . scripts/bwc/utils.sh . scripts/bwc/opensearch_service.sh . scripts/bwc/opensearch_dashboards_service.sh +. scripts/bwc/generate_test_data.sh # For every release, add sample data and new version below: DEFAULT_VERSIONS=( @@ -24,6 +25,8 @@ DEFAULT_VERSIONS=( "odfe-1.13.2" "osd-1.0.0" "osd-1.1.0" + "osd-1.3.2" + "osd-2.0.0" ) # Define test groups @@ -51,11 +54,12 @@ function usage() { echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." echo -e "-v VERSIONS\t, Specify versions as a CSV to execute tests with data from specific version of OpenSearch Dashboards." echo -e "-r RELEASES\t, Specify versions as a CSV to execute tests for released versions of OpenSearch." + echo -e "-g GENERATE_DATA\t(true | false), defaults to false. Specify to generate test data for BWC tests (will not execute tests)." echo -e "-h\tPrint this message." echo "--------------------------------------------------------------------------" } -while getopts ":h:b:p:s:c:v:r:o:d:" arg; do +while getopts ":h:b:p:s:c:v:r:g:o:d:" arg; do case $arg in h) usage @@ -79,6 +83,9 @@ while getopts ":h:b:p:s:c:v:r:o:d:" arg; do r) RELEASES=$OPTARG ;; + g) + GENERATE_DATA=$OPTARG + ;; o) OPENSEARCH=$OPTARG ;; @@ -104,6 +111,7 @@ done [ $SECURITY_ENABLED == "false" ] && DASHBOARDS_TYPE="without-security" || DASHBOARDS_TYPE="with-security" [ $SECURITY_ENABLED == "false" ] && RELEASES_ARRAY=() || IFS=',' read -r -a RELEASES_ARRAY <<<"$RELEASES" [ -z "$CREDENTIAL" ] && CREDENTIAL="admin:admin" +[ -z $GENERATE_DATA ] && GENERATE_DATA="false" TOTAL_TEST_FAILURES=0 # OpenSearch and OpenSearch Dashboards Process IDs @@ -162,6 +170,8 @@ TEST_SUITES=( ["odfe-1.13.2"]=$TEST_GROUP_4 ["osd-1.0.0"]=$TEST_GROUP_4 ["osd-1.1.0"]=$TEST_GROUP_4 + ["osd-1.3.2"]=$TEST_GROUP_4 + ["osd-2.0.0"]=$TEST_GROUP_4 ) # this function sets up the cypress env @@ -191,7 +201,7 @@ function run_cypress() { [ $IS_CORE == true ] && spec="$SPEC_FILES" || "$TEST_DIR/cypress/integration/$DASHBOARDS_TYPE/plugins/*.js" [ $IS_CORE == true ] && success_msg="BWC tests for core passed ($spec)" || success_msg="BWC tests for plugin passed ($spec)" [ $IS_CORE == true ] && error_msg="BWC tests for core failed ($spec)" || error_msg="BWC tests for plugin failed ($spec)" - [ $CI == 1 ] && cypress_args="--browser chromium" || cypress_args="" + [ "$CI" == '1' ] && cypress_args="--browser chromium" || cypress_args="" env NO_COLOR=1 npx cypress run $cypress_args --headless --spec $spec || test_failures=$? [ -z $test_failures ] && test_failures=0 [ $test_failures == 0 ] && echo $success_msg || echo "$error_msg::TEST_FAILURES: $test_failures" @@ -213,6 +223,23 @@ function run_bwc() { fi } +# generate test data +function generate_test_data() { + setup_opensearch >> /dev/null 2>&1 & + setup_dashboards >> /dev/null 2>&1 & + + run_opensearch + check_opensearch_status + run_dashboards + check_dashboards_status + + run_generate_data_spec + archive_data + + # kill the running OpenSearch process + clean +} + # Main function function execute_tests() { setup_opensearch >> /dev/null 2>&1 & @@ -243,12 +270,7 @@ function execute_tests() { # Executes the main function with different versions of OpenSearch downloaded function execute_mismatch_tests() { - PACKAGE_VERSION=$(cat $DASHBOARDS_DIR/package.json \ - | grep version \ - | head -1 \ - | awk -F: '{ print $2 }' \ - | sed 's/[",]//g' \ - | tr -d [:space:]) + PACKAGE_VERSION=$(get_dashboards_package_version) for release in "${RELEASES_ARRAY[@]}" do @@ -264,6 +286,12 @@ function execute_mismatch_tests() { # setup the cypress test env [ ! -d "$TEST_DIR/cypress" ] && setup_cypress +if [ $GENERATE_DATA == "true" ]; then + generate_test_data + echo "Generate data complete" + exit 0 +fi + execute_tests (( ${#RELEASES_ARRAY[@]} )) && execute_mismatch_tests echo "Completed BWC tests for $TEST_VERSIONS [$DASHBOARDS_TYPE]"