Browse Source

moved integration text execution to docker

Danny Coates 6 years ago
parent
commit
7d62a23b36
6 changed files with 35 additions and 48 deletions
  1. 16 31
      circle.yml
  2. 7 6
      docker-compose.yml
  3. 1 3
      package.json
  4. 9 0
      test/integration/Dockerfile
  5. 0 4
      test/integration/scripts/start-docker.sh
  6. 2 4
      test/integration/tox.ini

+ 16 - 31
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:

+ 7 - 6
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
+

+ 1 - 3
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"
   },

+ 9 - 0
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"]

+ 0 - 4
test/integration/scripts/start-docker.sh

@@ -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 &

+ 2 - 4
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)