forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC for running cypress tests outside FT repo
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
- Loading branch information
1 parent
b796940
commit b925e1e
Showing
9 changed files
with
746 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: remote_cypress_workflow | ||
run-name: remote_cypress_workflow [${{ inputs.build_id}}] # Unique workflow number appended to the workflow run-name to filter the run results based on that. | ||
# trigger on every PR for all branches | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
test_repo: | ||
description: 'Cypress test repo' | ||
default: '' | ||
required: false | ||
type: string | ||
test_branch: | ||
description: 'Cypress test branch (default: source branch)' | ||
required: false | ||
type: string | ||
specs: | ||
description: 'Tests to run (default: osd:ciGroup)' | ||
required: false | ||
type: string | ||
build_id: | ||
description: 'Unique Id for Job' | ||
required: false | ||
type: string | ||
|
||
env: | ||
TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || github.repository }} | ||
TEST_BRANCH: "${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }}" | ||
FTR_PATH: 'cypress' | ||
START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true' | ||
OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot -E cluster.routing.allocation.disk.threshold_enabled=false' | ||
CYPRESS_BROWSER: 'chromium' | ||
JOB_ID: ${{ inputs.build_id}} | ||
|
||
jobs: | ||
cypress-tests: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2 | ||
options: --user 1001 | ||
env: | ||
# prevents extra Cypress installation progress messages | ||
CI: 1 | ||
# avoid warnings like "tput: No value for $TERM and no -T specified" | ||
TERM: xterm | ||
name: Run cypress tests (${{ inputs.build_id}}) | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ${{ env.SOURCE_REPO }} | ||
ref: '${{ env.SOURCE_BRANCH }}' | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version-file: '.nvmrc' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Setup Yarn | ||
run: | | ||
npm uninstall -g yarn | ||
npm i -g [email protected] | ||
- name: Run bootstrap | ||
run: yarn osd bootstrap | ||
|
||
- name: Build plugins | ||
run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 12 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ${{ env.FTR_PATH }} | ||
repository: ${{ env.TEST_REPO }} | ||
ref: '${{ env.TEST_BRANCH }}' | ||
|
||
- name: Get Cypress version | ||
id: cypress_version | ||
run: | | ||
echo "name=cypress_version::$(cat ./${{ env.FTR_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')" >> $GITHUB_OUTPUT | ||
- name: Cache Cypress | ||
id: cache-cypress | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cache/Cypress | ||
key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }} | ||
env: | ||
CYPRESS_INSTALL_BINARY: ${{ steps.cypress_version.outputs.cypress_version }} | ||
- run: npx cypress cache list | ||
- run: npx cypress cache path | ||
|
||
- name: Run tests | ||
uses: cypress-io/github-action@v2 | ||
with: | ||
working-directory: ${{ env.FTR_PATH }} | ||
start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }} | ||
wait-on: 'http://localhost:9200, http://localhost:5601' | ||
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.FTR_PATH }}/integration/dasboard_sanity_test.spec.js | ||
|
||
# Screenshots are only captured on failure, will change this once we do visual regression tests | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: ftr-cypress-screenshots | ||
path: ${{ env.FTR_PATH }}/screenshots | ||
retention-days: 1 | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: ftr-cypress-videos | ||
path: ${{ env.FTR_PATH }}/videos | ||
retention-days: 1 | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: ftr-cypress-results | ||
path: ${{ env.FTR_PATH }}/results | ||
retention-days: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"defaultCommandTimeout": 60000, | ||
"requestTimeout": 60000, | ||
"responseTimeout": 60000, | ||
"baseUrl": "http://localhost:5601", | ||
"viewportWidth": 2000, | ||
"viewportHeight": 1320, | ||
"env": { | ||
"openSearchUrl": "http://localhost:9200", | ||
"SECURITY_ENABLED": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
CommonUI, | ||
MiscUtils, | ||
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
|
||
/** | ||
* dashboard_sample_data test suite description: | ||
* 1) Visit the dev tool page of opensearchdashboard, check key UI elements display | ||
*/ | ||
export function dashboardSanityTests() { | ||
const commonUI = new CommonUI(cy); | ||
const miscUtils = new MiscUtils(cy); | ||
|
||
describe('dashboard sample data validation', () => { | ||
before(() => {}); | ||
|
||
after(() => {}); | ||
describe('checking Dev Tools', () => { | ||
before(() => { | ||
// Go to the Dev Tools page | ||
miscUtils.visitPage('app/dev_tools#/console'); | ||
}); | ||
|
||
after(() => {}); | ||
|
||
it('checking welcome panel display', () => { | ||
commonUI.checkElementExists('div[data-test-subj="welcomePanel"]', 1); | ||
}); | ||
|
||
it('checking dismiss button display', () => { | ||
commonUI.checkElementExists('button[data-test-subj="help-close-button"]', 1); | ||
}); | ||
|
||
it('checking console input area display', () => { | ||
commonUI.checkElementExists('div[data-test-subj="request-editor"]', 1); | ||
}); | ||
|
||
it('checking console output area display', () => { | ||
commonUI.checkElementExists('div[data-test-subj="response-editor"]', 1); | ||
}); | ||
}); | ||
}); | ||
} | ||
dashboardSanityTests(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands'; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.