more docker integration test tweaks

This commit is contained in:
Danny Coates 2018-05-03 23:47:44 -07:00
parent 7d62a23b36
commit 7841dec5d8
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
9 changed files with 39 additions and 62 deletions

View File

@ -48,6 +48,8 @@ jobs:
docker-compose --version docker-compose --version
- run: - run:
command: npm run test-integration command: npm run test-integration
- store_artifacts:
path: coverage/send-test.html
deploy_dev: deploy_dev:
machine: true machine: true
steps: steps:
@ -114,10 +116,19 @@ workflows:
ignore: /.*/ ignore: /.*/
tags: tags:
only: /^v.*/ only: /^v.*/
- deploy_stage: - integration_tests:
requires: requires:
- build - build
- test filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- deploy_stage:
requires:
- build
- test
- integration_tests
filters: filters:
branches: branches:
ignore: /.*/ ignore: /.*/

View File

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

View File

@ -28,7 +28,8 @@
"test": "npm-run-all test:*", "test": "npm-run-all test:*",
"test:backend": "nyc mocha --reporter=min test/backend", "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:frontend": "cross-env NODE_ENV=development node test/frontend/runner.js && nyc report --reporter=html",
"test-integration": "docker-compose up --abort-on-container-exit --exit-code-from integration-tests --build --remove-orphans --quiet-pull && docker-compose down --rmi local", "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", "start": "npm run clean && cross-env NODE_ENV=development webpack-dev-server",
"prod": "node server/prod.js" "prod": "node server/prod.js"
}, },

View File

@ -5,5 +5,6 @@ RUN apt-get update && \
pip install tox pip install tox
COPY . /integration COPY . /integration
WORKDIR /integration WORKDIR /integration
RUN tox --notest
CMD ["tox", "-e", "integration-tests"] 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. 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. [tox][Tox] is our test environment manager and [pytest][pytest] is the test runner.
To run the tests, execute the command below: To run the tests, execute the commands below:
1. Make sure all of the images are running:
```sh ```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 ### Adding a test
@ -60,21 +45,13 @@ If not start them detached:
docker-compose up -d docker-compose up -d
``` ```
2. Copy the port that is forwarded for the ```selenium-firefox``` image: 2. Open your favorite VNC viewer and type in `localhost:5900`.
```sh 3. The password is ```secret```.
0.0.0.0:32771->5900/tcp 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.
```
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.
### Debugging a failure ### 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/ [flake8]: http://flake8.pycqa.org/en/latest/
[git-clone]: https://help.github.com/articles/cloning-a-repository/ [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

@ -4,19 +4,16 @@ skipsdist = True
[testenv] [testenv]
skip_install = True skip_install = True
deps = -rpipenv.txt deps = -rrequirements.txt
commands = commands =
pipenv install --skip-lock 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}
pipenv run pytest -v --verify-base-url --driver Remote --capability browserName firefox --host selenium --html=send-test.html --self-contained-html {posargs}
[testenv:flake8] [testenv:flake8]
commands = commands =
pipenv install --skip-lock flake8 {posargs:.}
pipenv run flake8 {posargs:.}
[flake8] [flake8]
exclude = .eggs,.tox,docs,node_modules exclude = .eggs,.tox,docs,node_modules
[pytest] [pytest]
base_url = http://web:1443
sensitive_url = mozilla\.(com|org) sensitive_url = mozilla\.(com|org)