diff --git a/.eslintrc.js b/.eslintrc.js index b2e07ec15724..16a2cb421387 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -743,5 +743,12 @@ module.exports = { ], }, }, + { + files: ['cypress/**/*.js'], + rules: { + 'import/no-unresolved': 'off', + 'no-undef': 'off', + }, + }, ], }; diff --git a/.gitignore b/.gitignore index 2ce3f5d31091..d516495bceba 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ trash /built_assets target /build +/bwc_tmp .jruby .idea *.iml diff --git a/TESTING.md b/TESTING.md index 5f5e54735c4f..67d26e482184 100644 --- a/TESTING.md +++ b/TESTING.md @@ -53,13 +53,13 @@ Say that you would want to debug a test in CI group 1, you can run the following This will print off an address, to which you could open your chrome browser on your instance and navigate to `chrome://inspect/#devices` and inspect the functional test runner `scripts/functional_tests.js`. ### Backwards Compatibility tests -To run all the backwards compatibility tests on vanilla OpenSearch Dashboards: +To run all the backwards compatibility tests on OpenSearch Dashboards without security: `yarn test:bwc -o [test path to opensearch.tar.gz] -d [test path to opensearch-dashboards.tar.gz]` -To run all the backwards compatibility tests on bundled dashboards, pass the bundle parameter to the test: +To run all the backwards compatibility tests on OpenSearch Dashboards with security, pass the security parameter to the test: -`yarn test:bwc -o [test path to opensearch.tar.gz] -d [test path to opensearch-dashboards.tar.gz] -b true` +`yarn test:bwc -o [test path to opensearch.tar.gz] -d [test path to opensearch-dashboards.tar.gz] -s true` To run specific versions' backwards compatibility tests, pass the versions to the test: diff --git a/bwctest.sh b/bwctest.sh old mode 100644 new mode 100755 index 3bf9b3527fbd..74f14e0a7484 --- a/bwctest.sh +++ b/bwctest.sh @@ -2,6 +2,9 @@ set -e +# TODO: Update to include all known BWC of data +DEFAULT_VERSIONS="osd-1.1.0" + function usage() { echo "" echo "This script is used to run bwc tests on a remote OpenSearch/Dashboards cluster." @@ -9,35 +12,42 @@ function usage() { echo "Usage: $0 [args]" echo "" echo "Required arguments:" - echo "None" + echo -e "-d DASHBOARDS\t, Specify the url of the build/dist of OpenSearch Dashboards" echo "" echo "Optional arguments:" - echo -e "-a BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." + echo -e "-o OPENSEARCH\t, Specify the url of the build/dist of OpenSearch" + echo -e "-b BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." echo -e "-p BIND_PORT\t, defaults to 9200 or 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location." - echo -e "-b BUNDLED_OSD\t(true | false), defaults to true. Specify the usage of bundled Dashboards or not." + echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not." echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." echo -e "-h\tPrint this message." echo "--------------------------------------------------------------------------" } -while getopts ":ha:p:b:c:" arg; do +while getopts ":h:b:p:s:c:o:d:" arg; do case $arg in h) usage exit 1 ;; - a) + b) BIND_ADDRESS=$OPTARG ;; p) BIND_PORT=$OPTARG ;; - b) - BUNDLED_OSD=$OPTARG + s) + SECURITY_ENABLED=$OPTARG ;; c) CREDENTIAL=$OPTARG ;; + o) + OPENSEARCH=$OPTARG + ;; + d) + DASHBOARDS=$OPTARG + ;; :) echo "-${OPTARG} requires an argument" usage @@ -50,50 +60,27 @@ while getopts ":ha:p:b:c:" arg; do esac done +[ -z "$BIND_ADDRESS" ] && BIND_ADDRESS="localhost" +[ -z "$BIND_PORT" ] && BIND_PORT="5601" +[ -z "$SECURITY_ENABLED" ] && SECURITY_ENABLED="false" +[ -z "$CREDENTIAL" ] && CREDENTIAL="admin:admin" -if [ -z "$BIND_ADDRESS" ] -then - BIND_ADDRESS="localhost" -fi - -if [ -z "$BIND_PORT" ] -then - BIND_PORT="5601" -fi - -if [ -z "$BUNDLED_OSD" ] -then - BUNDLED_OSD="true" -fi - -if [ -z "$CREDENTIAL" ] -then - CREDENTIAL="admin:admin" - USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` - PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` -fi - -cwd=$(pwd) -dir="bwc-tmp" -if [ -d "$dir" ]; then - rm -rf "$dir" - echo "bwc-tmp exists and needs to be removed" -fi - -mkdir "$dir" -git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test "$dir" -rm -rf "$dir/cypress" -cp -r cypress "$dir" -cd "$dir" - -npm install +# If no OpenSearch build was passed then this constructs the version +if [ -z "$OPENSEARCH" ]; then + IFS='/' read -ra SLASH_ARR <<< "$DASHBOARDS" + # Expected to be opensearch-x.y.z-platform-arch.tar.gz + TARBALL="${SLASH_ARR[12]}" + IFS='-' read -ra DASH_ARR <<< "$TARBALL" + # Expected to be arch.tar.gz + DOTS="${DASH_ARR[4]}" + IFS='.' read -ra DOTS_ARR <<< "$DOTS" + + VERSION="${DASH_ARR[2]}" + PLATFORM="${DASH_ARR[3]}" + ARCH="${DOTS_ARR[0]}" -if [ $BUNDLED_OSD = "true" ] -then - echo "run security enabled tests" - npx cypress run --spec "$cwd/bwc-tmp/cypress/integration/bundled-osd/*.js" -else - npx cypress run --spec "$cwd/bwc-tmp/cypress/integration/osd/*.js" + # TODO: Replace '676' with -latest from distributions + OPENSEARCH="https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/676/$PLATFORM/$ARCH/dist/opensearch/opensearch-$VERSION-$PLATFORM-$ARCH.tar.gz" fi -rm -rf "$cwd/$dir" \ No newline at end of file +./scripts/bwctest_osd.sh -b $BIND_ADDRESS -p $BIND_PORT -s $SECURITY_ENABLED -c $CREDENTIAL -o $OPENSEARCH -d $DASHBOARDS -v $DEFAULT_VERSIONS diff --git a/cypress/integration/osd-bundle/check_loaded_data.js b/cypress/integration/osd-bundle/check_loaded_data.js deleted file mode 100644 index 34f0ac545688..000000000000 --- a/cypress/integration/osd-bundle/check_loaded_data.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/* eslint-disable */ -import { MiscUtils, CommonUI, LoginPage } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - -const miscUtils = new MiscUtils(cy); -const commonUI = new CommonUI(cy); -const loginPage = new LoginPage(cy); - -describe('check previously loaded data', () => { - beforeEach(() => { - miscUtils.visitPage('app/dashboards#'); - loginPage.enterUserName('admin'); - loginPage.enterPassword('admin'); - loginPage.submit(); - }); - - afterEach(() => { - cy.clearCookies(); - }); - - it('previous loaded data should exist in dashboards', () => { - let items = cy.get('[data-test-subj="itemsInMemTable"]'); - - items.get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') - .should('have.text', '[Flights] Global Flight Dashboard'); - - items.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]') - .should('have.text', '[Logs] Web Traffic'); - - items.get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') - .should('have.text', '[eCommerce] Revenue Dashboard'); - }); - - describe('Check Global Flight Dashboard', () => { - beforeEach(() => { - cy.get('[data-test-subj="itemsInMemTable"]') - .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') - }); - - it('Global Flight Dashboard is loaded and funtions correctly', () => { - cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[Flights] Global Flight Dashboard'); - cy.get('[data-title="[Flights] Total Flights"]').should('exist'); - cy.get('[data-title="[Flights] Average Ticket Price"]').should('exist'); - - commonUI.addFilterRetrySelection('FlightDelayType', 'is not', 'No Delay'); - let types = cy.get('[data-title="[Flights] Delay Type"]') - types.find('[data-label="Weather Delay"]').should('exist'); - types.find('[data-label="No Delay"]').should('not.exist'); ; - commonUI.removeFilter('FlightDelayType'); - - commonUI.addFilterRetrySelection('Carrier', 'is', 'Logstash Airways'); - cy.get('[data-title="[Flights] Airline Carrier"]') - .find('[class="label-text"]') - .should('have.text', 'Logstash Airways (100%)'); - }); - }); - - describe('Check eCommerce Revenue Dashboard', () => { - beforeEach(() => { - cy.get('[data-test-subj="itemsInMemTable"]') - .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') - }); - - it('eCommerce Revenue Dashboard is loaded and functions correctly', () => { - cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[eCommerce] Revenue Dashboard'); - cy.get('[data-title="[eCommerce] Average Sales Price"]').should('exist'); - cy.get('[data-title="[eCommerce] Average Sold Quantity"]').should('exist'); - - commonUI.addFilterRetrySelection('customer_gender', 'is', 'FEMALE'); - cy.get('[data-title="[eCommerce] Sales by Gender"]') - .find('[class="label-text"]') - .should('have.text', 'FEMALE (100%)'); - - commonUI.addFilterRetrySelection('category', 'is not', "Women's Clothing"); - let category = cy.get('[data-title="[eCommerce] Sales by Category"]') - category.find('[data-label="Men\'s Clothing"]').should('exist'); - category.find('[data-label="Women\'s Clothing"]').should('not.exist'); - }); - }); -}); \ No newline at end of file diff --git a/cypress/integration/osd-bundle/check_timeline.js b/cypress/integration/osd-bundle/check_timeline.js deleted file mode 100644 index e0639d3b917a..000000000000 --- a/cypress/integration/osd-bundle/check_timeline.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/* eslint-disable */ -import { MiscUtils, LoginPage } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - -const miscUtils = new MiscUtils(cy); -const loginPage = new LoginPage(cy); - -describe('check timeline visualization', () => { - beforeEach(() => { - miscUtils.visitPage('app/visualize#'); - 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('timeline visualizations should be saved and named correctly', () => { - cy.get('[data-test-subj="visualizationLandingPage"]') - .find('[class="euiFormControlLayout__childrenWrapper"]') - .type('timeline'); - cy.get('[data-test-subj="visListingTitleLink-test-timeline"]').should('have.text', 'test-timeline').click(); - cy.get('[class="view-line"]').contains('.es(*)'); - }); - - describe('timeline visualizations should work properly', () => { - beforeEach(() => { - cy.get('[data-test-subj="visualizationLandingPage"]') - .find('[data-test-subj="newItemButton"]') - .click(); - cy.get('[data-test-subj="visType-timelion"]').click(); - }); - - it('.es(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.es(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.es(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.elasticsearch(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.elasticsearch(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.opensearch(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.opensearch(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.opensearch(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - }); -}); \ No newline at end of file diff --git a/cypress/integration/osd/check_loaded_data.js b/cypress/integration/osd/check_loaded_data.js deleted file mode 100644 index 9439affa702b..000000000000 --- a/cypress/integration/osd/check_loaded_data.js +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/* eslint-disable */ -import { MiscUtils, CommonUI } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - -const miscUtils = new MiscUtils(cy); -const commonUI = new CommonUI(cy); - -describe('check previously loaded data', () => { - beforeEach(() => { - miscUtils.visitPage('app/dashboards#'); - }); - - it('previous loaded data should exist in dashboards', () => { - let items = cy.get('[data-test-subj="itemsInMemTable"]'); - - items.get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') - .should('have.text', '[Flights] Global Flight Dashboard'); - - items.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]') - .should('have.text', '[Logs] Web Traffic'); - - items.get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') - .should('have.text', '[eCommerce] Revenue Dashboard'); - }); - - describe('Global Flight Dashboard should function properly', () => { - beforeEach(() => { - cy.get('[data-test-subj="itemsInMemTable"]') - .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'); - }); - - it('Global Flight Dashboard is loaded when clicked', () => { - cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[Flights] Global Flight Dashboard'); - cy.get('[data-title="[Flights] Total Flights"]').should('exist'); - cy.get('[data-title="[Flights] Average Ticket Price"]').should('exist'); - }); - - it('If set filter for carrier, [Flights] Airline Carrier should show correct carrier', () => { - commonUI.addFilterRetrySelection('Carrier', 'is', 'Logstash Airways'); - cy.get('[data-title="[Flights] Airline Carrier"]') - .find('[class="label-text"]') - .should('have.text', 'Logstash Airways (100%)'); - }); - - it('If set filter for FlightDelayType, [Flights] Delay Type should filter out selected type', () => { - commonUI.addFilterRetrySelection('FlightDelayType', 'is not', 'No Delay'); - let types = cy.get('[data-title="[Flights] Delay Type"]') - types.find('[data-label="Weather Delay"]').should('exist'); - types.find('[data-label="No Delay"]').should('not.exist'); ; - }); - }); - - describe('eCommerce Revenue Dashboard should function properly', () => { - beforeEach(() => { - cy.get('[data-test-subj="itemsInMemTable"]') - .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'); - }); - - it('eCommerce Revenue Dashboard is loaded when clicked', () => { - cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[eCommerce] Revenue Dashboard'); - cy.get('[data-title="[eCommerce] Average Sales Price"]').should('exist'); - cy.get('[data-title="[eCommerce] Average Sold Quantity"]').should('exist'); - }); - - it('If set filter for gender, [eCommerce] Sales by Gender should show one gender', () => { - commonUI.addFilterRetrySelection('customer_gender', 'is', 'FEMALE'); - cy.get('[data-title="[eCommerce] Sales by Gender"]') - .find('[class="label-text"]') - .should('have.text', 'FEMALE (100%)'); - }) - - it('If filter out Women\'s Clothing, [eCommerce] Sales by Category should not show this category', () => { - commonUI.addFilterRetrySelection('category', 'is not', "Women's Clothing"); - let category = cy.get('[data-title="[eCommerce] Sales by Category"]') - category.find('[data-label="Men\'s Clothing"]').should('exist'); - category.find('[data-label="Women\'s Clothing"]').should('not.exist'); - }); - }); -}); \ No newline at end of file diff --git a/cypress/integration/osd/check_timeline.js b/cypress/integration/osd/check_timeline.js deleted file mode 100644 index dd7ca2d3f495..000000000000 --- a/cypress/integration/osd/check_timeline.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/* eslint-disable */ -import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - -const miscUtils = new MiscUtils(cy); - -describe('check timeline visualization', () => { - beforeEach(() => { - miscUtils.visitPage('app/visualize#'); - }); - - it('timeline visualizations should be saved and named correctly', () => { - cy.get('[data-test-subj="visualizationLandingPage"]') - .find('[class="euiFormControlLayout__childrenWrapper"]') - .type('timeline'); - cy.get('[data-test-subj="visListingTitleLink-test-timeline"]').should('have.text', 'test-timeline').click(); - cy.get('[class="view-line"]').contains('.es(*)'); - }); - - describe('timeline visualizations should work properly', () => { - beforeEach(() => { - cy.get('[data-test-subj="visualizationLandingPage"]') - .find('[data-test-subj="newItemButton"]') - .click(); - cy.get('[data-test-subj="visType-timelion"]').click(); - }); - - it('.es(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.es(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.es(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.elasticsearch(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.elasticsearch(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.opensearch(*, kibana1=true) should report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') - }); - - it('.opensearch(*, kibana=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - - it('.opensearch(*, opensearchDashboards=true) should not report search error', () => { - cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)'); - cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); - cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') - }); - }); -}); \ No newline at end of file diff --git a/cypress/integration/osd-bundle/check_advanced_settings.js b/cypress/integration/with-security/check_advanced_settings.js similarity index 98% rename from cypress/integration/osd-bundle/check_advanced_settings.js rename to cypress/integration/with-security/check_advanced_settings.js index 12d4e56b1768..502ee150a33f 100644 --- a/cypress/integration/osd-bundle/check_advanced_settings.js +++ b/cypress/integration/with-security/check_advanced_settings.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ import { MiscUtils, LoginPage, diff --git a/cypress/integration/osd-bundle/check_default_page.js b/cypress/integration/with-security/check_default_page.js similarity index 96% rename from cypress/integration/osd-bundle/check_default_page.js rename to cypress/integration/with-security/check_default_page.js index 469b80014bda..43a1c059ed9b 100644 --- a/cypress/integration/osd-bundle/check_default_page.js +++ b/cypress/integration/with-security/check_default_page.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ import { MiscUtils, LoginPage, diff --git a/cypress/integration/osd-bundle/check_filter_and_query.js b/cypress/integration/with-security/check_filter_and_query.js similarity index 99% rename from cypress/integration/osd-bundle/check_filter_and_query.js rename to cypress/integration/with-security/check_filter_and_query.js index 04b415a5aeb1..0055e5c078ed 100644 --- a/cypress/integration/osd-bundle/check_filter_and_query.js +++ b/cypress/integration/with-security/check_filter_and_query.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ import { MiscUtils, CommonUI, diff --git a/cypress/integration/with-security/check_loaded_data.js b/cypress/integration/with-security/check_loaded_data.js new file mode 100644 index 000000000000..cd173e4a90ba --- /dev/null +++ b/cypress/integration/with-security/check_loaded_data.js @@ -0,0 +1,102 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + MiscUtils, + CommonUI, + LoginPage, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const commonUI = new CommonUI(cy); +const loginPage = new LoginPage(cy); + +describe('check previously loaded data', () => { + beforeEach(() => { + miscUtils.visitPage('app/dashboards#'); + loginPage.enterUserName('admin'); + loginPage.enterPassword('admin'); + loginPage.submit(); + }); + + afterEach(() => { + cy.clearCookies(); + }); + + it('previous loaded data should exist in dashboards', () => { + const items = cy.get('[data-test-subj="itemsInMemTable"]'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') + .should('have.text', '[Flights] Global Flight Dashboard'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]') + .should('have.text', '[Logs] Web Traffic'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') + .should('have.text', '[eCommerce] Revenue Dashboard'); + }); + + describe('Check Global Flight Dashboard', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .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'); + }); + + it('Global Flight Dashboard is loaded and funtions correctly', () => { + cy.get('[data-test-subj="breadcrumb last"]').should( + 'have.text', + '[Flights] Global Flight Dashboard' + ); + cy.get('[data-title="[Flights] Total Flights"]').should('exist'); + cy.get('[data-title="[Flights] Average Ticket Price"]').should('exist'); + + commonUI.addFilterRetrySelection('FlightDelayType', 'is not', 'No Delay'); + const types = cy.get('[data-title="[Flights] Delay Type"]'); + types.find('[data-label="Weather Delay"]').should('exist'); + types.find('[data-label="No Delay"]').should('not.exist'); + commonUI.removeFilter('FlightDelayType'); + + commonUI.addFilterRetrySelection('Carrier', 'is', 'Logstash Airways'); + cy.get('[data-title="[Flights] Airline Carrier"]') + .find('[class="label-text"]') + .should('have.text', 'Logstash Airways (100%)'); + }); + }); + + describe('Check eCommerce Revenue Dashboard', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .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'); + }); + + it('eCommerce Revenue Dashboard is loaded and functions correctly', () => { + cy.get('[data-test-subj="breadcrumb last"]').should( + 'have.text', + '[eCommerce] Revenue Dashboard' + ); + cy.get('[data-title="[eCommerce] Average Sales Price"]').should('exist'); + cy.get('[data-title="[eCommerce] Average Sold Quantity"]').should('exist'); + + commonUI.addFilterRetrySelection('customer_gender', 'is', 'FEMALE'); + cy.get('[data-title="[eCommerce] Sales by Gender"]') + .find('[class="label-text"]') + .should('have.text', 'FEMALE (100%)'); + + commonUI.addFilterRetrySelection('category', 'is not', "Women's Clothing"); + const category = cy.get('[data-title="[eCommerce] Sales by Category"]'); + category.find('[data-label="Men\'s Clothing"]').should('exist'); + category.find('[data-label="Women\'s Clothing"]').should('not.exist'); + }); + }); +}); diff --git a/cypress/integration/with-security/check_timeline.js b/cypress/integration/with-security/check_timeline.js new file mode 100644 index 000000000000..2cd6401edc13 --- /dev/null +++ b/cypress/integration/with-security/check_timeline.js @@ -0,0 +1,133 @@ +/* + * 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('check timeline visualization', () => { + beforeEach(() => { + miscUtils.visitPage('app/visualize#'); + 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('timeline visualizations should be saved and named correctly', () => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[class="euiFormControlLayout__childrenWrapper"]') + .type('timeline'); + cy.get('[data-test-subj="visListingTitleLink-test-timeline"]') + .should('have.text', 'test-timeline') + .click(); + cy.get('[class="view-line"]').contains('.es(*)'); + }); + + describe('timeline visualizations should work properly', () => { + beforeEach(() => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[data-test-subj="newItemButton"]') + .click(); + cy.get('[data-test-subj="visType-timelion"]').click(); + }); + + it('.es(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.es(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.es(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.elasticsearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.elasticsearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.opensearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.opensearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.opensearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + }); +}); diff --git a/cypress/integration/with-security/plugins/.gitignore b/cypress/integration/with-security/plugins/.gitignore new file mode 100644 index 000000000000..86d0cb2726c6 --- /dev/null +++ b/cypress/integration/with-security/plugins/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/cypress/integration/osd/check_advanced_settings.js b/cypress/integration/without-security/check_advanced_settings.js similarity index 96% rename from cypress/integration/osd/check_advanced_settings.js rename to cypress/integration/without-security/check_advanced_settings.js index 7a7d5f535ac8..474a8178441a 100644 --- a/cypress/integration/osd/check_advanced_settings.js +++ b/cypress/integration/without-security/check_advanced_settings.js @@ -3,33 +3,32 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - + const miscUtils = new MiscUtils(cy); - + describe('verify the advanced settings are saved', () => { beforeEach(() => { miscUtils.visitPage('app/management/opensearch-dashboards/settings'); }); - + it('the dark mode is on', () => { cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]') .invoke('attr', 'aria-checked') .should('eq', 'true'); }); - + it('the Timeline default columns field is set to 4', () => { cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').should( 'have.value', 4 ); }); - + it('the Timeline Maximum buckets field is set to 4', () => { cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').should( 'have.value', 4 ); }); -}); \ No newline at end of file +}); diff --git a/cypress/integration/osd/check_default_page.js b/cypress/integration/without-security/check_default_page.js similarity index 93% rename from cypress/integration/osd/check_default_page.js rename to cypress/integration/without-security/check_default_page.js index 20af7440b027..390628046cc1 100644 --- a/cypress/integration/osd/check_default_page.js +++ b/cypress/integration/without-security/check_default_page.js @@ -3,17 +3,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - + const miscUtils = new MiscUtils(cy); - + describe('verify default landing page work for bwc', () => { beforeEach(() => { miscUtils.visitPage(''); }); - + it('the overview page is set as the default landing page', () => { cy.url().should('include', '/app/opensearch_dashboards_overview#/'); }); -}); \ No newline at end of file +}); diff --git a/cypress/integration/osd/check_filter_and_query.js b/cypress/integration/without-security/check_filter_and_query.js similarity index 93% rename from cypress/integration/osd/check_filter_and_query.js rename to cypress/integration/without-security/check_filter_and_query.js index 8847192b2863..30911d05ba7e 100644 --- a/cypress/integration/osd/check_filter_and_query.js +++ b/cypress/integration/without-security/check_filter_and_query.js @@ -3,21 +3,23 @@ * SPDX-License-Identifier: Apache-2.0 */ -/* eslint-disable */ -import { MiscUtils, CommonUI } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; - +import { + MiscUtils, + CommonUI, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + const miscUtils = new MiscUtils(cy); const commonUI = new CommonUI(cy); - + describe('check dashboards filter and query', () => { beforeEach(() => { miscUtils.visitPage('app/dashboards#'); }); - + afterEach(() => { cy.clearCookies(); }); - + describe('osx filter and query should work in [Logs] Web Traffic dashboards', () => { beforeEach(() => { cy.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]').click(); @@ -25,7 +27,7 @@ describe('check dashboards filter and query', () => { .invoke('attr', 'title') .should('eq', '[Logs] Web Traffic'); }); - + it('osx filter and query should exist and be named correctly', () => { cy.get('[data-test-subj="saved-query-management-popover-button"]').click(); cy.get('[data-test-subj="saved-query-management-popover"]') @@ -47,24 +49,24 @@ describe('check dashboards filter and query', () => { .should('have.text', 'is'); cy.get('[data-test-subj="filterParams"]').find('input').should('have.value', 'osx'); }); - + it('osx filter and query should function correctly', () => { cy.get('[data-test-subj="saved-query-management-popover-button"]').click(); cy.get('[data-test-subj="saved-query-management-popover"]') .find('[class="osdSavedQueryListItem__labelText"]') .should('have.text', 'test-query') .click(); - commonUI.setDateRange('Dec 1, 2021 @ 00:00:00.000', 'Jan 1, 2021 @ 00:00:00.000'); - + commonUI.setDateRange('Dec 1, 2021 @ 00:00:00.000', 'Jan 1, 2021 @ 00:00:00.000'); + //[Logs] vistor chart should show osx 100% cy.get('[data-title="[Logs] Visitors by OS"]') .find('[class="label"]') .should('have.text', 'osx (100%)'); - + //[Logs] Response chart should show 200 label cy.get('[data-title="[Logs] Response Codes Over Time + Annotations"]') .find('[title="200"]') .should('have.text', '200'); }); }); -}); \ No newline at end of file +}); diff --git a/cypress/integration/without-security/check_loaded_data.js b/cypress/integration/without-security/check_loaded_data.js new file mode 100644 index 000000000000..5a738c539ef2 --- /dev/null +++ b/cypress/integration/without-security/check_loaded_data.js @@ -0,0 +1,100 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + MiscUtils, + CommonUI, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const commonUI = new CommonUI(cy); + +describe('check previously loaded data', () => { + beforeEach(() => { + miscUtils.visitPage('app/dashboards#'); + }); + + it('previous loaded data should exist in dashboards', () => { + const items = cy.get('[data-test-subj="itemsInMemTable"]'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') + .should('have.text', '[Flights] Global Flight Dashboard'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]') + .should('have.text', '[Logs] Web Traffic'); + + items + .get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') + .should('have.text', '[eCommerce] Revenue Dashboard'); + }); + + describe('Global Flight Dashboard should function properly', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .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'); + }); + + it('Global Flight Dashboard is loaded when clicked', () => { + cy.get('[data-test-subj="breadcrumb last"]').should( + 'have.text', + '[Flights] Global Flight Dashboard' + ); + cy.get('[data-title="[Flights] Total Flights"]').should('exist'); + cy.get('[data-title="[Flights] Average Ticket Price"]').should('exist'); + }); + + it('If set filter for carrier, [Flights] Airline Carrier should show correct carrier', () => { + commonUI.addFilterRetrySelection('Carrier', 'is', 'Logstash Airways'); + cy.get('[data-title="[Flights] Airline Carrier"]') + .find('[class="label-text"]') + .should('have.text', 'Logstash Airways (100%)'); + }); + + it('If set filter for FlightDelayType, [Flights] Delay Type should filter out selected type', () => { + commonUI.addFilterRetrySelection('FlightDelayType', 'is not', 'No Delay'); + const types = cy.get('[data-title="[Flights] Delay Type"]'); + types.find('[data-label="Weather Delay"]').should('exist'); + types.find('[data-label="No Delay"]').should('not.exist'); + }); + }); + + describe('eCommerce Revenue Dashboard should function properly', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .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'); + }); + + it('eCommerce Revenue Dashboard is loaded when clicked', () => { + cy.get('[data-test-subj="breadcrumb last"]').should( + 'have.text', + '[eCommerce] Revenue Dashboard' + ); + cy.get('[data-title="[eCommerce] Average Sales Price"]').should('exist'); + cy.get('[data-title="[eCommerce] Average Sold Quantity"]').should('exist'); + }); + + it('If set filter for gender, [eCommerce] Sales by Gender should show one gender', () => { + commonUI.addFilterRetrySelection('customer_gender', 'is', 'FEMALE'); + cy.get('[data-title="[eCommerce] Sales by Gender"]') + .find('[class="label-text"]') + .should('have.text', 'FEMALE (100%)'); + }); + + it("If filter out Women's Clothing, [eCommerce] Sales by Category should not show this category", () => { + commonUI.addFilterRetrySelection('category', 'is not', "Women's Clothing"); + const category = cy.get('[data-title="[eCommerce] Sales by Category"]'); + category.find('[data-label="Men\'s Clothing"]').should('exist'); + category.find('[data-label="Women\'s Clothing"]').should('not.exist'); + }); + }); +}); diff --git a/cypress/integration/without-security/check_timeline.js b/cypress/integration/without-security/check_timeline.js new file mode 100644 index 000000000000..fe97f6c01c1d --- /dev/null +++ b/cypress/integration/without-security/check_timeline.js @@ -0,0 +1,117 @@ +/* + * 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('check timeline visualization', () => { + beforeEach(() => { + miscUtils.visitPage('app/visualize#'); + }); + + it('timeline visualizations should be saved and named correctly', () => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[class="euiFormControlLayout__childrenWrapper"]') + .type('timeline'); + cy.get('[data-test-subj="visListingTitleLink-test-timeline"]') + .should('have.text', 'test-timeline') + .click(); + cy.get('[class="view-line"]').contains('.es(*)'); + }); + + describe('timeline visualizations should work properly', () => { + beforeEach(() => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[data-test-subj="newItemButton"]') + .click(); + cy.get('[data-test-subj="visType-timelion"]').click(); + }); + + it('.es(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.es(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.es(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.elasticsearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.elasticsearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.opensearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .contains('Timeline request error: undefined Error: Unknown argument to es: kibana1'); + }); + + it('.opensearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + + it('.opensearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type( + '{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)' + ); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]') + .find('[data-test-subj="errorToastMessage"]') + .should('not.exist'); + }); + }); +}); diff --git a/cypress/integration/without-security/plugins/.gitignore b/cypress/integration/without-security/plugins/.gitignore new file mode 100644 index 000000000000..86d0cb2726c6 --- /dev/null +++ b/cypress/integration/without-security/plugins/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/cypress/test-data/osd-bundle/odfe-0.10.0.tar.gz b/cypress/test-data/with-security/odfe-0.10.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-0.10.0.tar.gz rename to cypress/test-data/with-security/odfe-0.10.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.0.2.tar.gz b/cypress/test-data/with-security/odfe-1.0.2.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.0.2.tar.gz rename to cypress/test-data/with-security/odfe-1.0.2.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.1.0.tar.gz b/cypress/test-data/with-security/odfe-1.1.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.1.0.tar.gz rename to cypress/test-data/with-security/odfe-1.1.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.11.0.tar.gz b/cypress/test-data/with-security/odfe-1.11.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.11.0.tar.gz rename to cypress/test-data/with-security/odfe-1.11.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.13.2.tar.gz b/cypress/test-data/with-security/odfe-1.13.2.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.13.2.tar.gz rename to cypress/test-data/with-security/odfe-1.13.2.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.2.1.tar.gz b/cypress/test-data/with-security/odfe-1.2.1.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.2.1.tar.gz rename to cypress/test-data/with-security/odfe-1.2.1.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.3.0.tar.gz b/cypress/test-data/with-security/odfe-1.3.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.3.0.tar.gz rename to cypress/test-data/with-security/odfe-1.3.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.4.0.tar.gz b/cypress/test-data/with-security/odfe-1.4.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.4.0.tar.gz rename to cypress/test-data/with-security/odfe-1.4.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.7.0.tar.gz b/cypress/test-data/with-security/odfe-1.7.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.7.0.tar.gz rename to cypress/test-data/with-security/odfe-1.7.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.8.0.tar.gz b/cypress/test-data/with-security/odfe-1.8.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.8.0.tar.gz rename to cypress/test-data/with-security/odfe-1.8.0.tar.gz diff --git a/cypress/test-data/osd-bundle/odfe-1.9.0.tar.gz b/cypress/test-data/with-security/odfe-1.9.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/odfe-1.9.0.tar.gz rename to cypress/test-data/with-security/odfe-1.9.0.tar.gz diff --git a/cypress/test-data/osd-bundle/osd-1.0.0.tar.gz b/cypress/test-data/with-security/osd-1.0.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/osd-1.0.0.tar.gz rename to cypress/test-data/with-security/osd-1.0.0.tar.gz diff --git a/cypress/test-data/osd-bundle/osd-1.1.0.tar.gz b/cypress/test-data/with-security/osd-1.1.0.tar.gz similarity index 100% rename from cypress/test-data/osd-bundle/osd-1.1.0.tar.gz rename to cypress/test-data/with-security/osd-1.1.0.tar.gz diff --git a/cypress/test-data/osd/odfe-0.10.0.tar.gz b/cypress/test-data/without-security/odfe-0.10.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-0.10.0.tar.gz rename to cypress/test-data/without-security/odfe-0.10.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.0.2.tar.gz b/cypress/test-data/without-security/odfe-1.0.2.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.0.2.tar.gz rename to cypress/test-data/without-security/odfe-1.0.2.tar.gz diff --git a/cypress/test-data/osd/odfe-1.1.0.tar.gz b/cypress/test-data/without-security/odfe-1.1.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.1.0.tar.gz rename to cypress/test-data/without-security/odfe-1.1.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.11.0.tar.gz b/cypress/test-data/without-security/odfe-1.11.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.11.0.tar.gz rename to cypress/test-data/without-security/odfe-1.11.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.13.2.tar.gz b/cypress/test-data/without-security/odfe-1.13.2.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.13.2.tar.gz rename to cypress/test-data/without-security/odfe-1.13.2.tar.gz diff --git a/cypress/test-data/osd/odfe-1.2.1.tar.gz b/cypress/test-data/without-security/odfe-1.2.1.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.2.1.tar.gz rename to cypress/test-data/without-security/odfe-1.2.1.tar.gz diff --git a/cypress/test-data/osd/odfe-1.3.0.tar.gz b/cypress/test-data/without-security/odfe-1.3.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.3.0.tar.gz rename to cypress/test-data/without-security/odfe-1.3.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.4.0.tar.gz b/cypress/test-data/without-security/odfe-1.4.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.4.0.tar.gz rename to cypress/test-data/without-security/odfe-1.4.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.7.0.tar.gz b/cypress/test-data/without-security/odfe-1.7.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.7.0.tar.gz rename to cypress/test-data/without-security/odfe-1.7.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.8.0.tar.gz b/cypress/test-data/without-security/odfe-1.8.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.8.0.tar.gz rename to cypress/test-data/without-security/odfe-1.8.0.tar.gz diff --git a/cypress/test-data/osd/odfe-1.9.0.tar.gz b/cypress/test-data/without-security/odfe-1.9.0.tar.gz similarity index 100% rename from cypress/test-data/osd/odfe-1.9.0.tar.gz rename to cypress/test-data/without-security/odfe-1.9.0.tar.gz diff --git a/cypress/test-data/osd/osd-1.0.0.tar.gz b/cypress/test-data/without-security/osd-1.0.0.tar.gz similarity index 100% rename from cypress/test-data/osd/osd-1.0.0.tar.gz rename to cypress/test-data/without-security/osd-1.0.0.tar.gz diff --git a/cypress/test-data/osd/osd-1.1.0.tar.gz b/cypress/test-data/without-security/osd-1.1.0.tar.gz similarity index 100% rename from cypress/test-data/osd/osd-1.1.0.tar.gz rename to cypress/test-data/without-security/osd-1.1.0.tar.gz diff --git a/package.json b/package.json index d34f798cfee1..a94ba53e0358 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "osd": "node scripts/osd", "opensearch": "node scripts/opensearch", "test": "grunt test", - "test:bwc": "./scripts/bwctest-osd.sh", + "test:bwc": "./scripts/bwctest_osd.sh", "test:jest": "node scripts/jest", "test:jest_integration": "node scripts/jest_integration", "test:mocha": "node scripts/mocha", diff --git a/scripts/bwctest-osd.sh b/scripts/bwctest-osd.sh deleted file mode 100755 index 630cd0e54a1d..000000000000 --- a/scripts/bwctest-osd.sh +++ /dev/null @@ -1,288 +0,0 @@ -#!/bin/bash - -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 - -set -e - -function usage() { - echo "" - echo "This script is used to run backwards compatibility tests on a remote OpenSearch/Dashboards cluster." - echo "--------------------------------------------------------------------------" - echo "Usage: $0 [args]" - echo "" - echo "Required arguments:" - echo "None" - echo "" - echo "Optional arguments:" - echo -e "-a BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." - echo -e "-p BIND_PORT\t, defaults to 9200 or 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location." - echo -e "-b BUNDLED_DASHBOARDS\t(true | false), defaults to false. Specify the usage of bundled Dashboards or not." - echo -e "-v VERSIONS\t(true | false), defaults to a defind test array in the script. Specify the versions of the tested Dashboards. It could be a single version or multiple." - echo -e "-o OPENSEARCH\t, no defaults and must provide. Specify the tested OpenSearch which must be named opensearch and formatted as tar.gz." - echo -e "-d DASHBOARDS\t, no defaults and must provide. Specify the tested Dashboards which must be named opensearch-dashboards and formatted as tar.gz." - echo -e "-h\tPrint this message." - echo "--------------------------------------------------------------------------" -} - -while getopts ":ha:p:b:v:o:d:" arg; do - case $arg in - h) - usage - exit 1 - ;; - a) - BIND_ADDRESS=$OPTARG - ;; - p) - BIND_PORT=$OPTARG - ;; - b) - BUNDLED_DASHBOARDS=$OPTARG - ;; - v) - VERSIONS=$OPTARG - ;; - o) - OPENSEARCH=$OPTARG - ;; - d) - DASHBOARDS=$OPTARG - ;; - :) - echo "-${OPTARG} requires an argument" - usage - exit 1 - ;; - ?) - echo "Invalid option: -${OPTARG}" - exit 1 - ;; - esac -done - -if [ -z "$BIND_ADDRESS" ] -then - BIND_ADDRESS="localhost" -fi - -if [ -z "$BIND_PORT" ] -then - BIND_PORT="5601" -fi - -if [ -v "VERSIONS" ] -then - test_array=($VERSIONS) -else - test_array=("odfe-0.10.0" "odfe-1.0.2" "odfe-1.1.0" "odfe-1.2.1" "odfe-1.3.0" "odfe-1.4.0" "odfe-1.7.0" "odfe-1.8.0" "odfe-1.9.0" "odfe-1.11.0" "odfe-1.13.2" "osd-1.0.0" "osd-1.1.0") -fi - -if [ -z "$BUNDLED_DASHBOARDS" ] -then - BUNDLED_DASHBOARDS="false" -fi - -if [ $BUNDLED_DASHBOARDS == "false" ] -then - dashboards_type="osd" -else - dashboards_type="osd-bundle" -fi - -# define test path -cwd=$(pwd) -dir="$cwd/bwc-tmp" -test_dir="$dir/test" -if [ -d "$dir" ]; then - echo "bwc-tmp exists and needs to be removed" - rm -rf "$dir" -fi -mkdir "$dir" -mkdir "$test_dir" - -# unzip opensearch and dashboards -echo "[ unzip opensearch and dashboards ]" -cd "$dir" -cp $OPENSEARCH $dir -cp $DASHBOARDS $dir - -IFS='/' read -ra ADDR <<< "$OPENSEARCH" -opensearch_tar=${ADDR[-1]} -tar -xvf $opensearch_tar >> /dev/null 2>&1 -IFS='.' read -ra ADDR <<< "$opensearch_tar" -opensearch=${ADDR[0]} - -IFS='/' read -ra ADDR <<< "$DASHBOARDS" -dashboards_tar=${ADDR[-1]} -tar -xvf $dashboards_tar >> /dev/null 2>&1 -IFS='.' read -ra ADDR <<< "$dashboards_tar" -dashboards=${ADDR[0]} - -# define other paths and tmp files -opensearch_dir="$dir/$opensearch" -dashboards_dir="$dir/$dashboards" -opensearch_file='opensearch.txt' -dashboards_file='dashboards.txt' -opensearch_path="$dir/$opensearch_file" -if [ $BUNDLED_DASHBOARDS == "false" ]; then opensearch_msg="\"status\":\"green\""; else opensearch_msg="\"status\":\"yellow\""; fi -dashboards_path="$dir/$dashboards_file" -dashboards_msg="\"state\":\"green\",\"title\":\"Green\",\"nickname\":\"Looking good\",\"icon\":\"success\"" -if [ $BUNDLED_DASHBOARDS == "false" ]; then opensearch_url="http://localhost:9200/_cluster/health"; else opensearch_url="https://localhost:9200/_cluster/health"; fi -if [ $BUNDLED_DASHBOARDS == "false" ]; then opensearch_args=""; else opensearch_args="-u admin:admin --insecure"; fi -dashboards_url="http://localhost:5601/api/status" - -# define test groups and suites -test_group_1="check_loaded_data,check_timeline" -test_group_2="check_advanced_settings,check_loaded_data,check_timeline" -test_group_3="check_advanced_settings,check_filter_and_query,check_loaded_data,check_timeline" -test_group_4="check_advanced_settings,check_default_page,check_filter_and_query,check_loaded_data,check_timeline" - -declare -A test_suites -test_suites=( - ["odfe-0.10.0"]=$test_group_1 - ["odfe-1.0.2"]=$test_group_2 - ["odfe-1.1.0"]=$test_group_2 - ["odfe-1.2.1"]=$test_group_2 - ["odfe-1.3.0"]=$test_group_2 - ["odfe-1.4.0"]=$test_group_3 - ["odfe-1.7.0"]=$test_group_3 - ["odfe-1.8.0"]=$test_group_3 - ["odfe-1.9.0"]=$test_group_3 - ["odfe-1.11.0"]=$test_group_3 - ["odfe-1.13.2"]=$test_group_4 - ["osd-1.0.0"]=$test_group_4 - ["osd-1.1.0"]=$test_group_4 -) - -# remove the running opensearch process -function clean { - echo "close running opensearcn" - process=($(ps -ef | grep "Dopensearch" | awk '{print $2}')) - kill ${process[0]} - echo "close any usage on port 5601" - process=($(lsof -i -P -n | grep 5601 | awk '{print $2}')) - kill ${process[0]} -} - -# this is a support funtion to print out a text file line by line -function print_txt { - while IFS= read -r line; do - echo "text read from $1: $line" - done < $1 -} - -# this function is used to check the opensearch or dashboards running status -# $1 is the path to the tmp file which saves the running status -# $2 is the error msg to check -# $3 is the url to curl -# $4 contains arguments that need to be passed to the curl command -function check_status { - while [ ! -f $1 ] || ! grep -q "$2" $1; do - if [ -f $1 ]; then rm $1; fi - curl $3 $4 > $1 || true - done - rm $1 -} - -# this function sets up the cypress env -# it first clones the opensearch-dashboards-functional-test library -# then it removes the tests into the cypress integration folder -# and copies the backwards compatibility tests into the folder -function setup_cypress { - git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test "$test_dir" - rm -rf "$test_dir/cypress/integration" - cp -r "$cwd/cypress/integration" "$test_dir/cypress" - cd "$test_dir" - npm install -} - -# this function copies the tested data for the required version to the opensearch data folder -# $1 is the required version -function upload_data { - rm -rf "$opensearch_dir/data" - cd $opensearch_dir - cp "$cwd/cypress/test-data/$dashboards_type/$1.tar.gz" . - tar -xvf "$opensearch_dir/$1.tar.gz" >> /dev/null 2>&1 - rm "$1.tar.gz" - echo "ready to test" -} - -# this function starts opensearch -function run_opensearch { - cd "$opensearch_dir" - ./bin/opensearch -} - -# this function starts dashboards -function run_dashboards { - cd "$dashboards_dir" - ./bin/opensearch-dashboards -} - -# this function checks the opensearch running status -# it calls check_status and passes the opensearch tmp file path, error msg, url, and arguments -# if success, the while loop in the check_status will end and it prints out "opensearch is up" -function check_opensearch_status { - cd "$dir" - check_status $opensearch_path "$opensearch_msg" $opensearch_url "$opensearch_args" >> /dev/null 2>&1 - echo "opensearch is up" -} - -# this function checks the dashboards running status -# it calls check_status and passes the dashboards tmp file path, error msg, url, and arguments -# if success, the while loop in the check_status will end and it prints out "dashboards is up" -function check_dashboards_status { - cd "$dir" - check_status $dashboards_path "$dashboards_msg" $dashboards_url "" >> /dev/null 2>&1 - echo "dashboards is up" -} - -# this function will run backwards compatibility test using cypress for the required version -# $1 is the requested version -function run_bwc { - cd "$test_dir" - IFS=',' read -r -a tests <<< "${test_suites[$1]}" - for test in "${tests[@]}" - do - npx cypress run --spec "$cwd/bwc-tmp/test/cypress/integration/$dashboards_type/$test.js" || echo "backwards compatibility tests have issue" - done -} - -# setup the cypress test env -echo "[ setup the cypress test env ]" -setup_cypress -echo "cypress is ready" - -# for each required testing version, do the following -# first run opensearch and check the status -# second run dashboards and check the status -# run the backwards compatibility tests -for i in ${!test_array[@]}; -do - version=${test_array[$i]} - # setup the opensearch env - # copy and unzip data in the opensearch data folder - echo "[ set up the opensearch env for $version ]" - upload_data $version - - echo "[ start opensearch and wait ]" - run_opensearch >> /dev/null 2>&1 & - - echo "check the opensearch status" - check_opensearch_status - - echo "[ start dashboards and wait ]" - run_dashboards >> /dev/null 2>&1 & - - echo "check the dashboards status" - check_dashboards_status - - echo "[ run the backwards compatibility tests for $version ]" - run_bwc $version - - # kill the running opensearch process - clean -done - -rm -rf "$dir" \ No newline at end of file diff --git a/scripts/bwctest_osd.sh b/scripts/bwctest_osd.sh new file mode 100755 index 000000000000..9c131e50fc10 --- /dev/null +++ b/scripts/bwctest_osd.sh @@ -0,0 +1,332 @@ +#!/bin/bash + +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 + +set -e + +# For every release, add sample data and new version below: +DEFAULT_VERSIONS=( + "odfe-0.10.0" + "odfe-1.0.2" + "odfe-1.1.0" + "odfe-1.2.1" + "odfe-1.3.0" + "odfe-1.4.0" + "odfe-1.7.0" + "odfe-1.8.0" + "odfe-1.9.0" + "odfe-1.11.0" + "odfe-1.13.2" + "osd-1.0.0" + "osd-1.1.0" +) + +# Define test groups +TEST_GROUP_1="check_loaded_data,check_timeline" +TEST_GROUP_2="$TEST_GROUP_1,check_advanced_settings" +TEST_GROUP_3="$TEST_GROUP_2,check_filter_and_query" +TEST_GROUP_4="$TEST_GROUP_3,check_default_page" +# If not defining test suite for a specific version, it will default to this group of tests +TEST_GROUP_DEFAULT="$TEST_GROUP_4" + +function usage() { + echo "" + echo "This script is used to run backwards compatibility tests for OpenSearch Dashboards" + echo "--------------------------------------------------------------------------" + echo "Usage: $0 [args]" + echo "" + echo "Required arguments:" + echo -e "-o OPENSEARCH\t, Specify the tested OpenSearch." + echo -e "-d DASHBOARDS\t, Specify the tested OpenSearch Dashboards." + echo "" + echo "Optional arguments:" + echo -e "-b BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." + echo -e "-p BIND_PORT\t, defaults to 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location." + echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not." + 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 "-h\tPrint this message." + echo "--------------------------------------------------------------------------" +} + +while getopts ":h:b:p:s:c:v:r:o:d:" arg; do + case $arg in + h) + usage + exit 1 + ;; + b) + BIND_ADDRESS=$OPTARG + ;; + p) + BIND_PORT=$OPTARG + ;; + s) + SECURITY_ENABLED=$OPTARG + ;; + c) + CREDENTIAL=$OPTARG + ;; + v) + VERSIONS=$OPTARG + ;; + r) + RELEASES=$OPTARG + ;; + o) + OPENSEARCH=$OPTARG + ;; + d) + DASHBOARDS=$OPTARG + ;; + :) + echo "-${OPTARG} requires an argument" + usage + exit 1 + ;; + ?) + echo "Invalid option: -${OPTARG}" + exit 1 + ;; + esac +done + +[ -z "$BIND_ADDRESS" ] && BIND_ADDRESS="localhost" +[ -z "$BIND_PORT" ] && BIND_PORT="5601" +[ -z "$VERSIONS" ] && test_array=("${DEFAULT_VERSIONS[@]}") || IFS=',' read -r -a test_array <<<"$VERSIONS" +[ -z "$SECURITY_ENABLED" ] && SECURITY_ENABLED="false" +[ $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" + +# define test path +cwd=$(pwd) +dir="$cwd/bwc_tmp" +test_dir="$dir/test" +opensearch_dir="$dir/opensearch" +dashboards_dir="$dir/opensearch-dashboards" +if [ -d "$dir" ]; then + echo "Temporary directory exists. Removing." + rm -rf "$dir" +fi +mkdir "$dir" +mkdir "$test_dir" +mkdir "$opensearch_dir" +mkdir "$dashboards_dir" + +function open_artifact { + artifact_dir=$1 + artifact=$2 + cd $artifact_dir + + # check if artifact provided is URL or attempt if passing by absolute path + if wget -q --method=HEAD $artifact; then + wget -c $artifact -O - | tar -xz --strip-components=1 + else + tar -xf $artifact --strip-components=1 + fi + +} + +# un-tar OpenSearch and OpenSearch Dashboards +echo "[ unzip OpenSearch and OpenSearch Dashboards ]" +open_artifact $opensearch_dir $OPENSEARCH +open_artifact $dashboards_dir $DASHBOARDS + +# define other paths and tmp files +opensearch_file='opensearch.txt' +dashboards_file='dashboards.txt' +opensearch_path="$dir/$opensearch_file" +dashboards_path="$dir/$dashboards_file" +dashboards_msg="\"state\":\"green\",\"title\":\"Green\",\"nickname\":\"Looking good\",\"icon\":\"success\"" +dashboards_url="http://$BIND_ADDRESS:$BIND_PORT/api/status" +if [ $SECURITY_ENABLED == "false" ]; +then + opensearch_msg="\"status\":\"green\"" + opensearch_url="http://$BIND_ADDRESS:9200/_cluster/health" + opensearch_args="" +else + opensearch_msg="\"status\":\"yellow\"" + opensearch_url="https://$BIND_ADDRESS:9200/_cluster/health" + opensearch_args="-u $CREDENTIAL --insecure" +fi + +# define test groups to test suites +declare -A test_suites +test_suites=( + ["odfe-0.10.0"]=$TEST_GROUP_1 + ["odfe-1.0.2"]=$TEST_GROUP_2 + ["odfe-1.1.0"]=$TEST_GROUP_2 + ["odfe-1.2.1"]=$TEST_GROUP_2 + ["odfe-1.3.0"]=$TEST_GROUP_2 + ["odfe-1.4.0"]=$TEST_GROUP_3 + ["odfe-1.7.0"]=$TEST_GROUP_3 + ["odfe-1.8.0"]=$TEST_GROUP_3 + ["odfe-1.9.0"]=$TEST_GROUP_3 + ["odfe-1.11.0"]=$TEST_GROUP_3 + ["odfe-1.13.2"]=$TEST_GROUP_4 + ["osd-1.0.0"]=$TEST_GROUP_4 + ["osd-1.1.0"]=$TEST_GROUP_4 +) + +# remove the running opensearch process +function clean { + echo "Closing the running OpenSearch" + process=($(ps -ef | grep "Dopensearch" | awk '{print $2}')) + kill ${process[0]} + echo "Closing any usage on port $BIND_PORT" + process=($(lsof -i -P -n | grep $BIND_PORT | awk '{print $2}')) + kill ${process[0]} +} + +# Print out a textfile line by line +function print_txt { + while IFS= read -r line; do + echo "text read from $1: $line" + done < $1 +} + +# this function is used to check the running status of OpenSearch or OpenSearch Dashboards +# $1 is the path to the tmp file which saves the running status +# $2 is the error msg to check +# $3 is the url to curl +# $4 contains arguments that need to be passed to the curl command +function check_status { + while [ ! -f $1 ] || ! grep -q "$2" $1; do + if [ -f $1 ]; then rm $1; fi + curl $3 $4 > $1 || true + done + rm $1 +} + +# this function sets up the cypress env +# it first clones the opensearch-dashboards-functional-test library +# then it removes the tests into the cypress integration folder +# and copies the backwards compatibility tests into the folder +function setup_cypress { + echo "[ Setup the cypress test environment ]" + git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test "$test_dir" + rm -rf "$test_dir/cypress/integration" + cp -r "$cwd/cypress/integration" "$test_dir/cypress" + cd "$test_dir" + npm install + echo "Cypress is ready!" +} + +# this function copies the tested data for the required version to the opensearch data folder +# $1 is the required version +function upload_data { + rm -rf "$opensearch_dir/data" + cd $opensearch_dir + cp "$cwd/cypress/test-data/$dashboards_type/$1.tar.gz" . + tar -xvf "$opensearch_dir/$1.tar.gz" >> /dev/null 2>&1 + rm "$1.tar.gz" + echo "Data has been uploaded and ready to test" +} + +# Starts OpenSearch, if verifying a distribution it will install the certs then start. +function run_opensearch { + echo "[ Attempting to start OpenSearch... ]" + cd "$opensearch_dir" + [ $SECURITY_ENABLED == "false" ] && ./bin/opensearch || ./opensearch-tar-install.sh +} + +# Starts OpenSearch Dashboards +function run_dashboards { + echo "[ Attempting to start OpenSearch Dashboards... ]" + cd "$dashboards_dir" + [ $SECURITY_ENABLED == "false" ] && rm config/opensearch_dashboards.yml && touch config/opensearch_dashboards.yml + ./bin/opensearch-dashboards +} + +# Checks the running status of OpenSearch +# it calls check_status and passes the OpenSearch tmp file path, error msg, url, and arguments +# if success, the while loop in the check_status will end and it prints out "OpenSearch is up!" +function check_opensearch_status { + echo "Checking the status OpenSearch..." + cd "$dir" + check_status $opensearch_path "$opensearch_msg" $opensearch_url "$opensearch_args" >> /dev/null 2>&1 + echo "OpenSearch is up!" +} + +# Checks the running status of OpenSearch Dashboards +# it calls check_status and passes the OpenSearch Dashboards tmp file path, error msg, url, and arguments +# if success, the while loop in the check_status will end and it prints out "OpenSearch Dashboards is up!" +function check_dashboards_status { + echo "Checking the OpenSearch Dashboards..." + cd "$dir" + check_status $dashboards_path "$dashboards_msg" $dashboards_url "" >> /dev/null 2>&1 + echo "OpenSearch Dashboards is up!" +} + +# Runs the backwards compatibility test using cypress for the required version +# $1 is the requested version +function run_bwc { + cd "$test_dir" + [ -z "${test_suites[$1]}" ] && test_suite=$TEST_GROUP_DEFAULT || test_suite="${test_suites[$1]}" + IFS=',' read -r -a tests <<<"$test_suite" + for test in "${tests[@]}" + do + npx cypress run --spec "$test_dir/cypress/integration/$dashboards_type/$test.js" || echo "backwards compatibility tests have issue" + done + # Check if $dashboards_type/plugins has tests in them to execute + if [ "$(ls -A $test_dir/cypress/integration/$dashboards_type/plugins | wc -l)" -gt 1 ]; then + echo "Running tests from plugins" + npx cypress run --spec "$test_dir/cypress/integration/$dashboards_type/plugins/*.js" || echo "backwards compatibility plugins tests have issue" + fi +} + +# Main function +function execute_tests { + # for each required testing version, do the following + # first run opensearch and check the status + # second run dashboards and check the status + # run the backwards compatibility tests + for version in "${test_array[@]}" + do + # copy and un-tar data into the OpenSearch data folder + echo "[ Setting up the OpenSearch environment for $version ]" + upload_data $version + + run_opensearch >> /dev/null 2>&1 & + check_opensearch_status + run_dashboards >> /dev/null 2>&1 & + check_dashboards_status + + echo "[ Run the backwards compatibility tests for $version ]" + run_bwc $version + + # kill the running OpenSearch process + clean + done +} + +# 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:]) + + for release in "${releases_array[@]}" + do + echo "Running tests with OpenSearch Dashboards $PACKAGE_VERSION and OpenSearch $release" + ( + rm -rf $opensearch_dir && mkdir "$opensearch_dir" + # TODO: support multiple platforms and architectures + cd $opensearch_dir && wget -c https://artifacts.opensearch.org/releases/bundle/opensearch/$release/opensearch-$release-linux-x64.tar.gz -O - | tar -xz --strip-components=1 + ) + execute_tests + done +} + +# setup the cypress test env +setup_cypress +execute_tests +(( ${#releases_array[@]} )) && execute_mismatch_tests + +rm -rf "$dir" \ No newline at end of file