Merge pull request #813 from mozilla/docker-int

moved integration text execution to docker
This commit is contained in:
Danny Coates 2018-05-04 12:18:54 -07:00 committed by GitHub
commit aeb44379c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 69 additions and 105 deletions

View File

@ -16,7 +16,7 @@ jobs:
- persist_to_workspace:
root: .
paths:
- ./*
- ./dist
test:
docker:
- image: circleci/node:8-browsers
@ -35,14 +35,11 @@ jobs:
- store_artifacts:
path: coverage
integration_tests:
working_directory: ~/send
machine: true
steps:
- checkout
- restore_cache:
keys:
- uitest-cache-{{ checksum "test/integration/Pipfile" }}
- uitest-cache-{{ checksum "test/integration/pipenv.txt" }}
- attach_workspace:
at: .
- run:
name: Install Docker Compose
command: |
@ -50,33 +47,13 @@ jobs:
pip install docker-compose>=1.18
docker-compose --version
- run:
name: Install Tox
command: |
set -x
pip install tox
- run:
name: Start docker container
command: docker-compose up -d
- run:
name: Run User Integration Tests
command: |
npm run start:integration-docker
npm run test-integration-docker
environment:
MOZ_HEADLESS: 1
command: npm run test-integration
- store_artifacts:
path: send-test.html
- save_cache:
key: uitest-cache-{{ checksum "test/integration/Pipfile" }}
paths:
- test/integration/.tox
- save_cache:
key: uitest-cache-{{ checksum "test/integration/pipenv.txt" }}
paths:
- test/integration/.tox
path: coverage/send-test.html
deploy_dev:
machine: true
steps:
- checkout
- attach_workspace:
at: .
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
@ -85,6 +62,7 @@ jobs:
deploy_stage:
machine: true
steps:
- checkout
- attach_workspace:
at: .
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
@ -94,11 +72,20 @@ workflows:
version: 2
test_pr:
jobs:
- build:
filters:
branches:
ignore: master
- test:
filters:
branches:
ignore: master
- integration_tests
- integration_tests:
filters:
branches:
ignore: master
requires:
- build
build_and_deploy_dev:
jobs:
- build:
@ -129,10 +116,19 @@ workflows:
ignore: /.*/
tags:
only: /^v.*/
- deploy_stage:
- integration_tests:
requires:
- build
- test
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- deploy_stage:
requires:
- build
- test
- integration_tests
filters:
branches:
ignore: /.*/

View File

@ -10,16 +10,17 @@ services:
- REDIS_HOST=redis
redis:
image: redis:alpine
ports:
- "6379:6379"
selenium-firefox:
selenium:
image: b4handjr/selenium-firefox
volumes:
- .:/send
working_dir: /send
expose:
- "4444"
ports:
- "5900"
- "4444:4444"
- "${VNC_PORT:-5900}:5900"
shm_size: 2g
integration-tests:
build: ./test/integration
environment:
- BASE_URL=${BASE_URL:-http://web:1443}
links:
- web
- selenium
volumes:
- "./coverage:/coverage"

View File

@ -28,9 +28,8 @@
"test": "npm-run-all test:*",
"test:backend": "nyc mocha --reporter=min test/backend",
"test:frontend": "cross-env NODE_ENV=development node test/frontend/runner.js && nyc report --reporter=html",
"test-integration-local": "tox -c test/integration/tox.ini",
"test-integration-docker": "docker-compose exec -T --user root selenium-firefox tox -c test/integration/tox.ini",
"start:integration-docker": "docker-compose exec -T --user root selenium-firefox ./test/integration/scripts/start-docker.sh &",
"test-integration": "docker-compose up --abort-on-container-exit --exit-code-from integration-tests --build --remove-orphans --quiet-pull && docker-compose down",
"test-integration-stage": "cross-env BASE_URL=https://send.stage.mozaws.net npm run test-integration",
"start": "npm run clean && cross-env NODE_ENV=development webpack-dev-server",
"prod": "node server/prod.js"
},

View File

@ -0,0 +1,10 @@
FROM ubuntu:xenial
RUN apt-get update && \
apt-get install -y python-pip python-dev && \
pip install tox
COPY . /integration
WORKDIR /integration
RUN tox --notest
CMD ["tox", "-e", "integration-tests"]

