Skip to content

Commit

Permalink
E2E: Create dashboard access for reviewing tests results (rancher#6576)
Browse files Browse the repository at this point in the history
* Add sorry-cypress library, commands and configuration

* Replace e2e test run ID to be used for the dashboard with title, id and number run

* Add missing instruction for the dashboard

* Set default browser to Chrome

* Updated env template
  • Loading branch information
cnotv authored Aug 4, 2022
1 parent 9b61699 commit 194d9a7
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ env:
CATTLE_BOOTSTRAP_PASSWORD: password
TEST_BASE_URL: https://127.0.0.1:8005
API: https://127.0.0.1
TEST_PROJECT_ID: rancher-dashboard
CYPRESS_API_URL: http://139.59.134.103:1234/
TEST_RUN_ID: ${{github.event.pull_request.title}}_${{github.run_number}}_id_${{github.run_id}}
jobs:
e2e-test:
if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')"
Expand Down
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const getSpecPattern = (): string[] => {
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');

export default defineConfig({
projectId: process.env.TEST_PROJECT_ID,
defaultCommandTimeout: 60000,
trashAssetsBeforeRuns: true,
env: {
Expand Down
27 changes: 27 additions & 0 deletions docs/developer/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ For the cypress test runner to consume the UI, you should specify the environmen
- `CATTLE_BOOTSTRAP_PASSWORD`, initialization password which will also be used as `admin` password (do not pick `admin`)
- `TEST_BASE_URL` // URL used by Cypress to run the tests, default `https://localhost:8005`
- `TEST_SKIP_SETUP` // Avoid to execute bootstrap setup tests for already initialized Rancher instances
- Dashboard
- `TEST_PROJECT_ID` // Project ID used by Cypress/Sorry cypress to run the tests
- `TEST_RUN_ID` (optional) // Identifier for your dashboard run, default value is timestamp

### Development with watch/dev

Expand All @@ -28,6 +31,30 @@ The Cypress dashboard will contain the options and the list of test suites. Thes

For further information, consult [official documentation](https://docs.cypress.io/guides/guides/command-line#cypress-open).

### E2E Dashboard

#### Self-hosted: Sorry Cypress

Link to the dashboard: http://139.59.134.103:8080/

E2E tests can be added and displayed in a dashboard by defining the project ID with the env var `TEST_PROJECT_ID`, then run the script:

```bash
yarn cy:run:sorry
```

#### Cypress Dashboard

E2E tests can be displayed in Cypress dashboard by defining the project ID with the env var `TEST_PROJECT_ID`, then run the script by passing the parameters

```bash
yarn cy:run --record --key YOUR_RECORD_KEY_HERE
```

These values are provided when you create a new project within Cypress dashboard or within `Project settings`.

It's also possible to run a workflow in GitHub Actions E2E test using these values to record on personal dashboards.

### Local and CI/prod run

It is possible to start the project and run all the tests at once with a single command. There's however a difference between `dev` and `production` run. The first will not require an official certificate and will build the project in `.nuxt`, while the production will enable all the SSL configurations to run encrypted.
Expand Down
14 changes: 13 additions & 1 deletion env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Rancher API Endpoint
API="URL"
API= # Rancher server location
CATTLE_BOOTSTRAP_PASSWORD= # (optional) Rancher password used for Docker initialization, adopted also for admin and skipped request
CATTLE_PASSWORD_MIN_LENGTH= # (optional) (default: 12) Minimum length of the Rancher initialization password

# Packages to exclude. Running `yarn clean` may be required in order for changes to take affect.
EXCLUDES_PKG="epinio, rancher-components"

# E2E
TEST_USERNAME=admin # Rancher user, initial one is always 'admin'
TEST_PASSWORD= # User password or custom during first Rancher run
TEST_BASE_URL= # URL used by Cypress to run the tests, default already set as `https://localhost:8005`
TEST_SKIP_SETUP= # (optional) set it 'true' to avoid to execute bootstrap setup tests for already initialized Rancher instances

# E2E Dashboard values needed only for recording
TEST_PROJECT_ID= # Cypres Project ID; Use any value for Sorry Cypress
CYPRESS_API_URL= # Cypress unofficial dashboard Sorry Cypress
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
"generate": "./node_modules/.bin/nuxt generate",
"dev-debug": "node --inspect ./node_modules/.bin/nuxt",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:run": "cypress run --browser chrome",
"cy:run:sorry": "./scripts/e2e",
"e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev yarn build",
"e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run",
"e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry",
"e2e:pre-prod": "yarn docker:local:stop && yarn docker:local:start && DEV_PORTS=true yarn build",
"e2e:prod": "START_SERVER_AND_TEST_INSECURE=1 server-test start:prod https-get://localhost:8005 cy:run",
"e2e:prod": "START_SERVER_AND_TEST_INSECURE=1 server-test start:prod https-get://localhost:8005 cy:run:sorry",
"storybook": "yarn run install-storybook && start-storybook -p 6006",
"build-storybook": "yarn run install-storybook && build-storybook",
"install-storybook": "./scripts/storybook-install",
Expand Down Expand Up @@ -154,6 +155,7 @@
"core-js": "^3.20.3",
"css-loader": "4.3.0",
"csv-loader": "^3.0.3",
"cy2": "^2.0.0",
"cypress": "^10.3.1",
"eslint": "^7.32.0",
"eslint-config-standard": ">=12.0.0",
Expand Down
5 changes: 5 additions & 0 deletions scripts/e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
ID="$(echo ${TEST_RUN_ID:-`date +%s`} | tr '[:upper:]' '[:lower:]' | tr ' ' '-')"
echo "$ID"

CYPRESS_API_URL='http://139.59.134.103:1234' cy2 run --browser chrome --record --key rancher-dashboard --parallel --ci-build-id "$ID"
29 changes: 27 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7290,6 +7290,15 @@ custom-event-polyfill@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/custom-event-polyfill/-/custom-event-polyfill-1.0.7.tgz#9bc993ddda937c1a30ccd335614c6c58c4f87aee"

cy2@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/cy2/-/cy2-2.0.0.tgz#c4697c62c939375966ab1f5ec3872a59d8f1c82f"
integrity sha512-Vo2fMKda/XzEGt4yPsYzpuXscCe031dwZ2LcTo3FFTS4BZ4dzHdRFrSEG/sPARDUJMryEqc/55qkmgIOR/WRZQ==
dependencies:
debug "^4.3.2"
js-yaml "^4.0.0"
npm-which "^3.0.1"

cyclist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
Expand Down Expand Up @@ -11609,7 +11618,7 @@ js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^4.1.0:
js-yaml@^4.0.0, js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
dependencies:
Expand Down Expand Up @@ -12865,6 +12874,13 @@ normalize-url@^4.1.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129"

npm-path@^2.0.2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/npm-path/-/npm-path-2.0.4.tgz#c641347a5ff9d6a09e4d9bce5580c4f505278e64"
integrity sha512-IFsj0R9C7ZdR5cP+ET342q77uSRdtWOlWpih5eC+lu29tIDbNEgDbzgVJ5UFvYHWhxDZ5TFkJafFioO0pPQjCw==
dependencies:
which "^1.2.10"

npm-run-path@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
Expand All @@ -12877,6 +12893,15 @@ npm-run-path@^4.0.0, npm-run-path@^4.0.1:
dependencies:
path-key "^3.0.0"

npm-which@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/npm-which/-/npm-which-3.0.1.tgz#9225f26ec3a285c209cae67c3b11a6b4ab7140aa"
integrity sha512-CM8vMpeFQ7MAPin0U3wzDhSGV0hMHNwHU0wjo402IVizPDrs45jSfSuoC+wThevY88LQti8VvaAnqYAeVy3I1A==
dependencies:
commander "^2.9.0"
npm-path "^2.0.2"
which "^1.2.10"

nth-check@^1.0.2, nth-check@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c"
Expand Down Expand Up @@ -17508,7 +17533,7 @@ which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"

which@^1.2.9:
which@^1.2.10, which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
dependencies:
Expand Down

0 comments on commit 194d9a7

Please sign in to comment.