Skip to content

Commit 971556c

Browse files
author
robpblake
committed
[MWES-3564] Further updates to e2e testing infrastructure
Final changes to e2e testing infrastructure to put us in a better place to capture everything as a Jenkins pipeline script. Additionally I have updated the project documentation to help people run the tests and now only mention the Docker supported development experience.
1 parent e3a2254 commit 971556c

File tree

12 files changed

+142
-481
lines changed

12 files changed

+142
-481
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ _docker/drupal/drupal-filesystem/web/sites/default/rhd.settings.yml
6060

6161
# Ignore files generated by PhpStorm
6262
_docker/drupal/.idea
63-
.gitignore
6463
_tests/unit/rhd-frontend
6564
_tests/unit/report/
6665
local.log

README.md

Lines changed: 62 additions & 421 deletions
Large diffs are not rendered by default.

_docker/drupal/dev/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Local development for Drupal
1+
### developers.redhat.com - Local development for Drupal
22

33
This directory provides facilities for making it easy to develop with Drupal in a way that will ensure you are compatible
44
with our deployment onto Managed Platform.

_tests/e2e/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ RUN gem install bundler:1.16.1 octokit:4.6.2 --no-rdoc --no-ri
77

88
USER e2e
99
WORKDIR /home/e2e
10-
COPY package.json package-lock.json wait-for-docker-selenium.sh ./
10+
COPY package.json package-lock.json ./
1111
RUN npm config set "registry" https://repository.engineering.redhat.com/nexus/repository/registry.npmjs.org/ \
1212
&& npm config set strict-ssl=false \
13-
&& npm install --verbose
13+
&& npm install
1414

15-
COPY tests tests
16-
17-
ENV PATH /home/e2e/node_modules/.bin:$PATH
15+
ENV PATH /home/e2e/node_modules/.bin:/usr/java/latest/bin:$PATH

_tests/e2e/Dockerfile.mp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Dockerfile for running the end-to-end tests for the developer program in a CI environment
3+
#
4+
FROM images.paas.redhat.com/rhdp/developer-testing-base:e2e
5+
6+
USER root
7+
RUN groupadd -g 1000 e2e \
8+
&& useradd -g e2e -m -s /bin/bash -u 1000 e2e
9+
10+
WORKDIR /home/e2e
11+
ENTRYPOINT ["/home/e2e/wait-for-selenium.sh"]
12+
13+
COPY package.json package-lock.json wait-for-selenium.sh ./
14+
RUN chown -R e2e:e2e /home/e2e
15+
16+
USER e2e
17+
RUN npm config set "registry" https://repository.engineering.redhat.com/nexus/repository/registry.npmjs.org/ \
18+
&& npm config set strict-ssl=false \
19+
&& npm install
20+
21+
COPY tests tests
22+
23+
ENV PATH /home/e2e/node_modules/.bin:$PATH

_tests/e2e/README.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
RHDP Site End-to-end Testing
1+
developers.redhat.com End-to-End (e2e) Testing
22
=============================
33

44
### Summary
55

