From 7841dec5d8c379e8dd433416624face054e2d8a2 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 3 May 2018 23:47:44 -0700 Subject: [PATCH] more docker integration test tweaks --- circle.yml | 15 +++++++++++-- docker-compose.yml | 10 ++++----- package.json | 3 ++- test/integration/Dockerfile | 1 + test/integration/Pipfile | 17 -------------- test/integration/README.md | 37 ++++++------------------------- test/integration/pipenv.txt | 1 - test/integration/requirements.txt | 8 +++++++ test/integration/tox.ini | 9 +++----- 9 files changed, 39 insertions(+), 62 deletions(-) delete mode 100644 test/integration/Pipfile delete mode 100644 test/integration/pipenv.txt create mode 100644 test/integration/requirements.txt diff --git a/circle.yml b/circle.yml index 4530e16b..b1faac49 100644 --- a/circle.yml +++ b/circle.yml @@ -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: /.*/ diff --git a/docker-compose.yml b/docker-compose.yml index d88389d7..88d2ac4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" diff --git a/package.json b/package.json index e47b6a7f..e9c85579 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/integration/Dockerfile b/test/integration/Dockerfile index eb7d3414..2114da5f 100644 --- a/test/integration/Dockerfile +++ b/test/integration/Dockerfile @@ -5,5 +5,6 @@ RUN apt-get update && \ pip install tox COPY . /integration WORKDIR /integration +RUN tox --notest CMD ["tox", "-e", "integration-tests"] \ No newline at end of file diff --git a/test/integration/Pipfile b/test/integration/Pipfile deleted file mode 100644 index ff8cb7a6..00000000 --- a/test/integration/Pipfile +++ /dev/null @@ -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" diff --git a/test/integration/README.md b/test/integration/README.md index ea20885c..b0aefda6 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -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/ diff --git a/test/integration/pipenv.txt b/test/integration/pipenv.txt deleted file mode 100644 index d4adcb0c..00000000 --- a/test/integration/pipenv.txt +++ /dev/null @@ -1 +0,0 @@ -pipenv==11.9.0 diff --git a/test/integration/requirements.txt b/test/integration/requirements.txt new file mode 100644 index 00000000..78b399f4 --- /dev/null +++ b/test/integration/requirements.txt @@ -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 diff --git a/test/integration/tox.ini b/test/integration/tox.ini index cbc83c0e..2f5ccbfc 100755 --- a/test/integration/tox.ini +++ b/test/integration/tox.ini @@ -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)