-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate existing Cypress tests to Cypress + Cucumber (#57299)
* chore: move gitignore to the cypress directory * chore: ignore more test files * fix: do not check the Loading Message It seems not relevant to the main purpose of these tests * chore: use cypres + webpack + cucumber scaffolding See https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example * chore: add eslint and prettier for code linting * feat: convert existing Cypress test into BDD style * feat: add support for using proper Node version in MacOSX * chore: use tslint * chore: use old layout We are keeping cypress as rootDir to follow project's structure. On the other hand, having a second cypress directory at the 2nd level is the default structure, as shown in the examples: - https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example - https://github.com/cypress-io/cypress-example-recipes/tree/a240054d7f5626ffcd7bd668dded96d219c4a7eb/examples/preprocessors__typescript-webpack * chore: remove prelint script meanwhile we fix TS lint * chore: move test results to a specific directory * chore: rename variable following old code * chore: remove non-needed lints, as we are going to use kibana build * chore: import snapshot function from cypress * chore: add readFile utils back from a bad removal * chore: change format of JSON spec file It was automatically changed by tests * chore: move CI directory to the proper layout in order for Jenkins to work * chore: store test-results from proper dir on Jenkins * chore: store artifacts properly on Jenkins * Fix type issues * chore: rename test application to e2e (end-to-end) We are keeping the build system within the test application, isolating dependencies * docs: reorganise docs for APM UI e2e tests * fix: Use proper cypress support file * chore: use existing NPM script for running cypress on CI * chore: update paths in CI scripts * docs: document how the CI runs the tests * chore: use Node 10 for tests * chore: Use kibana's Node version for tests * chore: run yarn install * docs: update docs * fix: path was wrong * docs: fix paths and flags used to load data * docs: elasticsearch fix flag * docs: Bootstrap kibana before running it * docs: remove outdated info * chore: move background steps to the scenario This would avoid not reading the background when the number of scenarios grows Co-authored-by: Dario Gieselaar <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
fa5400f
commit d27b6c0
Showing
34 changed files
with
2,302 additions
and
919 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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
cypress/ingest-data/events.json | ||
cypress/screenshots/* | ||
|
||
cypress/test-results |
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,68 @@ | ||
# End-To-End (e2e) Test for APM UI | ||
|
||
## Ingest static data into Elasticsearch via APM Server | ||
|
||
1. Start Elasticsearch and APM Server, using [apm-integration-testing](https://github.com/elastic/apm-integration-testing): | ||
|
||
```shell | ||
$ git clone https://github.com/elastic/apm-integration-testing.git | ||
$ cd apm-integration-testing | ||
./scripts/compose.py start master --no-kibana --no-xpack-secure | ||
``` | ||
|
||
2. Download [static data file](https://storage.googleapis.com/apm-ui-e2e-static-data/events.json) | ||
|
||
```shell | ||
$ cd x-pack/legacy/plugins/apm/e2e/cypress/ingest-data | ||
$ curl https://storage.googleapis.com/apm-ui-e2e-static-data/events.json --output events.json | ||
``` | ||
|
||
3. Post to APM Server | ||
|
||
```shell | ||
$ cd x-pack/legacy/plugins/apm/e2e/cypress/ingest-data | ||
$ node replay.js --server-url http://localhost:8200 --secret-token abcd --events ./events.json | ||
``` | ||
>This process will take a few minutes to ingest all data | ||
4. Start Kibana | ||
|
||
```shell | ||
$ yarn kbn bootstrap | ||
$ yarn start --no-base-path --csp.strict=false | ||
``` | ||
|
||
> Content Security Policy (CSP) Settings: Your Kibana instance must have the `csp.strict: false`. | ||
## How to run the tests | ||
|
||
_Note: Run the following commands from `kibana/x-pack/legacy/plugins/apm/e2e/cypress`._ | ||
|
||
### Interactive mode | ||
|
||
``` | ||
yarn cypress open | ||
``` | ||
|
||
### Headless mode | ||
|
||
``` | ||
yarn cypress run | ||
``` | ||
|
||
## Reproducing CI builds | ||
|
||
>This process is very slow compared to the local development described above. Consider that the CI must install and configure the build tools and create a Docker image for the project to run tests in a consistent manner. | ||
The Jenkins CI uses a shell script to prepare Kibana: | ||
|
||
```shell | ||
# Prepare and run Kibana locally | ||
$ x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh | ||
# Build Docker image for Kibana | ||
$ docker build --tag cypress --build-arg NODE_VERSION=$(cat .node-version) x-pack/legacy/plugins/apm/e2e/ci | ||
# Run Docker image | ||
$ docker run --rm -t --user "$(id -u):$(id -g)" \ | ||
-v `pwd`:/app --network="host" \ | ||
--name cypress cypress | ||
``` |
3 changes: 2 additions & 1 deletion
3
.../legacy/plugins/apm/cypress/ci/Dockerfile → x-pack/legacy/plugins/apm/e2e/ci/Dockerfile
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
FROM node:12 | ||
ARG NODE_VERSION | ||
FROM node:$NODE_VERSION | ||
|
||
RUN apt-get -qq update \ | ||
&& apt-get -y -qq install xvfb \ | ||
|
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../plugins/apm/cypress/ci/prepare-kibana.sh → ...gacy/plugins/apm/e2e/ci/prepare-kibana.sh
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,19 @@ | ||
{ | ||
"baseUrl": "http://localhost:5601", | ||
"video": false, | ||
"trashAssetsBeforeRuns": false, | ||
"fileServerFolder": "../", | ||
"fixturesFolder": "./cypress/fixtures", | ||
"integrationFolder": "./cypress/integration", | ||
"pluginsFile": "./cypress/plugins/index.js", | ||
"screenshotsFolder": "./cypress/screenshots", | ||
"supportFile": "./cypress/support/index.ts", | ||
"videosFolder": "./cypress/videos", | ||
"useRelativeSnapshots": true, | ||
"reporter": "junit", | ||
"reporterOptions": { | ||
"mochaFile": "./cypress/test-results/[hash]-e2e-tests.xml", | ||
"toConsole": false | ||
}, | ||
"testFiles": "**/*.{feature,features}" | ||
} |
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
x-pack/legacy/plugins/apm/e2e/cypress/integration/apm.feature
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,7 @@ | ||
Feature: APM | ||
|
||
Scenario: Transaction duration charts | ||
Given a user browses the APM UI application | ||
When the user inspects the opbeans-go service | ||
Then should redirect to correct path with correct params | ||
And should have correct y-axis ticks |
File renamed without changes.
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.