From 7d62a23b363a5993c1078e1634b6d5ede85af3d7 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 3 May 2018 15:00:34 -0700 Subject: [PATCH] moved integration text execution to docker --- circle.yml | 47 ++++++++---------------- docker-compose.yml | 13 ++++--- package.json | 4 +- test/integration/Dockerfile | 9 +++++ test/integration/scripts/start-docker.sh | 4 -- test/integration/tox.ini | 6 +-- 6 files changed, 35 insertions(+), 48 deletions(-) create mode 100644 test/integration/Dockerfile delete mode 100755 test/integration/scripts/start-docker.sh diff --git a/circle.yml b/circle.yml index df2e5218..4530e16b 100644 --- a/circle.yml +++ b/circle.yml @@ -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,11 @@ 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 - - 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 + command: npm run test-integration deploy_dev: machine: true steps: + - checkout - attach_workspace: at: . - run: docker login -u $DOCKER_USER -p $DOCKER_PASS @@ -85,6 +60,7 @@ jobs: deploy_stage: machine: true steps: + - checkout - attach_workspace: at: . - run: docker login -u $DOCKER_USER -p $DOCKER_PASS @@ -94,11 +70,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: diff --git a/docker-compose.yml b/docker-compose.yml index 14559257..d88389d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,14 +12,15 @@ services: image: redis:alpine ports: - "6379:6379" - selenium-firefox: + selenium: image: b4handjr/selenium-firefox - volumes: - - .:/send - working_dir: /send - expose: - - "4444" ports: - "5900" - "4444:4444" shm_size: 2g + integration-tests: + build: ./test/integration + links: + - web + - selenium + diff --git a/package.json b/package.json index 5c0dea5a..e47b6a7f 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,7 @@ "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 --rmi local", "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 new file mode 100644 index 00000000..eb7d3414 --- /dev/null +++ b/test/integration/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:xenial + +RUN apt-get update && \ + apt-get install -y python-pip python-dev && \ + pip install tox +COPY . /integration +WORKDIR /integration + +CMD ["tox", "-e", "integration-tests"] \ No newline at end of file diff --git a/test/integration/scripts/start-docker.sh b/test/integration/scripts/start-docker.sh deleted file mode 100755 index 45de0474..00000000 --- a/test/integration/scripts/start-docker.sh +++ /dev/null @@ -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 & diff --git a/test/integration/tox.ini b/test/integration/tox.ini index 18fff6fe..cbc83c0e 100755 --- a/test/integration/tox.ini +++ b/test/integration/tox.ini @@ -3,13 +3,11 @@ envlist = integration-tests, flake8 skipsdist = True [testenv] -recreate=True skip_install = True -passenv = DISPLAY MOZ_HEADLESS deps = -rpipenv.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} + pipenv run pytest -v --verify-base-url --driver Remote --capability browserName firefox --host selenium --html=send-test.html --self-contained-html {posargs} [testenv:flake8] commands = @@ -20,5 +18,5 @@ commands = exclude = .eggs,.tox,docs,node_modules [pytest] -base_url = http://localhost:8080 +base_url = http://web:1443 sensitive_url = mozilla\.(com|org)