6-
This directory contains the UI Tests for the developers.redhat.com website, these tests are written in nodejs using [mocha](https://mochajs.org/) test framework and [webdriverio](http://webdriver.io/) as a driver to mimic real user interactions.
6+
This directory contains the end-to-end tests for the developers.redhat.com website. These tests are written in NodeJS using [mocha](https://mochajs.org/) test framework and [webdriver.io](http://webdriver.io/) as a driver to mimic real user interactions.
77

8-
## What types of tests we execute in our local/PR environment?
8+
These tests are executed each time a pull request is raised on the developers.redhat.com Git repository. Branch protection rules mean that it is not possible to merge your pull request until the tests are passing, so if you are making changes to the site,
9+
you should not neglect these tests.
910

10-
* js-e2e-tests
11-
* js-mobile-e2e-tests
12-
* js-drupal-e2e-tests
11+
The tests are split into three major sections:
12+
13+
* Key site functionality
14+
* Key site functionality on a mobile device
15+
* Key Drupal functionality
1316

1417
## What is e2e testing?
1518

@@ -20,22 +23,18 @@ We try to minimise the number of e2e tests that we have, as by nature these are
2023

2124
![http://www.agilenutshell.com/episodes/41-testing-pyramid](rules-of-thumb.png)
2225

23-
## What do we test on site-export?
26+
## What do we test for key site functionality
2427
* Search Page (DCP)
2528
* RHEL download (Download Manager, Keycloak login)
2629
* RHEL advanced linux cheatsheet (Download Manager, Keycloak login)
2730
* Keycloak pages (site navigation bar navigates users to login/register pages)
2831
* Home and Blog pages contain unique string for site monitoring.
2932
* 404 pages
3033

31-
## What do we test on drupal site?
32-
* Admin succesful login
34+
## What do we test for key Drupal functionality?
35+
* Admin can succesfully login after changes have been applied
3336
* All configuration changes are successfully imported after `drush cim` has been executed
3437

35-
## Testing of pull-requests
36-
The pull request pipeline consists of desktop and mobile end-to-end tests. The desktop tests execute in a chrome browser, and the mobile tests use a mobile enulated browser (currently iPhone X). Additionally the desktop tests perform some
37-
sanity checks around Drupal configuration status to make sure that any changes to our Drupal configuration in your pull request are applied cleanly.
38-
3938
## Retry strategy
4039
As we're not mocking and using live services, test sometimes fail. In an attempt to combat this we decided to add retry logic to tests.
4140

@@ -53,6 +52,9 @@ describe('my flaky test', function () {
5352
```
5453

5554
## Test failure(s) - what should I do?
55+
56+
You should investigate the failure.
57+
5658
A lot of time has been spent on focusing on flaky tests, unfortunately failures do occur which could be related to one or more issues. For example it could be your changes to the UI (css selectors/new functionality), environmental issues (kc, download-manager, dcp), or our build machine has issues (out of memory). Testing downloads as a real user would is also difficult, and has proved to be flaky. Despite adding retry functionality false positives do occur. If in doubt, discuss it with the rest of the team.
5759

5860
Fundamentally: **pull requests should not be merged if the tests are failing** and the branch protection rules on GitHub will prevent you from doing this.
@@ -69,7 +71,7 @@ You need to ensure you have the following installed locally:
6971

7072
### Running the tests
7173

72-
You can, and **should** test your changes locally before raising a PR. Please ensure you have a local build running and `https://localhost` is accessible in a browser.
74+
You can, and **should** test your changes locally before raising a PR. Please ensure you have Drupal running and `https://localhost` is accessible in your browser.
7375

7476
Next you need to ensure that you have the following environment variables set:
7577

@@ -84,7 +86,8 @@ So as an example, you will need to run the following commands on your terminal b
8486
export RHD_KEYCLOAK_ADMIN_USERNAME=rblake
8587
```
8688

87-
Please note that currently the tests use the legacy Drupal log in mechanism and as such the Drupal user password should match what is in the database for Drupal.
89+
Please note that currently the tests use the legacy Drupal log in mechanism and as such the Drupal user password should match what is in the database for Drupal. All Drupal passwords are sanitized in the local development environment,
90+
so ask the rest of the development team for the sanitized password.
8891

8992
Once you have set the required environment variables, in the root of the project directory execute the following command:
9093

@@ -98,6 +101,8 @@ You can alternatively run the individual components of the test suite using the
98101
* `npm run e2e:local-desktop` - Runs only the Desktop tests
99102
* `npm run e2e:local-mobile` - Runs only the mobile tests
100103

104+
**Note:** The Download tests are currently excluded from local runs due to https://issues.jboss.org/browse/DEVELOPER-5938
105+
101106
102107
## Run Single feature, or test
103108
Add a unique tag to the test(s) `it.` description, for example to execute the following scenario:
@@ -122,20 +127,13 @@ Add a unique tag to the test(s) `it.` description, for example to execute the fo
122127
});
123128
```
124129
125-
Would be: **`npm run e2e:local -- --mochaOpts.grep=@wip`**
130+
You can then run this single test with: **`npm run e2e:local -- --mochaOpts.grep=@wip`**
126131

127132
## Override the default (local) url:
128133

129-
The default baseUrl when running tests locally is set to `http://docker:8888`. To override this, you can execute:
134+
The default baseUrl when running tests locally is set to `https://localhost`. To override this, you can execute:
130135

131-
npm run e2e -- --base-url=https://developers.redhat.com --mochaOpts.grep=@wip
132-
133-
## Run tests inside docker using docker-selenium (build scripts - same as Jenkins)
134-
135-
The below command will execute both the desktop and mobile full-suite of tests (*at the time of writing this takes around 4 minutes in total*).
136-
137-
In the root of the project directory execute the following command:
138-
136+
npm run e2e:local -- --base-url=https://developers.redhat.com
139137

140138
## Approach to writing tests
141139

_tests/e2e/docker-compose.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
version: '2'
22
services:
33
e2e_drupal:
4-
build: .
5-
entrypoint: /home/e2e/wait-for-docker-selenium.sh
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.mp
67
command: 'npm run e2e:ci-drupal -- --base-url=$${RHD_BASE_URL}'
78
environment:
89
- RHD_BASE_URL
@@ -19,8 +20,9 @@ services:
1920
- chrome
2021

2122
e2e_desktop:
22-
build: .
23-
entrypoint: /home/e2e/wait-for-docker-selenium.sh
23+
build:
24+
context: .
25+
dockerfile: Dockerfile.mp
2426
command: 'npm run e2e:ci-desktop -- --base-url=$${RHD_BASE_URL}'
2527
environment:
2628
- RHD_BASE_URL
@@ -37,8 +39,9 @@ services:
3739
- chrome
3840

3941
e2e_mobile:
40-
build: .
41-
entrypoint: /home/e2e/wait-for-docker-selenium.sh
42+
build:
43+
context: .
44+
dockerfile: Dockerfile.mp
4245
command: 'npm run e2e:ci-mobile -- --base-url=$${RHD_BASE_URL}'
4346
environment:
4447
- RHD_BASE_URL

_tests/e2e/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "RHDP e2e testing",
55
"main": "index.js",
66
"scripts": {
7-
"e2e:local-drupal" : "wdio tests/config/wdio.conf.local.js --testType=drupal --browser=chrome --profile=drupal --base-url=https://localhost",
8-
"e2e:local-desktop" : "wdio tests/config/wdio.conf.local.js --browser=chrome --profile=desktop --mochaOpts.grep=@downloads --mochaOpts.invert=true --base-url=https://localhost",
9-
"e2e:local-mobile" : "wdio tests/config/wdio.conf.local.js --browser=mobile --profile=mobile --mochaOpts.grep=@downloads --mochaOpts.invert=true --tags=not:desktop --base-url=https://localhost",
7+
"e2e:local-drupal" : "wdio tests/config/wdio.conf.local.js --testType=drupal --browser=chrome --profile=drupal",
8+
"e2e:local-desktop" : "wdio tests/config/wdio.conf.local.js --browser=chrome --profile=desktop --mochaOpts.grep=@downloads --mochaOpts.invert=true",
9+
"e2e:local-mobile" : "wdio tests/config/wdio.conf.local.js --browser=mobile --profile=mobile --mochaOpts.grep=@downloads --mochaOpts.invert=true --tags=not:desktop",
1010
"e2e:local": "npm run e2e:local-drupal && npm run e2e:local-desktop && npm run e2e:local-mobile",
1111
"e2e:ci": "npm install && wdio tests/config/wdio.conf.ci.js",
1212
"e2e:ci-drupal" : "wdio tests/config/wdio.conf.ci.js --testType=drupal --browser=chrome --profile=drupal",

_tests/e2e/run-tests.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

_tests/e2e/wait-for-docker-selenium.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ do
1313
done
1414

1515
echo "Selenium-standalone is up - executing tests"
16-
exec $cmd
16+
exec ruby /home/e2e/developers.redhat.com/_docker/lib/pull_request/exec_with_git_hub_status_wrapper.rb $cmd

_tests/e2e/wait-for-selenium.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cmd="$@"
6+
7+
attempt=0
8+
while ! curl http://$GRID_HOST:$GRID_PORT/ && [ $attempt -le 59 ];
9+
do
10+
attempt=$(( $attempt + 1 ))
11+
echo "$(date) - waiting for Selenium server to be up (attempt: $attempt)..."
12+
sleep 1
13+
done
14+
15+
echo "Selenium server is up - executing tests"
16+
exec $cmd

previews/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Developer Preview Environments
1+
### developers.redhat.com Preview Environments
22

33
This directory contains a few utility scripts to help you connect to the preview environment associated with your pull
44
request build.

0 commit comments

Comments
 (0)