couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [4/7] fauxton commit: updated refs/heads/master to ced196a
Date Tue, 12 Jul 2016 17:25:19 GMT
Move selenium to docker

This runs selenium and CouchDB in a docker instance for the nightwatch
tests. It also includes a selenium debug container that allows you to
view the tests via VNC. This change is to make the running of the
selenium tests more consistent for all developers and the same as on
Travis.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/62c83b5a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/62c83b5a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/62c83b5a

Branch: refs/heads/master
Commit: 62c83b5a0f3e56491aba2f25be76b383f1d073a0
Parents: c5fc701
Author: Garren Smith <garren.smith@gmail.com>
Authored: Thu Jun 30 12:33:55 2016 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Jul 12 19:24:44 2016 +0200

----------------------------------------------------------------------
 .travis.yml                                     | 55 +++++++++-----------
 Gruntfile.js                                    |  3 +-
 .../tests/nightwatch/deletesDocuments.js        |  4 +-
 .../tests/nightwatch/uploadAttachment.js        |  4 +-
 .../documents/tests/nightwatch/viewCreate.js    |  4 +-
 .../documents/tests/nightwatch/viewEdit.js      |  4 ++
 devserver.js                                    |  2 +-
 docker/dc.selenium-debug.yml                    |  8 +++
 docker/dc.selenium.yml                          | 13 +++++
 index.js                                        |  2 +-
 package.json                                    | 10 +++-
 settings.json.default.json                      | 13 ++++-
 tasks/fauxton.js                                | 16 ++++--
 tasks/helper.js                                 | 12 +++--
 .../nightwatch_tests/nightwatch.json.underscore |  6 +--
 tests.md                                        | 34 ++++++++----
 16 files changed, 127 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 452e55a..d2419a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,42 +1,39 @@
-language: erlang
-otp_release:
-   - 17.4
+language: node
+node_js:
+   - 6
+sudo: required
+services:
+  - docker
 git:
-  depth: 10
+  depth: 1
 
-addons:
-  firefox: "38.0.1"
-before_install:
-  - sudo apt-get update -qq
-  - sudo apt-get install -qq flashplugin-installer
-  - sudo apt-get -y install libicu-dev libmozjs-dev pkg-config help2man libcurl4-openssl-dev
-  - sudo apt-get -y install libtool automake autoconf autoconf-archive
-  - sudo apt-get -y install haproxy
-  - nvm install 6 && nvm use 6
+env:
+  DOCKER_COMPOSE_VERSION: 1.8.0-rc1
 
