couchdb-commits mailing list archives

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

Stabilise some of the tests. Add a remove test db command and a script
to install docker 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/99802f32
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/99802f32
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/99802f32

Branch: refs/heads/master
Commit: 99802f328daa62eb3ffc6ca6a8c63391948166a2
Parents: 0c61177
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed Jul 6 11:58:13 2016 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Jul 12 19:24:44 2016 +0200

----------------------------------------------------------------------
 .travis.yml                                     |  3 --
 .../tests/nightwatch/deletesDatabase.js         |  2 ++
 .../documents/tests/nightwatch/cloneDoc.js      |  3 +-
 .../documents/tests/nightwatch/paginateView.js  |  1 +
 .../documents/tests/nightwatch/tableView.js     |  2 ++
 .../tests/nightwatch/tableViewConflicts.js      |  1 +
 bin/install-docker-travis.sh                    |  2 +-
 bin/remove-test-dbs.js                          | 30 ++++++++++++++++++++
 package.json                                    |  3 +-
 tasks/fauxton.js                                |  9 +++---
 test/nightwatch_tests/helpers/helpers.js        |  2 +-
 tests.md                                        |  4 +++
 12 files changed, 50 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 92c19dc..e9677d3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,9 +7,6 @@ services:
 git:
   depth: 1
 
