From bada0707c59663f8ece8b91e5828a144a6edc5e5 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 12 Mar 2019 20:47:54 -0400 Subject: [PATCH 1/4] Update config for running download tests on CI --- circle.yml | 7 ++--- package.json | 4 ++- scripts/bin/run-integration-test-circleci.sh | 28 ++++++++++++++++++++ test/integration/download-tests.js | 7 ++--- test/integration/homepage-tests.js | 4 +++ test/wdio.circleci.conf.js | 6 ++--- 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 scripts/bin/run-integration-test-circleci.sh diff --git a/circle.yml b/circle.yml index 7f60d0ca..b7e6234f 100644 --- a/circle.yml +++ b/circle.yml @@ -35,8 +35,7 @@ jobs: path: coverage integration_tests: docker: - - image: circleci/node:10 - - image: selenium/standalone-firefox + - image: circleci/node:10-browsers steps: - checkout - restore_cache: @@ -46,7 +45,9 @@ jobs: key: send-int-{{ checksum "package-lock.json" }} paths: - node_modules - - run: npm run circleci-test-integration + - run: + name: Run integration test + command: ./scripts/bin/run-integration-test-circleci.sh deploy_dev: machine: true steps: diff --git a/package.json b/package.json index e67c1ce8..93c560f9 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "test:backend": "nyc --reporter=lcovonly mocha --reporter=min test/backend", "test:frontend": "cross-env NODE_ENV=development node test/frontend/runner.js", "test:report": "nyc report --reporter=html", - "test-integration": "cross-env NODE_ENV=development wdio test/wdio.docker.conf.js", + "test-integration": "cross-env NODE_ENV=development ANDROID=1 wdio test/wdio.local.conf.js", "circleci-test-integration": "cross-env NODE_ENV=development wdio test/wdio.circleci.conf.js", "start": "npm run clean && cross-env NODE_ENV=development FXA_CLIENT_ID=fced6b5e3f4c66b9 BASE_URL=http://localhost:8080 webpack-dev-server --mode=development", "android": "cross-env ANDROID=1 npm start", @@ -126,6 +126,7 @@ "wdio-firefox-profile-service": "^0.1.3", "wdio-mocha-framework": "^0.6.3", "wdio-sauce-service": "^0.4.14", + "wdio-selenium-standalone-service": "0.0.12", "wdio-spec-reporter": "^0.1.5", "webdriverio": "^4.14.3", "webpack": "4.28.4", @@ -152,6 +153,7 @@ "node-fetch": "^2.3.0", "raven": "^2.6.4", "redis": "^2.8.0", + "selenium-standalone": "^6.15.6", "ua-parser-js": "^0.7.19", "websocket-stream": "^5.1.2" }, diff --git a/scripts/bin/run-integration-test-circleci.sh b/scripts/bin/run-integration-test-circleci.sh new file mode 100644 index 00000000..183e478c --- /dev/null +++ b/scripts/bin/run-integration-test-circleci.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -ex + +GECKODRIVER_URL=$( + curl -s 'https://api.github.com/repos/mozilla/geckodriver/releases/latest' | + python -c "import sys, json; r = json.load(sys.stdin); print([a for a in r['assets'] if 'linux64' in a['name']][0]['browser_download_url']);" +); + + +curl -L -o geckodriver.tar.gz $GECKODRIVER_URL +gunzip -c geckodriver.tar.gz | tar xopf - +chmod +x geckodriver +sudo mv geckodriver /bin +geckodriver --version +# Install pip +sudo apt-get install python-pip +sudo pip install --upgrade pip + +sudo pip install mozdownload mozinstall==1.15 + +mkdir -p ~/project/firefox-downloads/ +find ~/project/firefox-downloads/ -type f -mtime +90 -delete +mozdownload --version latest --type daily --destination ~/project/firefox-downloads/firefox_nightly/ + +export PATH=~/project/firefox:$PATH +mozinstall $(ls -t firefox-downloads/firefox_nightly/*.tar.bz2 | head -1) +firefox --version + npm run circleci-test-integration \ No newline at end of file diff --git a/test/integration/download-tests.js b/test/integration/download-tests.js index b1d8aab9..49373467 100644 --- a/test/integration/download-tests.js +++ b/test/integration/download-tests.js @@ -51,9 +51,10 @@ describe('Firefox Send', function() { browser.waitForExist(downloadPage.downloadComplete); browser.back(); browser.waitForExist('send-archive'); - assert.equal( - browser.getText('send-archive > div:first-of-type').substring(0, 24), - 'Expires after 1 download' + assert( + browser + .getText('send-archive > div:first-of-type') + .includes('Expires after 1 download') ); }); }); diff --git a/test/integration/homepage-tests.js b/test/integration/homepage-tests.js index 2c98e207..22a3e9d4 100644 --- a/test/integration/homepage-tests.js +++ b/test/integration/homepage-tests.js @@ -3,12 +3,16 @@ const assert = require('assert'); const HomePage = require('./pages/desktop/home_page'); describe('Firefox Send homepage', function() { + this.retries(2); const homePage = new HomePage(); const baseUrl = browser.options['baseUrl']; const footerLinks = ['mozilla', 'legal', 'legal', 'cookies', 'github']; beforeEach(function() { homePage.open(); + if (process.env.ANDROID) { + this.skip(); + } }); it('should have the right title', function() { diff --git a/test/wdio.circleci.conf.js b/test/wdio.circleci.conf.js index 176efc35..eb99fe7c 100644 --- a/test/wdio.circleci.conf.js +++ b/test/wdio.circleci.conf.js @@ -1,6 +1,5 @@ // eslint-disable-next-line node/no-extraneous-require const ip = require('ip'); -const path = require('path'); const common = require('./wdio.common.conf'); /*/ @@ -10,9 +9,8 @@ Config for running selenium from a circleci docker container against localhost /*/ exports.config = Object.assign({}, common.config, { - baseUrl: `http://${ip.address()}:8000`, - exclude: [path.join(__dirname, './integration/download-tests.js')], + baseUrl: `http://${ip.address()}:8080`, maxInstances: 1, bail: 1, - services: [require('./testServer')] + services: [require('./testServer'), 'selenium-standalone'] }); From f07988426ba63846a53b08305ad71db652c2c31b Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 12 Mar 2019 20:52:41 -0400 Subject: [PATCH 2/4] Fix permissions. --- scripts/bin/run-integration-test-circleci.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/bin/run-integration-test-circleci.sh diff --git a/scripts/bin/run-integration-test-circleci.sh b/scripts/bin/run-integration-test-circleci.sh old mode 100644 new mode 100755 From 6559afba375e7c2411688759c848674fe5bf0160 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 12 Mar 2019 20:56:31 -0400 Subject: [PATCH 3/4] Fix port. --- test/wdio.circleci.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/wdio.circleci.conf.js b/test/wdio.circleci.conf.js index eb99fe7c..64f4f4b8 100644 --- a/test/wdio.circleci.conf.js +++ b/test/wdio.circleci.conf.js @@ -9,7 +9,7 @@ Config for running selenium from a circleci docker container against localhost /*/ exports.config = Object.assign({}, common.config, { - baseUrl: `http://${ip.address()}:8080`, + baseUrl: `http://${ip.address()}:8000`, maxInstances: 1, bail: 1, services: [require('./testServer'), 'selenium-standalone'] From 3f8ebdaf4bb55db92cf8701347afa4353a130c86 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Wed, 13 Mar 2019 10:02:36 -0400 Subject: [PATCH 4/4] Remove extra changes from package.json. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93c560f9..0bee8dcb 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "test:backend": "nyc --reporter=lcovonly mocha --reporter=min test/backend", "test:frontend": "cross-env NODE_ENV=development node test/frontend/runner.js", "test:report": "nyc report --reporter=html", - "test-integration": "cross-env NODE_ENV=development ANDROID=1 wdio test/wdio.local.conf.js", + "test-integration": "cross-env NODE_ENV=development wdio test/wdio.docker.conf.js", "circleci-test-integration": "cross-env NODE_ENV=development wdio test/wdio.circleci.conf.js", "start": "npm run clean && cross-env NODE_ENV=development FXA_CLIENT_ID=fced6b5e3f4c66b9 BASE_URL=http://localhost:8080 webpack-dev-server --mode=development", "android": "cross-env ANDROID=1 npm start",