From be94338fe026477394d711721d687eee89ff9796 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 14 Mar 2024 18:00:06 -0400 Subject: [PATCH 01/26] Add infra support and helper function to create real datasource Signed-off-by: Derek Ho --- .github/workflows/release-signoff-chrome.yml | 5 +++++ .../release-signoff-chromium-ad-only.yml | 5 +++++ .../release-signoff-chromium-ism-only.yml | 5 +++++ .../1_create_datasource.spec.js | 17 +++++++++++++++++ cypress/utils/commands.js | 15 +++++++++++++++ 5 files changed, 47 insertions(+) diff --git a/.github/workflows/release-signoff-chrome.yml b/.github/workflows/release-signoff-chrome.yml index e6bdb4775..22d95298b 100644 --- a/.github/workflows/release-signoff-chrome.yml +++ b/.github/workflows/release-signoff-chrome.yml @@ -34,6 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: false + port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ad-only.yml b/.github/workflows/release-signoff-chromium-ad-only.yml index d4db844d9..ccb14dbd1 100644 --- a/.github/workflows/release-signoff-chromium-ad-only.yml +++ b/.github/workflows/release-signoff-chromium-ad-only.yml @@ -34,6 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: false + port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ism-only.yml b/.github/workflows/release-signoff-chromium-ism-only.yml index 6f0d5d3d1..0db14841f 100644 --- a/.github/workflows/release-signoff-chromium-ism-only.yml +++ b/.github/workflows/release-signoff-chromium-ism-only.yml @@ -34,6 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: false + port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 16340acb8..717a51d9c 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -17,6 +17,23 @@ const REGION = 'us-east-1'; const ACCESS_KEY = 'accessKey'; const SECRET_KEY = 'secretKey'; +export const CreateDataSourceNoAuth = () => { + cy.visit( + 'http://localhost:5601/app/management/opensearch-dashboards/dataSources/create' + ); + cy.get('[data-test-subj="createDataSourceFormTitleField"]').type('9201'); + cy.get('[data-test-subj="createDataSourceFormEndpointField"]').type( + 'http://localhost:9201' + ); + cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click(); + cy.get('#no_auth').click(); + cy.get('[data-test-subj="createDataSourceTestConnectionButton"]').click(); + cy.get('.euiToastHeader__title').should('contain', 'successful'); + cy.get('[data-test-subj="createDataSourceButton"]').click(); +}; + +// TODO: create datasource with basic auth and sigv4 + if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { describe('Create datasources', () => { before(() => { diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index 19f84fb66..a4e9e3ed4 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -368,6 +368,21 @@ Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => { Cypress.config().baseUrl }/api/saved_objects/index-pattern/${id}`; + console.log(JSON.stringify(url)); + console.log( + JSON.stringify({ + 'content-type': 'application/json;charset=UTF-8', + 'osd-xsrf': true, + ...header, + }) + ); + console.log( + JSON.stringify({ + attributes, + references: [], + }) + ); + cy.request({ method: 'POST', url, From 1b315acb8a1bde82d2ec099f62d2cff5dc181119 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 14 Mar 2024 18:01:29 -0400 Subject: [PATCH 02/26] Remove logs from previous change Signed-off-by: Derek Ho --- cypress/utils/commands.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index a4e9e3ed4..19f84fb66 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -368,21 +368,6 @@ Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => { Cypress.config().baseUrl }/api/saved_objects/index-pattern/${id}`; - console.log(JSON.stringify(url)); - console.log( - JSON.stringify({ - 'content-type': 'application/json;charset=UTF-8', - 'osd-xsrf': true, - ...header, - }) - ); - console.log( - JSON.stringify({ - attributes, - references: [], - }) - ); - cy.request({ method: 'POST', url, From 7146b08c363d4585586f4b109d8a0ade4e2a2423 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 15 Mar 2024 10:53:39 -0400 Subject: [PATCH 03/26] Add test that uses the helper function to verify functionality Signed-off-by: Derek Ho --- .../datasource-management-plugin/1_create_datasource.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 717a51d9c..c4c1312b5 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -417,6 +417,10 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { 'app/management/opensearch-dashboards/dataSources' ); }); + + it('creates a datasources to a real opensearch instance', () => { + CreateDataSourceNoAuth(); + }); }); }); } From 8364c60c7d68e05d2748627a80c1753bab323893 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 22 Mar 2024 11:17:33 -0400 Subject: [PATCH 04/26] Change to request and add it to appropriate workflows Signed-off-by: Derek Ho --- .../release-e2e-workflow-template-windows.yml | 5 ++++ .../release-e2e-workflow-template.yml | 5 ++++ .../1_create_datasource.spec.js | 28 +++++++++++-------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-e2e-workflow-template-windows.yml b/.github/workflows/release-e2e-workflow-template-windows.yml index f5b9a8873..dc88be645 100644 --- a/.github/workflows/release-e2e-workflow-template-windows.yml +++ b/.github/workflows/release-e2e-workflow-template-windows.yml @@ -69,6 +69,11 @@ jobs: fi netstat -anP tcp | grep LISTEN | grep 9200 || netstat -ntlp | grep 9200 shell: bash + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: false + port: 9201 - name: Get and run OpenSearch-Dashboards run: | curl -SLO https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/${{ env.PLATFORM }}/x64/zip/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-${{ env.PLATFORM }}-x64.zip diff --git a/.github/workflows/release-e2e-workflow-template.yml b/.github/workflows/release-e2e-workflow-template.yml index bc0788427..f2223529d 100644 --- a/.github/workflows/release-e2e-workflow-template.yml +++ b/.github/workflows/release-e2e-workflow-template.yml @@ -66,6 +66,11 @@ jobs: timeout 900 bash -c 'while [[ "$(curl -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' curl https://localhost:9200 -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure fi + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: false + port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index c4c1312b5..4d6763262 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -18,18 +18,22 @@ const ACCESS_KEY = 'accessKey'; const SECRET_KEY = 'secretKey'; export const CreateDataSourceNoAuth = () => { - cy.visit( - 'http://localhost:5601/app/management/opensearch-dashboards/dataSources/create' - ); - cy.get('[data-test-subj="createDataSourceFormTitleField"]').type('9201'); - cy.get('[data-test-subj="createDataSourceFormEndpointField"]').type( - 'http://localhost:9201' - ); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').click(); - cy.get('#no_auth').click(); - cy.get('[data-test-subj="createDataSourceTestConnectionButton"]').click(); - cy.get('.euiToastHeader__title').should('contain', 'successful'); - cy.get('[data-test-subj="createDataSourceButton"]').click(); + cy.request({ + method: 'POST', + url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, + headers: { + 'osd-xsrf': true, + }, + body: { + attributes: { + title: `9201`, + endpoint: `http://localhost:9201`, + auth: { + type: 'no_auth', + }, + }, + }, + }); }; // TODO: create datasource with basic auth and sigv4 From 5319fe850b8bec8f7f8392f7bad6aec105a2a1d3 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 3 Apr 2024 17:10:21 -0400 Subject: [PATCH 05/26] Add basic auth remote cluster Signed-off-by: Derek Ho --- .../release-e2e-workflow-template-windows.yml | 6 +++++ .../release-e2e-workflow-template.yml | 6 +++++ .github/workflows/release-signoff-chrome.yml | 6 +++++ .../release-signoff-chromium-ad-only.yml | 5 ++++ .../release-signoff-chromium-ism-only.yml | 6 +++++ .../1_create_datasource.spec.js | 24 +++++++++++++++++++ 6 files changed, 53 insertions(+) diff --git a/.github/workflows/release-e2e-workflow-template-windows.yml b/.github/workflows/release-e2e-workflow-template-windows.yml index dc88be645..80083ab4f 100644 --- a/.github/workflows/release-e2e-workflow-template-windows.yml +++ b/.github/workflows/release-e2e-workflow-template-windows.yml @@ -74,6 +74,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get and run OpenSearch-Dashboards run: | curl -SLO https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/${{ env.PLATFORM }}/x64/zip/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-${{ env.PLATFORM }}-x64.zip diff --git a/.github/workflows/release-e2e-workflow-template.yml b/.github/workflows/release-e2e-workflow-template.yml index f2223529d..7cad9e40d 100644 --- a/.github/workflows/release-e2e-workflow-template.yml +++ b/.github/workflows/release-e2e-workflow-template.yml @@ -71,6 +71,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chrome.yml b/.github/workflows/release-signoff-chrome.yml index 22d95298b..b63952dc7 100644 --- a/.github/workflows/release-signoff-chrome.yml +++ b/.github/workflows/release-signoff-chrome.yml @@ -39,6 +39,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ad-only.yml b/.github/workflows/release-signoff-chromium-ad-only.yml index ccb14dbd1..3a82addc9 100644 --- a/.github/workflows/release-signoff-chromium-ad-only.yml +++ b/.github/workflows/release-signoff-chromium-ad-only.yml @@ -39,6 +39,11 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ism-only.yml b/.github/workflows/release-signoff-chromium-ism-only.yml index 0db14841f..8c23ea37c 100644 --- a/.github/workflows/release-signoff-chromium-ism-only.yml +++ b/.github/workflows/release-signoff-chromium-ism-only.yml @@ -39,6 +39,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: derek-ho/start-opensearch@v3 + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 4d6763262..6050e8a4f 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -36,6 +36,30 @@ export const CreateDataSourceNoAuth = () => { }); }; +export const CreateDataSourceBasicAuth = () => { + miscUtils.visitPage( + 'app/management/opensearch-dashboards/dataSources/create' + ); + + cy.get('[data-test-subj="createDataSourceButton"]').should('be.disabled'); + cy.get('[name="dataSourceTitle"]').type('9201'); + cy.get('[name="endpoint"]').type('https://localhost:9202'); + cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( + 'username_password' + ); + cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type('admin'); + cy.get('[data-test-subj="createDataSourceFormPasswordField"]').type('admin'); + cy.get('[data-test-subj="createDataSourceButton"]').should('be.enabled'); + cy.get('[name="dataSourceDescription"]').type( + 'cypress test basic auth data source' + ); + cy.get('[data-test-subj="createDataSourceButton"]').click(); + cy.location('pathname', { timeout: 6000 }).should( + 'include', + 'app/management/opensearch-dashboards/dataSources' + ); +}; + // TODO: create datasource with basic auth and sigv4 if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { From f7d2337af4e6533c9f9e12a6a4c9855fec967973 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 3 Apr 2024 17:11:22 -0400 Subject: [PATCH 06/26] Call function Signed-off-by: Derek Ho --- .github/workflows/release-signoff-chromium-ad-only.yml | 1 + .../datasource-management-plugin/1_create_datasource.spec.js | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/release-signoff-chromium-ad-only.yml b/.github/workflows/release-signoff-chromium-ad-only.yml index 3a82addc9..25ade3e27 100644 --- a/.github/workflows/release-signoff-chromium-ad-only.yml +++ b/.github/workflows/release-signoff-chromium-ad-only.yml @@ -43,6 +43,7 @@ jobs: with: opensearch-version: ${{ env.VERSION }} security-enabled: true + admin-password: admin port: 9202 - name: Get OpenSearch-Dashboards run: | diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 6050e8a4f..fe7c6b126 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -448,6 +448,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { it('creates a datasources to a real opensearch instance', () => { CreateDataSourceNoAuth(); + CreateDataSourceBasicAuth(); }); }); }); From 47c47840b5a35a018446f5fb539a3750d547fc36 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 18 Apr 2024 16:58:56 -0400 Subject: [PATCH 07/26] Move action Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 181 ++++++++++++++++++ .../release-e2e-workflow-template-windows.yml | 8 +- .../release-e2e-workflow-template.yml | 8 +- .github/workflows/release-signoff-chrome.yml | 8 +- .../release-signoff-chromium-ad-only.yml | 8 +- .../release-signoff-chromium-ism-only.yml | 8 +- .../1_create_datasource.spec.js | 7 +- 7 files changed, 190 insertions(+), 38 deletions(-) create mode 100644 .github/actions/start-opensearch/action.yml diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml new file mode 100644 index 000000000..b700f4a3a --- /dev/null +++ b/.github/actions/start-opensearch/action.yml @@ -0,0 +1,181 @@ +name: 'Launch OpenSearch with or without plugins' +description: 'Downloads latest build of OpenSearch, optionally installs plugins, and then starts OpenSearch on localhost:9200' + +inputs: + opensearch-version: + description: 'The version of OpenSearch that should be used, e.g "3.0.0"' + required: true + + plugins: + description: 'A comma separated list of plugins to install. Leave empty to not install any. Each entry should be a full path prefixed with `file: `, for example: `file:$(pwd)/my-plugin.zip`' + required: false + + security-enabled: + description: 'Whether security is enabled' + required: true + + admin-password: + description: 'The admin password uses for the cluster' + required: false + + security_config_file: + description: 'Path to a security config file to replace the default. Leave empty if security is not enabled or using the default config' + required: false + + port: + description: 'Port to run OpenSearch. Leave empty to use the default config (9200)' + required: false + +runs: + using: "composite" + steps: + + # Configure longpath names if on Windows + - name: Enable Longpaths if on Windows + if: ${{ runner.os == 'Windows' }} + run: git config --system core.longpaths true + shell: pwsh + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + # Download OpenSearch + - name: Download OpenSearch for Windows + uses: peternied/download-file@v2 + if: ${{ runner.os == 'Windows' }} + with: + url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + + + - name: Download OpenSearch for Linux + uses: peternied/download-file@v2 + if: ${{ runner.os == 'Linux' }} + with: + url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-linux-x64-latest.tar.gz + + # Extract downloaded zip + - name: Extract downloaded tar + if: ${{ runner.os == 'Linux' }} + run: | + tar -xzf opensearch-*.tar.gz + rm -f opensearch-*.tar.gz + shell: bash + + - name: Extract downloaded zip + if: ${{ runner.os == 'Windows' }} + run: | + tar -xzf opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + del opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + shell: pwsh + + - name: Install plugin(s) into OpenSearch for Linux + if: ${{ runner.os == 'Linux'}} + run: | + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin + plugins="${{ inputs.plugins }}" + if [ -n "$plugins" ]; then + echo "$plugins" | tr ',' '\n' | while read -r plugin; do + /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install ${plugin}" + done + fi + shell: bash + + - name: Install plugin(s) into OpenSearch for Windows + if: ${{ runner.os == 'Windows' && inputs.plugins != '' }} + run: | + $pluginNames = "${{ inputs.plugins }}" -split ',' + if ($pluginNames.Length -gt 0) { + foreach ($plugin in $pluginNames) { + 'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install ${plugin} + } + } + shell: pwsh + + - name: Replace security configuration file if applicable + if: ${{ inputs.security_config_file != '' }} + run: | + mv ${{ inputs.security_config_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch-security/config.yml + shell: bash + + # Setup security if it's enabled + - name: Setup security demo configuration + if: ${{ runner.os == 'Linux' && inputs.security-enabled == 'true' }} + run: | + echo "running linux security demo configuration setup" + export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh + /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh -t" + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + shell: bash + + - name: Setup security demo configuration for Windows + if: ${{ runner.os == 'Windows' && inputs.security-enabled == 'true' }} + run: | + echo "running windows security demo configuration setup" + export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat + /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat -t" + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + shell: bash + + - name: Use more space + run: | + echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + shell: bash + + - name: Replace opensearch.yml file if applicable + if: ${{ inputs.port != '' }} + run: | + echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + shell: bash + + # Run OpenSearch + - name: Run OpenSearch with plugin on Linux + if: ${{ runner.os == 'Linux'}} + run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch &" + shell: bash + + - name: Run OpenSearch with plugin on Windows + if: ${{ runner.os == 'Windows'}} + run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch.bat + shell: pwsh + + # Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! + - name: Sleep while OpenSearch starts + uses: peternied/action-sleep@v1 + with: + seconds: 30 + + # Verify that the server is operational + - name: Check OpenSearch Running on Linux + if: ${{ runner.os != 'Windows'}} + run: | + if [ "${{ inputs.security-enabled }}" == "true" ]; then + curl https://localhost:${{ inputs.port || 9200 }}/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body + else + curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v + fi + shell: bash + + - name: Check OpenSearch Running on Windows + if: ${{ runner.os == 'Windows'}} + run: | + if ("${{ inputs.security-enabled }}" -eq "true") { + $credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:${{ inputs.admin-password }}") + $encodedCredentials = [Convert]::ToBase64String($credentialBytes) + $baseCredentials = "Basic $encodedCredentials" + $Headers = @{ Authorization = $baseCredentials } + $url = 'https://localhost:${{ inputs.port || 9200 }}/_cat/plugins' + } else { + $Headers = @{ } + $url = 'http://localhost:${{ inputs.port || 9200 }}/_cat/plugins' + } + Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers; + shell: pwsh + + - if: always() + run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/logs/opensearch.log + shell: bash \ No newline at end of file diff --git a/.github/workflows/release-e2e-workflow-template-windows.yml b/.github/workflows/release-e2e-workflow-template-windows.yml index 80083ab4f..5dda02f39 100644 --- a/.github/workflows/release-e2e-workflow-template-windows.yml +++ b/.github/workflows/release-e2e-workflow-template-windows.yml @@ -69,17 +69,11 @@ jobs: fi netstat -anP tcp | grep LISTEN | grep 9200 || netstat -ntlp | grep 9200 shell: bash - - uses: derek-ho/start-opensearch@v3 + - uses: ./.github/actions/start-opensearch with: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 - - uses: derek-ho/start-opensearch@v3 - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: true - admin-password: admin - port: 9202 - name: Get and run OpenSearch-Dashboards run: | curl -SLO https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/${{ env.PLATFORM }}/x64/zip/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-${{ env.PLATFORM }}-x64.zip diff --git a/.github/workflows/release-e2e-workflow-template.yml b/.github/workflows/release-e2e-workflow-template.yml index 7cad9e40d..6dd2b8128 100644 --- a/.github/workflows/release-e2e-workflow-template.yml +++ b/.github/workflows/release-e2e-workflow-template.yml @@ -66,17 +66,11 @@ jobs: timeout 900 bash -c 'while [[ "$(curl -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' curl https://localhost:9200 -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure fi - - uses: derek-ho/start-opensearch@v3 + - uses: ./.github/actions/start-opensearch with: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 - - uses: derek-ho/start-opensearch@v3 - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: true - admin-password: admin - port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chrome.yml b/.github/workflows/release-signoff-chrome.yml index b63952dc7..f7d4e61e2 100644 --- a/.github/workflows/release-signoff-chrome.yml +++ b/.github/workflows/release-signoff-chrome.yml @@ -34,17 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' - - uses: derek-ho/start-opensearch@v3 + - uses: ./.github/actions/start-opensearch with: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 - - uses: derek-ho/start-opensearch@v3 - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: true - admin-password: admin - port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ad-only.yml b/.github/workflows/release-signoff-chromium-ad-only.yml index 25ade3e27..53e113fa4 100644 --- a/.github/workflows/release-signoff-chromium-ad-only.yml +++ b/.github/workflows/release-signoff-chromium-ad-only.yml @@ -34,17 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' - - uses: derek-ho/start-opensearch@v3 + - uses: ./.github/actions/start-opensearch with: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 - - uses: derek-ho/start-opensearch@v3 - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: true - admin-password: admin - port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ism-only.yml b/.github/workflows/release-signoff-chromium-ism-only.yml index 8c23ea37c..680331a2c 100644 --- a/.github/workflows/release-signoff-chromium-ism-only.yml +++ b/.github/workflows/release-signoff-chromium-ism-only.yml @@ -34,17 +34,11 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' - - uses: derek-ho/start-opensearch@v3 + - uses: ./.github/actions/start-opensearch with: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 - - uses: derek-ho/start-opensearch@v3 - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: true - admin-password: admin - port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index fe7c6b126..9d4bf9bdb 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -18,7 +18,7 @@ const ACCESS_KEY = 'accessKey'; const SECRET_KEY = 'secretKey'; export const CreateDataSourceNoAuth = () => { - cy.request({ + return cy.request({ method: 'POST', url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, headers: { @@ -447,8 +447,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { }); it('creates a datasources to a real opensearch instance', () => { - CreateDataSourceNoAuth(); - CreateDataSourceBasicAuth(); + CreateDataSourceNoAuth().then((resp) => { + return resp.body.id; + }); }); }); }); From 190a4600d41b16cc37244e046ac261365aeeac3b Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 11:39:00 -0400 Subject: [PATCH 08/26] Update action and usage in docs Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 98 +++++++++---------- DEVELOPER_GUIDE.md | 25 +++++ .../1_create_datasource.spec.js | 8 +- 3 files changed, 78 insertions(+), 53 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index b700f4a3a..7aada20ce 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -1,5 +1,5 @@ -name: 'Launch OpenSearch with or without plugins' -description: 'Downloads latest build of OpenSearch, optionally installs plugins, and then starts OpenSearch on localhost:9200' +name: 'Launch OpenSearch' +description: 'Downloads OpenSearch and runs it' inputs: opensearch-version: @@ -25,6 +25,7 @@ inputs: port: description: 'Port to run OpenSearch. Leave empty to use the default config (9200)' required: false + default: '9200' runs: using: "composite" @@ -46,68 +47,50 @@ runs: uses: peternied/download-file@v2 if: ${{ runner.os == 'Windows' }} with: - url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/windows/x64/zip/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-windows-x64.zip - name: Download OpenSearch for Linux uses: peternied/download-file@v2 if: ${{ runner.os == 'Linux' }} with: - url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-linux-x64-latest.tar.gz + url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/linux/x64/tar/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-linux-x64.tar.gz # Extract downloaded zip - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz + tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} run: | - tar -xzf opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip - del opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip + Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" -DestinationPath "temp" + Move-Item -Path "temp/*" -Destination "opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" + Remove-Item -Path "temp" -Recurse + Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" shell: pwsh - - name: Install plugin(s) into OpenSearch for Linux - if: ${{ runner.os == 'Linux'}} - run: | - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin - plugins="${{ inputs.plugins }}" - if [ -n "$plugins" ]; then - echo "$plugins" | tr ',' '\n' | while read -r plugin; do - /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install ${plugin}" - done - fi - shell: bash - - - name: Install plugin(s) into OpenSearch for Windows - if: ${{ runner.os == 'Windows' && inputs.plugins != '' }} - run: | - $pluginNames = "${{ inputs.plugins }}" -split ',' - if ($pluginNames.Length -gt 0) { - foreach ($plugin in $pluginNames) { - 'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install ${plugin} - } - } - shell: pwsh - - - name: Replace security configuration file if applicable - if: ${{ inputs.security_config_file != '' }} - run: | - mv ${{ inputs.security_config_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch-security/config.yml - shell: bash - # Setup security if it's enabled - name: Setup security demo configuration if: ${{ runner.os == 'Linux' && inputs.security-enabled == 'true' }} run: | echo "running linux security demo configuration setup" export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh - /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.sh -t" - echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh + opensearch_version="${{ inputs.opensearch-version }}" + opensearch_major_version=$(echo "$opensearch_version" | awk -F'.' '{print $1}') + opensearch_minor_version=$(echo "$opensearch_version" | awk -F'.' '{print $2}') + if [ "$opensearch_major_version" -lt 2 ] || ([ "$opensearch_major_version" -eq 2 ] && [ "$opensearch_minor_version" -lt 12 ]); then + echo "Running the command without -t option (OpenSearch version is $opensearch_version)" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh" + else + echo "Running the command with -t option (OpenSearch version is $opensearch_version)" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.sh -t" + fi + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Setup security demo configuration for Windows @@ -115,32 +98,49 @@ runs: run: | echo "running windows security demo configuration setup" export OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ inputs.admin-password }} - chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat - /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/plugins/opensearch-security/tools/install_demo_configuration.bat -t" - echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat + opensearch_version="${{ inputs.opensearch-version }}" + opensearch_major_version=$(echo "$opensearch_version" | cut -d'.' -f1) + opensearch_minor_version=$(echo "$opensearch_version" | cut -d'.' -f2) + if [ "$opensearch_major_version" -lt 2 ] || ([ "$opensearch_major_version" -eq 2 ] && [ "$opensearch_minor_version" -lt 12 ]); then + echo "Running the command without -t option (OpenSearch version is $opensearch_version)" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat -y -i -s" + else + echo "Running the command with -t option (OpenSearch version is $opensearch_version)" + /bin/bash -c "yes | ./opensearch-${opensearch_version}-SNAPSHOT${{ inputs.port }}/plugins/opensearch-security/tools/install_demo_configuration.bat -t -y -i -s" + fi + echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml + shell: bash + + # Disable security if it's disabled + - name: Disable security + if: ${{ inputs.security-enbaled == 'false' }} + run: | + echo "Remove OpenSearch Security" + [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> config/opensearch.yml shell: bash - name: Use more space run: | - echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml - echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml + echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - - name: Replace opensearch.yml file if applicable + - name: Use port if applicable if: ${{ inputs.port != '' }} run: | - echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml + echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash # Run OpenSearch - name: Run OpenSearch with plugin on Linux if: ${{ runner.os == 'Linux'}} - run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch &" + run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch &" shell: bash - name: Run OpenSearch with plugin on Windows if: ${{ runner.os == 'Windows'}} - run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch.bat + run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}\bin\opensearch.bat shell: pwsh # Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! @@ -177,5 +177,5 @@ runs: shell: pwsh - if: always() - run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/logs/opensearch.log + run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/logs/opensearch.log shell: bash \ No newline at end of file diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 61b451ef7..49041f00a 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -125,6 +125,31 @@ Tests for plugins that are not a part of the [OpenSearch Dashboards](https://git / ``` +### Tests for Multiple Datasources + +Tests surrounding the multiple datasources feature can use the start-opensearch action that lives in this repo. + +Example usage: +``` +- uses: ./.github/actions/start-opensearch + with: + opensearch-version: 3.0.0 + security-enabled: false + port: 9201 +``` +This will spin up an OpenSearch backend with version 3.0.0 on port 9201 within the same github runner. This OpenSearch can then be added as an datasource. + +The DataSourceManagement Plugin exposes a helper function to create a helper function on this port: +``` +import {CreateDataSourceNoAuth} from 'datasource-management-plugin' + +CreateDataSourceNoAuth('9201').then((resp) => { + console.log(resp.body.id); + }); + +# Add tests that make calls to resp.body.id +``` + ### Experimental Features When writing tests for experimental features, please follow these steps. diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 9d4bf9bdb..e123dd2f9 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -17,7 +17,7 @@ const REGION = 'us-east-1'; const ACCESS_KEY = 'accessKey'; const SECRET_KEY = 'secretKey'; -export const CreateDataSourceNoAuth = () => { +export const CreateDataSourceNoAuth = (port) => { return cy.request({ method: 'POST', url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, @@ -27,7 +27,7 @@ export const CreateDataSourceNoAuth = () => { body: { attributes: { title: `9201`, - endpoint: `http://localhost:9201`, + endpoint: `http://localhost:${port}`, auth: { type: 'no_auth', }, @@ -447,8 +447,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { }); it('creates a datasources to a real opensearch instance', () => { - CreateDataSourceNoAuth().then((resp) => { - return resp.body.id; + CreateDataSourceNoAuth('9201').then((resp) => { + console.log(resp.body.id); }); }); }); From 42dd612c9ff7e6619c026851d14275240784e95b Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 11:42:01 -0400 Subject: [PATCH 09/26] Checkout before access Signed-off-by: Derek Ho --- .github/workflows/release-e2e-workflow-template-windows.yml | 2 ++ .github/workflows/release-e2e-workflow-template.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release-e2e-workflow-template-windows.yml b/.github/workflows/release-e2e-workflow-template-windows.yml index 5dda02f39..c2f69f49c 100644 --- a/.github/workflows/release-e2e-workflow-template-windows.yml +++ b/.github/workflows/release-e2e-workflow-template-windows.yml @@ -25,6 +25,8 @@ jobs: # 2.12 onwards security demo configuration require a custom admin password OPENSEARCH_INITIAL_ADMIN_PASSWORD: 'myStrongPassword123!' steps: + - name: Checkout Branch + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v1 with: diff --git a/.github/workflows/release-e2e-workflow-template.yml b/.github/workflows/release-e2e-workflow-template.yml index 6dd2b8128..09e778b3c 100644 --- a/.github/workflows/release-e2e-workflow-template.yml +++ b/.github/workflows/release-e2e-workflow-template.yml @@ -28,6 +28,8 @@ jobs: # 2.12 onwards security demo configuration require a custom admin password OPENSEARCH_INITIAL_ADMIN_PASSWORD: 'myStrongPassword123!' steps: + - name: Checkout Branch + uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v1 with: From b5bc25aa74c63fa0d446c8a5c1cc91de9f94e559 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 11:46:54 -0400 Subject: [PATCH 10/26] Add relative path Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 7aada20ce..0d25b42f2 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -117,7 +117,7 @@ runs: if: ${{ inputs.security-enbaled == 'false' }} run: | echo "Remove OpenSearch Security" - [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> config/opensearch.yml + [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Use more space From 1037a224a371ac18e01f8dd2ecaeac677be4cb84 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 11:51:43 -0400 Subject: [PATCH 11/26] Fix spelling Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 0d25b42f2..776bc1942 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -114,7 +114,7 @@ runs: # Disable security if it's disabled - name: Disable security - if: ${{ inputs.security-enbaled == 'false' }} + if: ${{ inputs.security-enabled == 'false' }} run: | echo "Remove OpenSearch Security" [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml From 3521a62512a642eaca028e44e27e488b175f6fd1 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 13:00:20 -0400 Subject: [PATCH 12/26] Remove -d Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 776bc1942..c29597e5a 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -117,7 +117,7 @@ runs: if: ${{ inputs.security-enabled == 'false' }} run: | echo "Remove OpenSearch Security" - [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml + echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - name: Use more space From 26f4063daa4e6ddf7d4dffdb53eecfed8962b0b7 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 13:42:58 -0400 Subject: [PATCH 13/26] Move port logic Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index c29597e5a..bfba61376 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -124,12 +124,7 @@ runs: run: | echo '' >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml - shell: bash - - - name: Use port if applicable - if: ${{ inputs.port != '' }} - run: | - echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml + echo "http.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash # Run OpenSearch From bd6b99c09e9e55dafb8c204c187a2ab4b60f51a0 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:11:27 -0400 Subject: [PATCH 14/26] Cat log Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index bfba61376..89bc7e8fa 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -173,4 +173,8 @@ runs: - if: always() run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/logs/opensearch.log + shell: bash + + - if: always() + run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash \ No newline at end of file From 10ed3c21ec6092eb214168bfc8ad6609d23d86aa Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:17:08 -0400 Subject: [PATCH 15/26] Allow modification Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 89bc7e8fa..0292a3694 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -117,6 +117,7 @@ runs: if: ${{ inputs.security-enabled == 'false' }} run: | echo "Remove OpenSearch Security" + chmod + x ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash From 5929aab346d8f1c7ffef1edf25aa7900faa0efe5 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:26:15 -0400 Subject: [PATCH 16/26] Duplicate download Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 0292a3694..282dcbe34 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -60,14 +60,14 @@ runs: - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} + tar -xzf opensearch-*.tar.gz.1 && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} run: | - Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" -DestinationPath "temp" + Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip.1" -DestinationPath "temp" Move-Item -Path "temp/*" -Destination "opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" From 8ef0669c882f903a3d46037e91888fb1a9ef8617 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:32:07 -0400 Subject: [PATCH 17/26] Change directory Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 282dcbe34..fa8180bdc 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -42,6 +42,12 @@ runs: with: java-version: 11 + - name: Change directory + run: | + mkdir test + cd test + shell: bash + # Download OpenSearch - name: Download OpenSearch for Windows uses: peternied/download-file@v2 From 05f710d48165256c139ae45586fddb4884307ca9 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:33:08 -0400 Subject: [PATCH 18/26] Change name Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index fa8180bdc..829a3e643 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -47,7 +47,7 @@ runs: mkdir test cd test shell: bash - + # Download OpenSearch - name: Download OpenSearch for Windows uses: peternied/download-file@v2 @@ -66,7 +66,7 @@ runs: - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz.1 && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} + tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash From adf18e403886628a9fd70412381ca64f93ba2abc Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:34:55 -0400 Subject: [PATCH 19/26] Remove extra chmod Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 829a3e643..98db62f31 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -123,7 +123,6 @@ runs: if: ${{ inputs.security-enabled == 'false' }} run: | echo "Remove OpenSearch Security" - chmod + x ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash From 466639ddc78072b22d4ff770f96ef03fe41b2bef Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:42:37 -0400 Subject: [PATCH 20/26] Within test directory Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 98db62f31..6cb0fc312 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -45,7 +45,6 @@ runs: - name: Change directory run: | mkdir test - cd test shell: bash # Download OpenSearch @@ -54,6 +53,7 @@ runs: if: ${{ runner.os == 'Windows' }} with: url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/windows/x64/zip/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-windows-x64.zip + target: ./test/ - name: Download OpenSearch for Linux @@ -61,6 +61,7 @@ runs: if: ${{ runner.os == 'Linux' }} with: url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/linux/x64/tar/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-linux-x64.tar.gz + target: ./test/ # Extract downloaded zip - name: Extract downloaded tar @@ -69,6 +70,7 @@ runs: tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash + working-directory: test - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} @@ -78,6 +80,7 @@ runs: Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" shell: pwsh + working-directory: test # Setup security if it's enabled - name: Setup security demo configuration @@ -98,6 +101,7 @@ runs: fi echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash + working-directory: test - name: Setup security demo configuration for Windows if: ${{ runner.os == 'Windows' && inputs.security-enabled == 'true' }} @@ -117,6 +121,7 @@ runs: fi echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash + working-directory: test # Disable security if it's disabled - name: Disable security @@ -125,6 +130,7 @@ runs: echo "Remove OpenSearch Security" echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash + working-directory: test - name: Use more space run: | @@ -132,17 +138,20 @@ runs: echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml echo "http.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash + working-directory: test # Run OpenSearch - name: Run OpenSearch with plugin on Linux if: ${{ runner.os == 'Linux'}} run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch &" shell: bash + working-directory: test - name: Run OpenSearch with plugin on Windows if: ${{ runner.os == 'Windows'}} run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}\bin\opensearch.bat shell: pwsh + working-directory: test # Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! - name: Sleep while OpenSearch starts @@ -160,6 +169,7 @@ runs: curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v fi shell: bash + working-directory: test - name: Check OpenSearch Running on Windows if: ${{ runner.os == 'Windows'}} @@ -176,11 +186,14 @@ runs: } Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers; shell: pwsh + working-directory: test - if: always() run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/logs/opensearch.log shell: bash + working-directory: test - if: always() run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml - shell: bash \ No newline at end of file + shell: bash + working-directory: test \ No newline at end of file From 639485937131b1ecee163d66ca03b975e92ffd9d Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 14:49:53 -0400 Subject: [PATCH 21/26] Fix Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 6cb0fc312..57a242104 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -53,7 +53,6 @@ runs: if: ${{ runner.os == 'Windows' }} with: url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/windows/x64/zip/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-windows-x64.zip - target: ./test/ - name: Download OpenSearch for Linux @@ -61,16 +60,14 @@ runs: if: ${{ runner.os == 'Linux' }} with: url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/linux/x64/tar/dist/opensearch/opensearch-${{ inputs.opensearch-version }}-linux-x64.tar.gz - target: ./test/ # Extract downloaded zip - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz && mv opensearch-${{ inputs.opensearch-version }} opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} + tar -xzf opensearch-*.tar.gz -C test && mv test/opensearch-${{ inputs.opensearch-version }} test/opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash - working-directory: test - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} From ca96d3ab89591b44b06116088796360a3917c4f8 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 15:15:50 -0400 Subject: [PATCH 22/26] Fix for windows, add helper function, show usage Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 4 ++-- .../release-signoff-chromium-ad-only.yml | 5 ---- .../release-signoff-chromium-ism-only.yml | 5 ---- DEVELOPER_GUIDE.md | 6 +---- .../1_create_datasource.spec.js | 23 +------------------ .../commands.js | 23 +++++++++++++++++++ 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 57a242104..726beb43e 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -72,10 +72,10 @@ runs: - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} run: | - Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip.1" -DestinationPath "temp" + Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" -DestinationPath "temp" Move-Item -Path "temp/*" -Destination "opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" Remove-Item -Path "temp" -Recurse - Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64-latest.zip" + Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" shell: pwsh working-directory: test diff --git a/.github/workflows/release-signoff-chromium-ad-only.yml b/.github/workflows/release-signoff-chromium-ad-only.yml index 53e113fa4..d4db844d9 100644 --- a/.github/workflows/release-signoff-chromium-ad-only.yml +++ b/.github/workflows/release-signoff-chromium-ad-only.yml @@ -34,11 +34,6 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' - - uses: ./.github/actions/start-opensearch - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: false - port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chromium-ism-only.yml b/.github/workflows/release-signoff-chromium-ism-only.yml index 680331a2c..6f0d5d3d1 100644 --- a/.github/workflows/release-signoff-chromium-ism-only.yml +++ b/.github/workflows/release-signoff-chromium-ism-only.yml @@ -34,11 +34,6 @@ jobs: cd opensearch-${{ env.VERSION }}/ ./opensearch-tar-install.sh & timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do sleep 5; done' - - uses: ./.github/actions/start-opensearch - with: - opensearch-version: ${{ env.VERSION }} - security-enabled: false - port: 9201 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 907145761..f2afed3c8 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -142,11 +142,7 @@ This will spin up an OpenSearch backend with version 3.0.0 on port 9201 within t The DataSourceManagement Plugin exposes a helper function to create a helper function on this port: ``` -import {CreateDataSourceNoAuth} from 'datasource-management-plugin' - -CreateDataSourceNoAuth('9201').then((resp) => { - console.log(resp.body.id); - }); +const id = cy.createDataSourceNoAuth(); # Add tests that make calls to resp.body.id ``` diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 7411e2f57..9dbce0d14 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -23,25 +23,6 @@ const miscUtils = new MiscUtils(cy); const username = Cypress.env('username'); const password = Cypress.env('password'); -export const CreateDataSourceNoAuth = (port) => { - return cy.request({ - method: 'POST', - url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, - headers: { - 'osd-xsrf': true, - }, - body: { - attributes: { - title: `9201`, - endpoint: `http://localhost:${port}`, - auth: { - type: 'no_auth', - }, - }, - }, - }); -}; - export const CreateDataSourceBasicAuth = () => { miscUtils.visitPage( 'app/management/opensearch-dashboards/dataSources/create' @@ -432,9 +413,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { }); it('creates a datasources to a real opensearch instance', () => { - CreateDataSourceNoAuth('9201').then((resp) => { - console.log(resp.body.id); - }); + cy.createDataSourceNoAuth(); }); }); }); diff --git a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js index 3d34fc494..f332c66e3 100644 --- a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js +++ b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js @@ -29,6 +29,29 @@ Cypress.Commands.add('deleteAllDataSources', () => { ); }); +Cypress.Commands.add('createDataSourceNoAuth', () => { + cy.request({ + method: 'POST', + url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, + headers: { + 'osd-xsrf': true, + }, + body: { + attributes: { + title: `9201`, + endpoint: `http://localhost:9201`, + auth: { + type: 'no_auth', + }, + }, + }, + }).then((resp) => { + if (resp && resp.body && resp.body.id) { + return resp.body.id; + } + }); +}); + Cypress.Commands.add('createDataSource', (dataSourceJSON) => { cy.request({ method: 'POST', From 5c2e239c944185f9709c57ec6f82d8b653d3ca12 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 15:19:25 -0400 Subject: [PATCH 23/26] Remove pwd Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 726beb43e..54a6acb53 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -77,7 +77,6 @@ runs: Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" shell: pwsh - working-directory: test # Setup security if it's enabled - name: Setup security demo configuration From 5263a920b5f79896ed668cb8d20836e77da57608 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 19 Apr 2024 15:23:36 -0400 Subject: [PATCH 24/26] Move to temp dire Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index 54a6acb53..b4f55624f 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -73,7 +73,7 @@ runs: if: ${{ runner.os == 'Windows' }} run: | Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" -DestinationPath "temp" - Move-Item -Path "temp/*" -Destination "opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" + Move-Item -Path "temp/*" -Destination "test/opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" shell: pwsh From 46d3442825d45ef318d72cd3a45aac3f4c0078da Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 22 Apr 2024 09:18:31 -0400 Subject: [PATCH 25/26] Address PR feedback and try to spin up an instance with security Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 28 ++++++++-------- .../release-e2e-workflow-template-windows.yml | 6 ++++ .../release-e2e-workflow-template.yml | 6 ++++ .github/workflows/release-signoff-chrome.yml | 6 ++++ DEVELOPER_GUIDE.md | 23 ++++++++++--- cypress.json | 4 +++ .../1_create_datasource.spec.js | 24 -------------- .../commands.js | 33 +++++++++++++++++-- 8 files changed, 85 insertions(+), 45 deletions(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index b4f55624f..d70d91df1 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -42,9 +42,9 @@ runs: with: java-version: 11 - - name: Change directory + - name: Create temporary directory run: | - mkdir test + mkdir ${{ inputs.port }} shell: bash # Download OpenSearch @@ -65,7 +65,7 @@ runs: - name: Extract downloaded tar if: ${{ runner.os == 'Linux' }} run: | - tar -xzf opensearch-*.tar.gz -C test && mv test/opensearch-${{ inputs.opensearch-version }} test/opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} + tar -xzf opensearch-*.tar.gz -C ${{ inputs.port }} && mv ${{ inputs.port }}/opensearch-${{ inputs.opensearch-version }} ${{ inputs.port }}/opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }} rm -f opensearch-*.tar.gz shell: bash @@ -73,7 +73,7 @@ runs: if: ${{ runner.os == 'Windows' }} run: | Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" -DestinationPath "temp" - Move-Item -Path "temp/*" -Destination "test/opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" + Move-Item -Path "temp/*" -Destination "${{ inputs.port }}/opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" shell: pwsh @@ -97,7 +97,7 @@ runs: fi echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - working-directory: test + working-directory: ${{ inputs.port }} - name: Setup security demo configuration for Windows if: ${{ runner.os == 'Windows' && inputs.security-enabled == 'true' }} @@ -117,7 +117,7 @@ runs: fi echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - working-directory: test + working-directory: ${{ inputs.port }} # Disable security if it's disabled - name: Disable security @@ -126,7 +126,7 @@ runs: echo "Remove OpenSearch Security" echo "plugins.security.disabled: true" >> ./opensearch-${{inputs.opensearch-version}}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - working-directory: test + working-directory: ${{ inputs.port }} - name: Use more space run: | @@ -134,20 +134,20 @@ runs: echo "cluster.routing.allocation.disk.threshold_enabled: false" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml echo "http.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - working-directory: test + working-directory: ${{ inputs.port }} # Run OpenSearch - name: Run OpenSearch with plugin on Linux if: ${{ runner.os == 'Linux'}} run: /bin/bash -c "./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/bin/opensearch &" shell: bash - working-directory: test + working-directory: ${{ inputs.port }} - name: Run OpenSearch with plugin on Windows if: ${{ runner.os == 'Windows'}} run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}\bin\opensearch.bat shell: pwsh - working-directory: test + working-directory: ${{ inputs.port }} # Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! - name: Sleep while OpenSearch starts @@ -165,7 +165,7 @@ runs: curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v fi shell: bash - working-directory: test + working-directory: ${{ inputs.port }} - name: Check OpenSearch Running on Windows if: ${{ runner.os == 'Windows'}} @@ -182,14 +182,14 @@ runs: } Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers; shell: pwsh - working-directory: test + working-directory: ${{ inputs.port }} - if: always() run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/logs/opensearch.log shell: bash - working-directory: test + working-directory: ${{ inputs.port }} - if: always() run: cat ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}/config/opensearch.yml shell: bash - working-directory: test \ No newline at end of file + working-directory: ${{ inputs.port }} \ No newline at end of file diff --git a/.github/workflows/release-e2e-workflow-template-windows.yml b/.github/workflows/release-e2e-workflow-template-windows.yml index c2f69f49c..fd9bc1dc4 100644 --- a/.github/workflows/release-e2e-workflow-template-windows.yml +++ b/.github/workflows/release-e2e-workflow-template-windows.yml @@ -76,6 +76,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: ./.github/actions/start-opensearch + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get and run OpenSearch-Dashboards run: | curl -SLO https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/${{ env.PLATFORM }}/x64/zip/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-${{ env.PLATFORM }}-x64.zip diff --git a/.github/workflows/release-e2e-workflow-template.yml b/.github/workflows/release-e2e-workflow-template.yml index 09e778b3c..2f2b62926 100644 --- a/.github/workflows/release-e2e-workflow-template.yml +++ b/.github/workflows/release-e2e-workflow-template.yml @@ -73,6 +73,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: ./.github/actions/start-opensearch + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/.github/workflows/release-signoff-chrome.yml b/.github/workflows/release-signoff-chrome.yml index f7d4e61e2..2af455edf 100644 --- a/.github/workflows/release-signoff-chrome.yml +++ b/.github/workflows/release-signoff-chrome.yml @@ -39,6 +39,12 @@ jobs: opensearch-version: ${{ env.VERSION }} security-enabled: false port: 9201 + - uses: ./.github/actions/start-opensearch + with: + opensearch-version: ${{ env.VERSION }} + security-enabled: true + admin-password: admin + port: 9202 - name: Get OpenSearch-Dashboards run: | wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{ env.VERSION }}/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-${{ env.VERSION }}-linux-x64.tar.gz diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index f2afed3c8..f1a052fb0 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -128,7 +128,7 @@ Tests for plugins that are not a part of the [OpenSearch Dashboards](https://git ### Tests for Multiple Datasources -Tests surrounding the multiple datasources feature can use the start-opensearch action that lives in this repo. +Tests surrounding the multiple datasources feature can use the start-opensearch action that lives in this repo. Note that to test these related features, the following OSD config needs to be set: `osd-serve-args: --data_source.enabled=true`. Additionally, if testing with a remote datasource with basic auth enabled using this repo, an additional OSD config needs to be set: `osd-serve-args: --data_source.ssl.verificationMode: none`, so that the self-signed demo certificates can be used. Example usage: ``` @@ -138,13 +138,28 @@ Example usage: security-enabled: false port: 9201 ``` + + This will spin up an OpenSearch backend with version 3.0.0 on port 9201 within the same github runner. This OpenSearch can then be added as an datasource. -The DataSourceManagement Plugin exposes a helper function to create a helper function on this port: ``` -const id = cy.createDataSourceNoAuth(); +- uses: ./.github/actions/start-opensearch + with: + opensearch-version: 3.0.0 + security-enabled: true + admin-password: admin + port: 9202 +``` +This will spin up an OpenSearch backend with version 3.0.0 on port 9202 with basic auth and admin credentials of "admin:admin" within the same github runner. This OpenSearch can then be added as an datasource. + + +The DataSourceManagement Plugin exposes a helper function to create a data source on this port: +``` +const [noAuthId, noAuthLabel] = cy.createDataSourceNoAuth(); + +const [basicAuthId, basicAuthLabel] = cy.createDataSourceBasicAuth(); -# Add tests that make calls to resp.body.id +# Add tests that make calls using noAuthId and basicAuthId, or test that remote datasource via the UI using the labels noAuthLabel and basicAuthLabel. ``` ### Experimental Features diff --git a/cypress.json b/cypress.json index b6ecf4119..41c52a98c 100644 --- a/cypress.json +++ b/cypress.json @@ -11,6 +11,10 @@ "viewportHeight": 1320, "env": { "openSearchUrl": "http://localhost:9200", + "remoteDataSourceNoAuthUrl": "http://localhost:9201", + "remoteDataSourceBasicAuthUrl": "https://localhost:9202", + "remoteDataSourceBasicAuthUsername": "admin", + "remoteDataSourceBasicAuthPassword": "admin", "SECURITY_ENABLED": false, "AGGREGATION_VIEW": false, "username": "admin", diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js index 9dbce0d14..34982fd0e 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js @@ -23,30 +23,6 @@ const miscUtils = new MiscUtils(cy); const username = Cypress.env('username'); const password = Cypress.env('password'); -export const CreateDataSourceBasicAuth = () => { - miscUtils.visitPage( - 'app/management/opensearch-dashboards/dataSources/create' - ); - - cy.get('[data-test-subj="createDataSourceButton"]').should('be.disabled'); - cy.get('[name="dataSourceTitle"]').type('9201'); - cy.get('[name="endpoint"]').type('https://localhost:9202'); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type('admin'); - cy.get('[data-test-subj="createDataSourceFormPasswordField"]').type('admin'); - cy.get('[data-test-subj="createDataSourceButton"]').should('be.enabled'); - cy.get('[name="dataSourceDescription"]').type( - 'cypress test basic auth data source' - ); - cy.get('[data-test-subj="createDataSourceButton"]').click(); - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); -}; - // TODO: create datasource with basic auth and sigv4 if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { diff --git a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js index f332c66e3..da4915e70 100644 --- a/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js +++ b/cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js @@ -38,8 +38,8 @@ Cypress.Commands.add('createDataSourceNoAuth', () => { }, body: { attributes: { - title: `9201`, - endpoint: `http://localhost:9201`, + title: 'RemoteDataSourceNoAuth', + endpoint: Cypress.env('remoteDataSourceNoAuthUrl'), auth: { type: 'no_auth', }, @@ -47,7 +47,34 @@ Cypress.Commands.add('createDataSourceNoAuth', () => { }, }).then((resp) => { if (resp && resp.body && resp.body.id) { - return resp.body.id; + return [resp.body.id, 'RemoteDataSourceNoAuth']; + } + }); +}); + +Cypress.Commands.add('createDataSourceBasicAuth', () => { + cy.request({ + method: 'POST', + url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source`, + headers: { + 'osd-xsrf': true, + }, + body: { + attributes: { + title: 'RemoteDataSourceBasicAuth', + endpoint: Cypress.env('remoteDataSourceBasicAuthUrl'), + auth: { + type: 'username_password', + credentials: { + username: Cypress.env('remoteDataSourceBasicAuthUsername'), + password: Cypress.env('remoteDataSourceBasicAuthPassword'), + }, + }, + }, + }, + }).then((resp) => { + if (resp && resp.body && resp.body.id) { + return [resp.body.id, 'RemoteDataSourceBasicAuth']; } }); }); From d0839fa394b1830a0c2378be5e488eab0eef9407 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 22 Apr 2024 10:16:38 -0400 Subject: [PATCH 26/26] Small action change and documentation add Signed-off-by: Derek Ho --- .github/actions/start-opensearch/action.yml | 2 +- DEVELOPER_GUIDE.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/start-opensearch/action.yml b/.github/actions/start-opensearch/action.yml index d70d91df1..2425cc2b9 100644 --- a/.github/actions/start-opensearch/action.yml +++ b/.github/actions/start-opensearch/action.yml @@ -72,7 +72,7 @@ runs: - name: Extract downloaded zip if: ${{ runner.os == 'Windows' }} run: | - Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" -DestinationPath "temp" + Expand-Archive -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip" -DestinationPath "temp" Move-Item -Path "temp/*" -Destination "${{ inputs.port }}/opensearch-${{ inputs.opensearch-version }}-SNAPSHOT${{ inputs.port }}" Remove-Item -Path "temp" -Recurse Remove-Item -Path "opensearch-${{ inputs.opensearch-version }}-windows-x64.zip.1" diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index f1a052fb0..37a4f2e32 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -152,6 +152,8 @@ This will spin up an OpenSearch backend with version 3.0.0 on port 9201 within t ``` This will spin up an OpenSearch backend with version 3.0.0 on port 9202 with basic auth and admin credentials of "admin:admin" within the same github runner. This OpenSearch can then be added as an datasource. +To test UI/API compatibility with different versions you may want to spin up a matrix of OpenSearch backends with different versions than the local cluster. The earliest windows distribution supported is 2.4. + The DataSourceManagement Plugin exposes a helper function to create a data source on this port: ```