Merge pull request #813 from mozilla/docker-int
moved integration text execution to docker
This commit is contained in:
commit
aeb44379c8
60
circle.yml
60
circle.yml
|
@ -16,7 +16,7 @@ jobs:
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: .
|
root: .
|
||||||
paths:
|
paths:
|
||||||
- ./*
|
- ./dist
|
||||||
test:
|
test:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:8-browsers
|
- image: circleci/node:8-browsers
|
||||||
|
@ -35,14 +35,11 @@ jobs:
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: coverage
|
path: coverage
|
||||||
integration_tests:
|
integration_tests:
|
||||||
working_directory: ~/send
|
|
||||||
machine: true
|
machine: true
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- attach_workspace:
|
||||||
keys:
|
at: .
|
||||||
- uitest-cache-{{ checksum "test/integration/Pipfile" }}
|
|
||||||
- uitest-cache-{{ checksum "test/integration/pipenv.txt" }}
|
|
||||||
- run:
|
- run:
|
||||||
name: Install Docker Compose
|
name: Install Docker Compose
|
||||||
command: |
|
command: |
|
||||||
|
@ -50,33 +47,13 @@ jobs:
|
||||||
pip install docker-compose>=1.18
|
pip install docker-compose>=1.18
|
||||||
docker-compose --version
|
docker-compose --version
|
||||||
- run:
|
- run:
|
||||||
name: Install Tox
|
command: npm run test-integration
|
||||||
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
|
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: send-test.html
|
path: coverage/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
|
|
||||||
deploy_dev:
|
deploy_dev:
|
||||||
machine: true
|
machine: true
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: .
|
at: .
|
||||||
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
|
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
@ -85,6 +62,7 @@ jobs:
|
||||||
deploy_stage:
|
deploy_stage:
|
||||||
machine: true
|
machine: true
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: .
|
at: .
|
||||||
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
|
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
@ -94,11 +72,20 @@ workflows:
|
||||||
version: 2
|
version: 2
|
||||||
test_pr:
|
test_pr:
|
||||||
jobs:
|
jobs:
|
||||||
|
- build:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
ignore: master
|
||||||
- test:
|
- test:
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: master
|
ignore: master
|
||||||
- integration_tests
|
- integration_tests:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
ignore: master
|
||||||
|
requires:
|
||||||
|
- build
|
||||||
build_and_deploy_dev:
|
build_and_deploy_dev:
|
||||||
jobs:
|
jobs:
|
||||||
- build:
|
- build:
|
||||||
|
@ -129,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: /.*/
|
||||||
|
|
|
@ -10,16 +10,17 @@ services:
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
redis:
|
redis:
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
ports:
|
selenium:
|
||||||
- "6379:6379"
|
|
||||||
selenium-firefox:
|
|
||||||
image: b4handjr/selenium-firefox
|
image: b4handjr/selenium-firefox
|
||||||
volumes:
|
|
||||||
- .:/send
|
|
||||||
working_dir: /send
|
|
||||||
expose:
|
|
||||||
- "4444"
|
|
||||||
ports:
|
ports:
|
||||||
- "5900"
|
- "${VNC_PORT:-5900}:5900"
|
||||||
- "4444:4444"
|
|
||||||
shm_size: 2g
|
shm_size: 2g
|
||||||
|
integration-tests:
|
||||||
|
build: ./test/integration
|
||||||
|
environment:
|
||||||
|
- BASE_URL=${BASE_URL:-http://web:1443}
|
||||||
|
links:
|
||||||
|
- web
|
||||||
|
- selenium
|
||||||
|
volumes:
|
||||||
|
- "./coverage:/coverage"
|
||||||
|
|
|
@ -28,9 +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-local": "tox -c test/integration/tox.ini",
|
"test-integration": "docker-compose up --abort-on-container-exit --exit-code-from integration-tests --build --remove-orphans --quiet-pull && docker-compose down",
|
||||||
"test-integration-docker": "docker-compose exec -T --user root selenium-firefox tox -c test/integration/tox.ini",
|
"test-integration-stage": "cross-env BASE_URL=https://send.stage.mozaws.net npm run test-integration",
|
||||||
"start:integration-docker": "docker-compose exec -T --user root selenium-firefox ./test/integration/scripts/start-docker.sh &",
|
|
||||||
"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"
|
||||||
},
|
},
|
||||||
|
|
|
@ -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"]
|
|
@ -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"
|
|
|
@ -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/
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
pipenv==11.9.0
|
|
|
@ -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
|
|
@ -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 &
|
|
|
@ -3,22 +3,17 @@ envlist = integration-tests, flake8
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
recreate=True
|
|
||||||
skip_install = True
|
skip_install = True
|
||||||
passenv = DISPLAY MOZ_HEADLESS
|
deps = -rrequirements.txt
|
||||||
deps = -rpipenv.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 -n 2 --driver Firefox --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://localhost:8080
|
|
||||||
sensitive_url = mozilla\.(com|org)
|
sensitive_url = mozilla\.(com|org)
|
||||||
|
|
Loading…
Reference in New Issue