-  - cd ..
-  - git clone --depth=1 https://github.com/apache/couchdb
-  - cd couchdb
-  - ./configure --disable-docs
-  - make
-  - ./dev/run --admin=tester:testerpass &
-  - haproxy -f rel/haproxy.cfg &
-  - cd .. && cd couchdb-fauxton
-  - npm install
-
-  - export DISPLAY=:99.0
-  - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1400x900x16"
+before_install:
+  - sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list'
+  - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
+  - sudo apt-get update
+  - sudo apt-key update
+  - sudo apt-get -qqy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
install docker-engine=1.11.1-0~precise
+  - sudo rm /usr/local/bin/docker-compose
+  - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname
-s`-`uname -m` > docker-compose
+  - chmod +x docker-compose
+  - sudo mv docker-compose /usr/local/bin
 
 before_script:
-  - npm run stylecheck
+  - npm run docker:up
+  - npm install
+  - docker logs couchdb
+  - docker logs selenium
+  - curl http://127.0.0.1:5984
   - npm test
   - grunt debugDev
   - DIST=./dist/debug ./bin/fauxton &
   - sleep 30
 script:
   - ./node_modules/grunt-cli/bin/grunt nightwatch
+after_script:
+  - npm run docker:down
 
 cache: apt
-
-git:
-  depth: 1

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index f2cc6e1..1675d3d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -248,6 +248,7 @@ module.exports = function (grunt) {
 
     exec: {
       check_selenium: initHelper.check_selenium,
+      check_chrome: initHelper.check_chrome,
       start_nightWatch: {
         command: __dirname + '/node_modules/nightwatch/bin/nightwatch' +
         ' -c ' + __dirname + '/test/nightwatch_tests/nightwatch.json'
@@ -360,5 +361,5 @@ module.exports = function (grunt) {
    * Nightwatch functional testing
    */
   //Start Nightwatch test from terminal, using: $ grunt nightwatch
-  grunt.registerTask('nightwatch', ['exec:check_selenium', 'initNightwatch', 'exec:start_nightWatch']);
+  grunt.registerTask('nightwatch', ['initNightwatch', 'exec:start_nightWatch']);
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/app/addons/documents/tests/nightwatch/deletesDocuments.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/deletesDocuments.js b/app/addons/documents/tests/nightwatch/deletesDocuments.js
index 3a1e9ad..b5e3b7f 100644
--- a/app/addons/documents/tests/nightwatch/deletesDocuments.js
+++ b/app/addons/documents/tests/nightwatch/deletesDocuments.js
@@ -90,11 +90,11 @@ module.exports = {
       // confirm the design doc appears in the sidebar
       .waitForElementPresent('#sidebar-content span[title="_design/sidebar-update"]', waitTime,
false)
       .waitForElementPresent('label[for="checkbox-_design/sidebar-update"]', waitTime, false)
-      .execute('$("label[for=\'checkbox-_design/sidebar-update\']")[0].scrollIntoView();')
+      .execute('$("label[for=\'checkbox-_design/sidebar-update\']")[0].scrollIntoView(false);')
       .clickWhenVisible('label[for="checkbox-_design/sidebar-update"]', waitTime, false)
 
       .waitForElementPresent('.bulk-action-component-selector-group .fonticon-trash', waitTime,
false)
-      .execute('$(".bulk-action-component-selector-group .fonticon-trash")[0].scrollIntoView();')
+      .execute('$(".bulk-action-component-selector-group .fonticon-trash")[0].scrollIntoView(false);')
       .clickWhenVisible('.bulk-action-component-selector-group .fonticon-trash')
       .acceptAlert()
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/app/addons/documents/tests/nightwatch/uploadAttachment.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/uploadAttachment.js b/app/addons/documents/tests/nightwatch/uploadAttachment.js
index c967abe..3bc3ba4 100644
--- a/app/addons/documents/tests/nightwatch/uploadAttachment.js
+++ b/app/addons/documents/tests/nightwatch/uploadAttachment.js
@@ -10,8 +10,8 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-
-
+// add to ignore list for now since selenium is running in its own container
+// we cannot link to the file
 module.exports = {
   'Uploading an attachment works': function (client) {
     /*jshint multistr: true */

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/app/addons/documents/tests/nightwatch/viewCreate.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/viewCreate.js b/app/addons/documents/tests/nightwatch/viewCreate.js
index aeb7304..3c8e2bf 100644
--- a/app/addons/documents/tests/nightwatch/viewCreate.js
+++ b/app/addons/documents/tests/nightwatch/viewCreate.js
@@ -71,16 +71,15 @@ module.exports = {
     /*jshint multistr: true */
     openDifferentDropdownsAndClick(client, '#header-dropdown-menu')
       .waitForElementPresent('#new-ddoc', waitTime, false)
-      .waitForElementVisible('#new-ddoc', waitTime, false)
       .setValue('#new-ddoc', 'test_design_doc-selenium-2')
       .clearValue('#index-name')
       .setValue('#index-name', 'gaenseindex')
-      .sendKeys("textarea.ace_text-input", client.Keys.Enter)
       .execute('\
         var editor = ace.edit("map-function");\
         editor.getSession().setValue("function (doc) { emit(\'gansgans\'); }");\
       ')
       .execute('$("#save-view")[0].scrollIntoView();')
+      .waitForElementPresent('#save-view', waitTime, false)
       .clickWhenVisible('#save-view')
       .checkForDocumentCreated('_design/test_design_doc-selenium-2')
       .waitForElementPresent('.prettyprint', waitTime, false)
@@ -104,7 +103,6 @@ module.exports = {
       .waitForElementVisible('#index-name', waitTime, false)
       .clearValue('#index-name')
       .setValue('#index-name', 'test-new-view')
-      .sendKeys("textarea.ace_text-input", client.Keys.Enter)
       .execute('\
         var editor = ace.edit("map-function");\
         editor.getSession().setValue("function (doc) { emit(\'enteente\', 1); }");\

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/app/addons/documents/tests/nightwatch/viewEdit.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/viewEdit.js b/app/addons/documents/tests/nightwatch/viewEdit.js
index f755d38..f8d9229 100644
--- a/app/addons/documents/tests/nightwatch/viewEdit.js
+++ b/app/addons/documents/tests/nightwatch/viewEdit.js
@@ -144,9 +144,13 @@ module.exports = {
 
       // create the second view
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
       .waitForElementPresent(dropDownElement, waitTime, false)
+      .waitForElementPresent(dropDownElement + ' a', waitTime, false)
       .clickWhenVisible(dropDownElement + ' a')
+      .waitForElementPresent(dropDownElement + ' a[href*="new_view"]', waitTime, false)
       .clickWhenVisible(dropDownElement + ' a[href*="new_view"]')
+      .waitForElementPresent('.index-cancel-link', waitTime, false)
       .waitForElementVisible('#new-ddoc', waitTime, false)
       .waitForElementNotPresent('.spinner', waitTime, true)
       .waitForElementNotPresent('.loading-lines', waitTime, true)

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/devserver.js
----------------------------------------------------------------------
diff --git a/devserver.js b/devserver.js
index eac4d5d..3bef0a8 100644
--- a/devserver.js
+++ b/devserver.js
@@ -108,7 +108,7 @@ var runWebpackServer = function () {
     proxy.web(req, res);
   });
 
-  server.listen(options.port, options.host, function (err) {
+  server.listen(options.port, '0.0.0.0', function (err) {
     if (err) {
       console.log(err);
       return;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/docker/dc.selenium-debug.yml
----------------------------------------------------------------------
diff --git a/docker/dc.selenium-debug.yml b/docker/dc.selenium-debug.yml
new file mode 100644
index 0000000..98dd11b
--- /dev/null
+++ b/docker/dc.selenium-debug.yml
@@ -0,0 +1,8 @@
+version: '2'
+services:
+  selenium:
+    container_name: selenium
+    image: selenium/standalone-firefox-debug:2.48.2
+    ports:
+      - "4444:4444"
+      - "5900:5900"

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/docker/dc.selenium.yml
----------------------------------------------------------------------
diff --git a/docker/dc.selenium.yml b/docker/dc.selenium.yml
new file mode 100644
index 0000000..f5004df
--- /dev/null
+++ b/docker/dc.selenium.yml
@@ -0,0 +1,13 @@
+version: '2'
+services:
+  selenium:
+    container_name: selenium
+    image: selenium/standalone-firefox:2.48.2
+    ports:
+      - "4444:4444"
+  couchdb:
+    container_name: couchdb
+    image: klaemo/couchdb:2.0-dev
+    command: '--with-haproxy -a tester:testerpass'
+    ports:
+      - "5984:5984"

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/index.js
----------------------------------------------------------------------
diff --git a/index.js b/index.js
index 82b2645..5ad25fe 100644
--- a/index.js
+++ b/index.js
@@ -67,7 +67,7 @@ module.exports = function (options) {
     req.headers.host = urlObj.host;
 
     proxy.web(req, res);
-  }).listen(port);
+  }).listen(port, '0.0.0.0');
 
   proxy.on('error', function (e) {
     // don't explode on cancelled requests

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 58b3b67..db388e4 100644
--- a/package.json
+++ b/package.json
@@ -108,8 +108,14 @@
     "dev": "node ./devserver.js",
     "nightwatch": "grunt nightwatch",
     "start": "node ./bin/fauxton",
-    "prepublish": "node version-check.js && grunt release",
-    "create:animaldb": "./bin/create-animal-db"
+    "preversion": "node version-check.js && grunt release",
+    "create:animaldb": "./bin/create-animal-db",
+    "docker:couchdb-up": "docker-compose -f ./docker/dc.selenium.yml up -d couchdb",
+    "docker:reset": "npm run docker:down && npm run docker:up",
+    "docker:logs": "docker logs couchdb",
+    "docker:up": "docker-compose -f ./docker/dc.selenium.yml up -d",
+    "docker:debug-up": "docker-compose -f ./docker/dc.selenium.yml -f ./docker/dc.selenium-debug.yml
up -d",
+    "docker:down": "docker-compose -f ./docker/dc.selenium.yml down"
   },
   "repository": {
     "type": "git",

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/settings.json.default.json
----------------------------------------------------------------------
diff --git a/settings.json.default.json b/settings.json.default.json
index a65f6ed..0fbd829 100644
--- a/settings.json.default.json
+++ b/settings.json.default.json
@@ -76,12 +76,21 @@
     "nightwatch": {
       "fauxton_username": "tester",
       "password": "testerpass",
-      "fauxton_host": "localhost",
+      "fauxton_host": "127.0.0.1",
       "fauxton_port": "8000",
       "db_host": "localhost",
       "db_port": "5984",
       "custom_commands_path": ["test/nightwatch_tests/custom-commands", "test/nightwatch_tests/custom-commands/auth"],
       "globals_path": "test/nightwatch_tests/helpers/helpers.js",
-      "selenium_port": "4444"
+      "selenium_port": "4444",
+      "testBlacklist": {
+        "databases": [
+          "zeroclipboard.js"
+        ],
+        "documents": [
+          "uploadAttachment.js",
+          "navigateToNewView.js"
+        ]
+      }
     }
 }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/tasks/fauxton.js b/tasks/fauxton.js
index 7a220e4..4b7fa6c 100644
--- a/tasks/fauxton.js
+++ b/tasks/fauxton.js
@@ -12,7 +12,8 @@
 
 module.exports = function (grunt) {
   var _ = grunt.util._,
-      fs = require('fs');
+      fs = require('fs'),
+      os = require('os');
 
   grunt.registerMultiTask('template', 'generates an html file from a specified template',
function () {
     var data = this.data,
@@ -131,7 +132,6 @@ module.exports = function (grunt) {
 
   // run every time nightwatch is executed from the command line
   grunt.registerMultiTask('initNightwatch', 'Sets up Nightwatch', function () {
-
     // perform a little validation on the settings
     _validateNightwatchSettings(this.data.settings);
 
@@ -140,6 +140,7 @@ module.exports = function (grunt) {
     var result = _getNightwatchTests(this.data.settings);
     var addonsWithTests = result.addonFolders;
     var excludeTests = result.excludeTests;
+    console.log('addons and excluded', addonsWithTests, excludeTests);
 
     // if the user passed a --file="X" on the command line, filter out
     var singleTestToRun = grunt.option('file');
@@ -157,7 +158,7 @@ module.exports = function (grunt) {
       fauxton_username: this.data.settings.nightwatch.fauxton_username,
       password: this.data.settings.nightwatch.password,
       launch_url: this.data.settings.nightwatch.launch_url,
-      fauxton_host: this.data.settings.nightwatch.fauxton_host,
+      fauxton_host: _getHostIpAddresss(),
       fauxton_port: this.data.settings.nightwatch.fauxton_port,
       db_host: this.data.settings.nightwatch.db_host,
       db_port: this.data.settings.nightwatch.db_port,
@@ -168,6 +169,15 @@ module.exports = function (grunt) {
 
   // HELPERS
 
+  function _getHostIpAddresss () {
+    //making some assumptions here
+    const interfaces = os.networkInterfaces();
+    const eth0 = interfaces[Object.keys(interfaces)[1]];
+    return eth0.find(function (item) {
+      return item.family === 'IPv4';
+    }).address;
+  }
+
   function _validateNightwatchSettings (data) {
     var error = '';
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/tasks/helper.js
----------------------------------------------------------------------
diff --git a/tasks/helper.js b/tasks/helper.js
index 02fd6b4..97d160c 100644
--- a/tasks/helper.js
+++ b/tasks/helper.js
@@ -58,9 +58,15 @@ exports.init = function (grunt) {
     },
 
     check_selenium: {
-      command: 'test -s ./test/nightwatch_tests/selenium/selenium-server-standalone-2.45.0.jar
|| ' +
-        'curl -o ./test/nightwatch_tests/selenium/selenium-server-standalone-2.45.0.jar '
+
-        'http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar'
+      command: 'test -s ./test/nightwatch_tests/selenium/selenium-server-standalone-2.53.0.jar
|| ' +
+        'curl -o ./test/nightwatch_tests/selenium/selenium-server-standalone-2.53.0.jar '
+
+        'http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar'
+    },
+    check_chrome: {
+      command: 'test -s ./test/nightwatch_tests/selenium/selenium-server-standalone-2.53.0.jar
|| ' +
+        'curl -o ./test/nightwatch_tests/selenium/chromedriver_mac32.zip' +
+        'http://chromedriver.storage.googleapis.com/2.22/chromedriver_mac32.zip' +
+        '&& tar -xvf ./test/nightwatch_tests/selenium/chromedriver_mac32.zip -C ./test/nightwatch_tests/selenium/'
     }
   };
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/test/nightwatch_tests/nightwatch.json.underscore
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/nightwatch.json.underscore b/test/nightwatch_tests/nightwatch.json.underscore
index 9d33770..c0d1580 100644
--- a/test/nightwatch_tests/nightwatch.json.underscore
+++ b/test/nightwatch_tests/nightwatch.json.underscore
@@ -8,8 +8,8 @@
   "live_output" : false,
 
   "selenium" : {
-    "start_process" : true,
-    "server_path" : "test/nightwatch_tests/selenium/selenium-server-standalone-2.45.0.jar",
+    "start_process" : false,
+    "server_path" : "test/nightwatch_tests/selenium/selenium-server-standalone-2.53.0.jar",
     "log_path" : "",
     "host" : "127.0.0.1",
     "port" : "<%- selenium_port %>",
@@ -48,7 +48,7 @@
         "javascriptEnabled" : true,
         "acceptSslCerts" : true,
         "chromeOptions" : {
-          "args" : ["window-size=1400,900"]
+          "args" : ["window-size=1400,900", "--no-sandbox"]
         }
       }
     },

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62c83b5a/tests.md
----------------------------------------------------------------------
diff --git a/tests.md b/tests.md
index cc0f615..e761881 100644
--- a/tests.md
+++ b/tests.md
@@ -1,6 +1,6 @@
 # Tests
 
-Fauxton has both test coverage through unit and selenium tests, built on 
+Fauxton has both test coverage through unit and selenium tests, built on
 [Mocha](https://mochajs.org/) and [Nightwatch](http://nightwatchjs.org/) respectively.
 
 
@@ -21,24 +21,36 @@ Refreshing the URL will re-run the tests via PhantomJS and in the browser.
 
 ## Selenium tests
 
-There is a bit of setup involved before you are able to run the Nightwatch selenium tests.
+To run selenium locally you need docker installed. Selenium runs in a docker container and
connects to a CouchDB instance in another container. To start them run the command:
 
-First, in your CouchDB admin accounts, add a user:
+    npm run docker:up
 
-> user: tester  
-password: testerpass  
+You can run `npm run docker:logs` to see when the CouchDB instance is ready to go. You also
need a Fauxton server instance runnning:
 
-Then on the command line:  
+    npm run dev
+    or
+    grunt debugDev && DIST=./dist/debug ./bin/fauxton`
 
-    npm install
+Finally to run the tests:
 
-Start Fauxton with
+    grunt nightwatch
 
-    grunt dev
+Or to run only one file:
 
-And to run the tests (in another terminal tab):
+    grunt nightwatch --file=viewEdit
 
-    grunt nightwatch
+View the package.json `scripts` section for some other useful docker commands.
+
+### Debugging Selenium tests
+
+To debug and view a failing selenium test, you need to run the selenium container with vnc
built into it:
+
+    npm run docker:debug-up
+
+Once it is up and running you can connect to it with any VNC client on `127.0.0.1:5900`.
On MacOSX open safari
+and type `vnc://127.0.0.1:5900`. That will open screen sharing. It will then prompt for the
password which is `secret`.
+
+After that run a Fauxton server instance and the nightwatch tests you want to debug.
 
 
 ### Omitting Nightwatch tests


Mime
View raw message