-env:
-  DOCKER_COMPOSE_VERSION: 1.8.0-rc1
-
 before_script:
   - ./bin/install-docker-travis.sh
   - npm run docker:up

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/app/addons/databases/tests/nightwatch/deletesDatabase.js
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/nightwatch/deletesDatabase.js b/app/addons/databases/tests/nightwatch/deletesDatabase.js
index 0c613cc..f5672b3 100644
--- a/app/addons/databases/tests/nightwatch/deletesDatabase.js
+++ b/app/addons/databases/tests/nightwatch/deletesDatabase.js
@@ -48,6 +48,8 @@ module.exports = {
       .assert.elementPresent('a[href="#/database/' + newDatabaseName + '/_all_docs"]')
       .clickWhenVisible('[title="Delete ' + newDatabaseName + '"]', waitTime, false)
       .setValue('.delete-db-modal input[type="text"]', [newDatabaseName, client.Keys.ENTER])
+      .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
+      .waitForElementPresent('.fauxton-table-list', waitTime, false)
       .checkForDatabaseDeleted(newDatabaseName, waitTime)
       .assert.elementNotPresent('a[href="#/database/' + newDatabaseName + '/_all_docs"]')
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/app/addons/documents/tests/nightwatch/cloneDoc.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/cloneDoc.js b/app/addons/documents/tests/nightwatch/cloneDoc.js
index 7932ac4..674ccb6 100644
--- a/app/addons/documents/tests/nightwatch/cloneDoc.js
+++ b/app/addons/documents/tests/nightwatch/cloneDoc.js
@@ -12,7 +12,7 @@
 
 
 module.exports = {
-  'Deletes a document via Editor': function (client) {
+  'Clones a document via Editor': function (client) {
     const waitTime = client.globals.maxWaitTime;
     const newDatabaseName = client.globals.testDatabaseName;
     const newDocumentName = 'clone_doc_doc';
@@ -43,6 +43,7 @@ module.exports = {
 
       .url(`${baseUrl}'/'${newDatabaseName}/${newDocumentName}`)
       .waitForElementPresent('#editor-container', waitTime, false)
+      .waitForElementNotPresent('.loading-lines', waitTime, false)
       .getText('#editor-container', function (result) {
         const data = result.value;
         const isCreatedDocumentPresent = data.indexOf('ente') !== -1;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/app/addons/documents/tests/nightwatch/paginateView.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/paginateView.js b/app/addons/documents/tests/nightwatch/paginateView.js
index f5ccc3a..5cfe02b 100644
--- a/app/addons/documents/tests/nightwatch/paginateView.js
+++ b/app/addons/documents/tests/nightwatch/paginateView.js
@@ -71,6 +71,7 @@ module.exports = {
 
       // http://www.w3.org/TR/2012/WD-webdriver-20120710/
       .keys(['\uE013', '\uE006'])
+      .waitForElementNotPresent('.loading-lines', waitTime, false)
       .waitForElementPresent('#next', waitTime, false)
       .clickWhenVisible('#next', waitTime, false)
       .waitForElementNotPresent('div[data-id="document_1"]', waitTime)

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/app/addons/documents/tests/nightwatch/tableView.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/tableView.js b/app/addons/documents/tests/nightwatch/tableView.js
index 05f3ce4..70e0479 100644
--- a/app/addons/documents/tests/nightwatch/tableView.js
+++ b/app/addons/documents/tests/nightwatch/tableView.js
@@ -28,6 +28,7 @@ module.exports = {
       .checkForDocumentCreated(newDocumentName1)
       .checkForDocumentCreated(newDocumentName2)
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs?include_docs=true')
+      .waitForElementVisible('.prettyprint', waitTime, false)
 
       .clickWhenVisible('.alternative-header .two-sides-toggle-button button:last-child')
       .waitForElementVisible('.tableview-checkbox-cell', client.globals.maxWaitTime, false)
@@ -59,6 +60,7 @@ module.exports = {
       .checkForDocumentCreated(newDocumentName1)
       .checkForDocumentCreated(newDocumentName2)
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementVisible('.prettyprint', waitTime, false)
 
       .clickWhenVisible('.alternative-header .two-sides-toggle-button button:last-child')
       .waitForElementVisible('.tableview-checkbox-cell', client.globals.maxWaitTime, false)

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/app/addons/documents/tests/nightwatch/tableViewConflicts.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/tableViewConflicts.js b/app/addons/documents/tests/nightwatch/tableViewConflicts.js
index 5122620..b644f16 100644
--- a/app/addons/documents/tests/nightwatch/tableViewConflicts.js
+++ b/app/addons/documents/tests/nightwatch/tableViewConflicts.js
@@ -24,6 +24,7 @@ module.exports = {
       .checkForDocumentCreated('outfit1')
       .loginToGUI()
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+      .waitForElementVisible('.prettyprint', waitTime, false)
 
       .clickWhenVisible('.alternative-header .two-sides-toggle-button button:last-child')
       .waitForElementVisible('.table', waitTime, false)

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/bin/install-docker-travis.sh
----------------------------------------------------------------------
diff --git a/bin/install-docker-travis.sh b/bin/install-docker-travis.sh
index 846428f..c8ba2e7 100755
--- a/bin/install-docker-travis.sh
+++ b/bin/install-docker-travis.sh
@@ -5,6 +5,6 @@ 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
+curl -L https://github.com/docker/compose/releases/download/1.8.0-rc1/docker-compose-`uname
-s`-`uname -m` > docker-compose
 chmod +x docker-compose
 sudo mv docker-compose /usr/local/bin

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/bin/remove-test-dbs.js
----------------------------------------------------------------------
diff --git a/bin/remove-test-dbs.js b/bin/remove-test-dbs.js
new file mode 100755
index 0000000..3b8fa88
--- /dev/null
+++ b/bin/remove-test-dbs.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+const fs = require('fs');
+
+const settingsFilePath = './settings.json';
+const settingsFile = fs.existsSync(settingsFilePath) ? settingsFilePath : './settings.json.default.json';
+const settings = JSON.parse(fs.readFileSync(settingsFile)).nightwatch;
+const dbUrl = `http://${settings.fauxton_username}:${settings.password}@${settings.db_host}:${settings.db_port}`;
+const nano = require('nano')(dbUrl);
+
+nano.db.list((err, body) => {
+  if (err) {
+    console.log('ERR', err);
+    return;
+  }
+  const out = body.forEach(db => {
+    if (!/fauxton-selenium-tests/.test(db)) {
+      return;
+    }
+
+    console.log('removing', db);
+    nano.db.destroy(db, (err, resp) => {
+      if (err) {
+        console.log('ERR deleting ', db, err);
+        return;
+      }
+    });
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 1cd6ad8..ea12e0c 100644
--- a/package.json
+++ b/package.json
@@ -118,7 +118,8 @@
     "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-debug.yml up -d",
-    "docker:down": "docker-compose -f ./docker/dc.selenium.yml down"
+    "docker:down": "docker-compose -f ./docker/dc.selenium.yml down",
+    "remove-test-dbs": "node ./bin/remove-test-dbs.js"
   },
   "repository": {
     "type": "git",

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/tasks/fauxton.js b/tasks/fauxton.js
index 779261a..abfaf9d 100644
--- a/tasks/fauxton.js
+++ b/tasks/fauxton.js
@@ -158,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: _getHost(),
+      fauxton_host: _getHost(this.data.settings.nightwatch.fauxton_ip),
       fauxton_port: this.data.settings.nightwatch.fauxton_port,
       db_host: this.data.settings.nightwatch.db_host,
       db_port: this.data.settings.nightwatch.db_port,
@@ -166,13 +166,12 @@ module.exports = function (grunt) {
     }));
   });
 
-
   // HELPERS
 
   //if FAUXTON_HOST not set use ip address
-  function _getHost () {
-    if (process.env.FAUXTON_HOST) {
-      return process.env.FAUXTON_HOST;
+  function _getHost (fauxton_ip) {
+    if (fauxton_ip) {
+      return fauxton_ip;
     }
     //making some assumptions here
     const interfaces = os.networkInterfaces();

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/test/nightwatch_tests/helpers/helpers.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/helpers/helpers.js b/test/nightwatch_tests/helpers/helpers.js
index c087f75..137e19e 100644
--- a/test/nightwatch_tests/helpers/helpers.js
+++ b/test/nightwatch_tests/helpers/helpers.js
@@ -18,7 +18,6 @@ function getRandomInt(min, max) {
 }
 
 const dbName = 'fauxton-selenium-tests-' + getRandomInt(1, 20000);
-console.log('ssss', process.env.CLOUDANT_PWD, process.env.CLOUDANT_USER);
 
 module.exports = {
   asyncHookTimeout: 20000,
@@ -26,6 +25,7 @@ module.exports = {
   testDatabaseName : dbName,
 
   getNanoInstance: function (dbURL) {
+    console.log('bbb', dbURL);
     return nano(dbURL);
   },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/99802f32/tests.md
----------------------------------------------------------------------
diff --git a/tests.md b/tests.md
index 1b0b81b..201d3f2 100644
--- a/tests.md
+++ b/tests.md
@@ -75,3 +75,7 @@ your settings.json file. That defines an object of the following form:
 The properties (`documents`, `databases`) map to a particular addon folder name (see `app/addons`).
The values
 should be an array of tests that you don't want to run. `*` will flag all tests from being
ran, otherwise you
 just enter the names of the files to omit.
+
+### Cleaning up old tests
+
+Each test run generates a new database. Sometimes these databases will not be removed. You
can run `npm run remove-test-dbs` to clean up any left over databases.


Mime
View raw message