Skip to content

Commit

Permalink
Add Windows workflow on cypress bundle build (opensearch-project#367)
Browse files Browse the repository at this point in the history
* Add osd e2e core test for Windows Runner

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add e2e windows

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Remove extra newline

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add newline checks

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Restore windows and dynamic version assignment

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Jakub Przybylski <jakub.przybylski@eliatra.com>
  • Loading branch information
2 people authored and jakubp-eliatra committed Mar 24, 2023
1 parent 052b222 commit cb28f2b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Bundle Snapshot based E2E Cypress tests workflow for core Dashboards (Windows)
on:
pull_request:
branches:
- main
- dev-*
push:
branches:
- main
- dev-*

jobs:
changes:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.filter.outputs.tests }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
tests:
- 'cypress/**/core-opensearch-dashboards/**'
tests:
needs: changes
if: ${{ needs.changes.outputs.tests == 'true' }}
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
test-command: env CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
# not useful now as the windows e2e template currently do not allow serving parameters
#osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true
102 changes: 102 additions & 0 deletions .github/workflows/release-e2e-workflow-template-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Release tests workflow in Bundled OpenSearch Dashboards (Windows)
on:
workflow_call:
inputs:
test-name:
required: true
type: string
test-command:
required: true
type: string
jobs:
tests:
name: Run Cypress E2E tests for ${{ inputs.test-name }}
runs-on: windows-latest
env:
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 14
- name: Checkout cypress-test
uses: actions/checkout@v2
with:
repository: ${{github.repository}}
path: cypress-test
- name: Get package version
working-directory: cypress-test
run: |
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
echo "PLATFORM=windows" >> $GITHUB_ENV
shell: bash
- name: Get and run OpenSearch
run: |
curl -SLO https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ env.VERSION }}/latest/${{ env.PLATFORM }}/x64/zip/dist/opensearch/opensearch-${{ env.VERSION }}-${{ env.PLATFORM }}-x64.zip
unzip -q opensearch-${{ env.VERSION }}-windows-x64.zip
cd opensearch-${{ env.VERSION }}/
nohup ./opensearch-windows-install.bat &
timeout 900 bash -c 'while [[ "$(curl -o /dev/null -w ''%{http_code}'' -u admin:admin -k https://localhost:9200)" != "200" ]]; do echo sleeping 5; sleep 5; done'
curl -sk https://localhost:9200/_cluster/health?pretty -u admin:admin
netstat -anP tcp | grep LISTEN | grep 9200 || netstat -ntlp | grep 9200
shell: bash
- 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
unzip -q opensearch-dashboards-${{ env.VERSION }}-windows-x64.zip
shell: bash
- name: Get node and yarn versions
run: |
echo "node_version=$(jq -r '.engines.node' ./opensearch-dashboards-${{ env.VERSION }}/package.json)" >> $GITHUB_ENV
shell: bash
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.node_version }}
registry-url: 'https://registry.npmjs.org'
- name: Run OpenSearch-Dashboards server
run: |
netstat -anP tcp | grep LISTEN | grep 9200 || netstat -ntlp | grep 9200
cd opensearch-dashboards-${{ env.VERSION }}
# Temporary solution to add vis_builder and data_source enabled parameters
echo "vis_builder.enabled: true" >> config/opensearch_dashboards.yml
echo "data_source.enabled: true" >> config/opensearch_dashboards.yml
# Not useful now as error shows when trying to force a background run with parameters on Windows
bin/opensearch-dashboards.bat serve ${{ inputs.osd-serve-args }} &
bin/opensearch-dashboards.bat &
timeout 300 bash -c 'while [[ "$(curl http://localhost:5601/api/status -u admin:admin | jq -r '.status.overall.state')" != "green" ]]; do echo sleeping 5; sleep 5; done'
curl -sk localhost:5601/api/status -u admin:admin | jq
netstat -anP tcp | grep LISTEN | grep 5601 || netstat -ntlp | grep 5601
shell: bash
- name: Get Cypress version
run: |
cd ./cypress-test
npm install
shell: bash
- name: Cypress tests
uses: cypress-io/github-action@v2
with:
working-directory: cypress-test
command: ${{ inputs.test-command }}
wait-on: 'http://localhost:5601'
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: cypress-test/cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-videos
path: cypress-test/cypress/videos
# Test reports was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-results
path: cypress-test/cypress/results
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

import { dashboardSanityTests } from '../../common/dashboard_sample_data_spec.js';


dashboardSanityTests();
4 changes: 2 additions & 2 deletions test_finder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

OSD_BUILD_MANIFEST='../local-test-cluster/opensearch-dashboards-*/manifest.yml'
OSD_TEST_PATH='cypress/integration/core-opensearch-dashboards/opensearch-dashboards'
OSD_TEST_PATH='cypress/integration/core-opensearch-dashboards'
OSD_PLUGIN_TEST_PATH='cypress/integration/plugins'

# Map component name in opensearch-build repo INPUT_MANIFEST with folder name for tests in functional repo
Expand Down Expand Up @@ -46,7 +46,7 @@ function get_test_list() {

if [ "$component_name" = "OpenSearch-Dashboards" ]; then
TEST_PATH_LOCAL=$OSD_TEST_PATH
TEST_FILES_EXT_LOCAL="*.js"
TEST_FILES_EXT_LOCAL="**/*.js"
else
TEST_PATH_LOCAL=$OSD_PLUGIN_TEST_PATH
TEST_FILES_EXT_LOCAL="*"
Expand Down

0 comments on commit cb28f2b

Please sign in to comment.