View File

@ -1,17 +0,0 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
selenium = "==3.11.0"
flake8 = "==3.5.0"
flake8-isort = "==2.5"
PyPOM = "==1.3.0"
pytest = "==3.5.0"
pytest-html = "==1.16.1"
pytest-selenium = "==1.12.0"
pytest-xdist = "==1.22.2"

View File

@ -20,26 +20,11 @@ Please view the README at the root directory of the project.
Included in the docker-compose file is an image containing Firefox Nightly.
[tox][Tox] is our test environment manager and [pytest][pytest] is the test runner.
To run the tests, execute the command below:
1. Make sure all of the images are running:
To run the tests, execute the commands below:
```sh
docker-compose ps
npm run build
npm run test-integration
```
If not start them detached:
```sh
docker-compose up -d
```
2. Start the tests within the docker container
```sh
npm run test:integration-docker
```
If you have [geckodriver][geckodriver] installed you can use these steps:
```sh
npm start &
npm run test:integration
```
This will use your local Firefox installation.
### Adding a test
@ -60,21 +45,13 @@ If not start them detached:
docker-compose up -d
```
2. Copy the port that is forwarded for the ```selenium-firefox``` image:
```sh
0.0.0.0:32771->5900/tcp
```
Note: Your port may not match what is seen here.
You will want to copy what ever IP address and port is before the ```->5900/tcp```.
3. Open your favorite VNC viewer and type in, or paste that address.
4. The password is ```secret```.
5. The viewer should open a window with a Ubuntu logo. If that happens you are connected to the ```selenium-firefox``` image and if you start the test, you should see a Firefox window open and the tests running.
2. Open your favorite VNC viewer and type in `localhost:5900`.
3. The password is ```secret```.
4. The viewer should open a window with a Ubuntu logo. If that happens you are connected to the ```selenium-firefox``` image and if you start the test, you should see a Firefox window open and the tests running.
### Debugging a failure
Whether a test passes or fails will result in a HTML report being created. This report will have detailed information of the test run and if a test does fail, it will provide geckodriver logs, terminal logs, as well as a screenshot of the browser when the test failed. We use a pytest plugin called [pytest-html][pytest-html] to create this report. The report can be found within the root directory of the project and is named ```send-test.html```. It should be viewed within a browser.
Whether a test passes or fails will result in a HTML report being created. This report will have detailed information of the test run and if a test does fail, it will provide geckodriver logs, terminal logs, as well as a screenshot of the browser when the test failed. We use a pytest plugin called [pytest-html][pytest-html] to create this report. The report can be found at ```coverage/send-test.html```. It should be viewed within a browser.
[flake8]: http://flake8.pycqa.org/en/latest/
[git-clone]: https://help.github.com/articles/cloning-a-repository/

View File

@ -1 +0,0 @@
pipenv==11.9.0

View File

@ -0,0 +1,8 @@
selenium==3.11.0
flake8==3.5.0
flake8-isort==2.5
PyPOM==1.3.0
pytest==3.5.0
pytest-html==1.16.1
pytest-selenium==1.12.0
pytest-xdist==1.22.2

View File

@ -1,4 +0,0 @@
#!/bin/bash
# piping to dev/null for starting the server within the firefox docker image
npm install > "/dev/null" 2>&1
npm start > "/dev/null" 2>&1 &

View File

@ -3,22 +3,17 @@ envlist = integration-tests, flake8
skipsdist = True
[testenv]
recreate=True
skip_install = True
passenv = DISPLAY MOZ_HEADLESS
deps = -rpipenv.txt
deps = -rrequirements.txt
commands =
pipenv install --skip-lock
pipenv run pytest -v --verify-base-url -n 2 --driver Firefox --html=send-test.html --self-contained-html {posargs}
pytest -v --verify-base-url --base-url {env:BASE_URL:http://web:1443} --driver Remote --capability browserName firefox --host selenium --html=/coverage/send-test.html --self-contained-html {posargs}
[testenv:flake8]
commands =
pipenv install --skip-lock
pipenv run flake8 {posargs:.}
flake8 {posargs:.}
[flake8]
exclude = .eggs,.tox,docs,node_modules
[pytest]
base_url = http://localhost:8080
sensitive_url = mozilla\.(com|org)