Skip to content

Commit

Permalink
Enable cypress test for windows and mac platform
Browse files Browse the repository at this point in the history
Signed-off-by: Heemin Kim <[email protected]>
  • Loading branch information
heemin32 committed Nov 23, 2022
1 parent 7e33614 commit 12787ce
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 19 deletions.
93 changes: 84 additions & 9 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,60 @@ env:
OPENSEARCH_VERSION: '2.4.0-SNAPSHOT'
jobs:
tests:
name: Run Cypress E2E tests
runs-on: ubuntu-latest
env:
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
WORKING_DIR: ${{ matrix.working_directory }}.
strategy:
# This setting says that all jobs should finish, even if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
include:
- os: windows-latest
working_directory: X:\
os_java_options: -Xmx6144M
cypress_cache_folder: ~/AppData/Local/Cypress/Cache
- os: ubuntu-latest
cypress_cache_folder: ~/.cache/Cypress
- os: macos-latest
cypress_cache_folder: ~/Library/Caches/Cypress
name: Test and Build Dashboards Maps on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11

# This is a hack, but this step creates a link to the X: mounted drive, which makes the path
# short enough to work on Windows
- name: Shorten Path
if: ${{ matrix.os == 'windows-latest' }}
run: subst 'X:' .

- name: Checkout geospatial plugin
uses: actions/checkout@v2
with:
path: geospatial
repository: opensearch-project/geospatial
ref: '2.4'

- name: Run Opensearch with plugin
working-directory: ${{ env.WORKING_DIR }}
run: |
# Install coreutils for macOS since timeout doesn't seem to available on that OS even when forcing bash shell
if [ "$RUNNER_OS" == "macOS" ]; then
brew install coreutils
fi
cd geospatial
./gradlew run &
timeout 600 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
shell: bash
env:
_JAVA_OPTIONS: ${{ matrix.os_java_options }}
- name: Checkout Plugin
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -65,7 +96,13 @@ jobs:
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
- name: Set npm to use bash for shell
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Sets Windows to use bash for npm shell so the script commands work as intended
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
- name: Move custom_import_map to Plugins Dir
run: |
mv dashboards-maps/src/plugins/custom_import_map OpenSearch-Dashboards/plugins/custom_import_map
Expand All @@ -79,26 +116,64 @@ jobs:
run: |
cd OpenSearch-Dashboards
yarn start --no-base-path --no-watch &
sleep 300
# timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5601/api/status)" != "200" ]]; do sleep 5; done'
shell: bash

- name: Sleep until OSD server starts - windows
if: ${{ matrix.os == 'windows-latest' }}
run: Start-Sleep -s 300
shell: powershell

- name: Sleep until OSD server starts - non-windows
if: ${{ matrix.os != 'windows-latest' }}
run: sleep 300
shell: bash

- name: Install Cypress
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
# This will install Cypress in case the binary is missing which can happen on Windows and Mac
# If the binary exists, this will exit quickly so it should not be an expensive operation
npx cypress install
shell: bash

- name: Get Cypress version
id: cypress_version
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: ${{ matrix.cypress_cache_folder }}
key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}

- name: Reset npm's script shell
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Resetting npm's script shell for Windows so `yarn run cypress` doesn't have conflicts
npm config delete script-shell
- name: Run Cypress tests
uses: cypress-io/github-action@v2
with:
working-directory: OpenSearch-Dashboards/plugins/custom_import_map
command: yarn run cypress run
command: yarn run cypress run --browser chrome
wait-on: 'http://localhost:5601'
browser: chrome
env:
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}

# 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
name: cypress-screenshots-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/custom_import_map/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
name: cypress-videos-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/custom_import_map/cypress/videos
2 changes: 1 addition & 1 deletion src/plugins/custom_import_map/cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultCommandTimeout": 10000,
"defaultCommandTimeout": 120000,
"env": {
"opensearch_url": "localhost:9200",
"opensearch_dashboards": "http://localhost:5601",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe('Verify successful custom geojson file upload', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);
// Click on "Sample data" tab
cy.contains('Sample data', { timeout: 60000 }).click({ force: true });
cy.contains('Sample data').click({ force: true });
// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({
force: true,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 60000 });
cy.contains('Sample flight data installed', { timeout: 240000 });

cy.visit(`${BASE_PATH}/app/visualize#/`);

Expand All @@ -40,7 +40,7 @@ describe('Verify successful custom geojson file upload', () => {
cy.get('[data-testId="filePicker"]').attachFile('sample_geojson.json');
cy.get('[data-testId="customIndex"]').type('sample');
cy.contains('Import file').click({ force: true });
cy.contains('Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.', { timeout: 60000 });
cy.contains('Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.', { timeout: 240000 });
})

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ describe('Verify the presence of import custom map tab in region map plugin', ()
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);
// Click on "Sample data" tab
cy.contains('Sample data', { timeout: 60000 }).click({ force: true });
cy.contains('Sample data').click({ force: true });
// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({
force: true,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 60000 });
cy.contains('Sample flight data installed', { timeout: 240000 });

cy.visit(`${BASE_PATH}/app/visualize#/`);

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/custom_import_map/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "customImportMapDashboards",
"version": "2.4.0.0",
"opensearchDashboardsVersion": "2.4.0",
"version": "2.4.1.0",
"opensearchDashboardsVersion": "2.4.1",
"server": true,
"ui": true,
"requiredPlugins": ["regionMap", "opensearchDashboardsReact"],
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/custom_import_map/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "customImportMap",
"version": "2.4.0.0",
"version": "2.4.1.0",
"license": "Apache-2.0",
"config": {
"id": "customImportMapDashboards"
Expand Down

0 comments on commit 12787ce

Please sign in to comment.