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
- run:
command: npm run test-integration
- store_artifacts:
path: coverage/send-test.html
deploy_dev:
machine: true
steps:
@ -114,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,17 +10,17 @@ services:
- REDIS_HOST=redis
redis:
image: redis:alpine
ports:
- "6379:6379"
selenium:
image: b4handjr/selenium-firefox
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,7 +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": "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",
"prod": "node server/prod.js"
},

View File

@ -5,5 +5,6 @@ RUN apt-get update && \
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

@ -4,19 +4,16 @@ skipsdist = True
[testenv]
skip_install = True
deps = -rpipenv.txt
deps = -rrequirements.txt
commands =
pipenv install --skip-lock
pipenv run pytest -v --verify-base-url --driver Remote --capability browserName firefox --host selenium --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://web:1443
sensitive_url = mozilla\.(com|org)