You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by we...@apache.org on 2013/04/09 01:33:51 UTC
[1/6] git commit: updated refs/heads/master to 9dfddaa
Updated Branches:
refs/heads/master e65d7b733 -> 9dfddaa7b
Ensure that waitForSuccess calls have return values.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c43b84dc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c43b84dc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c43b84dc
Branch: refs/heads/master
Commit: c43b84dcc426dad888852eea078bbd96d796f928
Parents: e65d7b7
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:38:20 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:38:20 2013 -0700
----------------------------------------------------------------------
share/www/script/test/changes.js | 13 ++++++++++++-
share/www/script/test/oauth.js | 1 +
2 files changed, 13 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c43b84dc/share/www/script/test/changes.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js
index d76c193..00944f7 100644
--- a/share/www/script/test/changes.js
+++ b/share/www/script/test/changes.js
@@ -92,6 +92,7 @@ couchTests.changes = function(debug) {
if (change2.seq != 2) {
throw "bad seq, try again";
}
+ return true;
}, "bar-only");
T(change1.seq == 1);
@@ -112,6 +113,7 @@ couchTests.changes = function(debug) {
if (change3.seq != 3) {
throw "bad seq, try again";
}
+ return true;
});
T(change3.seq == 3);
@@ -131,6 +133,7 @@ couchTests.changes = function(debug) {
if (str.charAt(str.length - 1) != "\n" || str.charAt(str.length - 2) != "\n") {
throw("keep waiting");
}
+ return true;
}, "heartbeat");
T(str.charAt(str.length - 1) == "\n");
@@ -152,8 +155,10 @@ couchTests.changes = function(debug) {
source.addEventListener('message', sourceListener , false);
waitForSuccess(function() {
- if (results.length != 3)
+ if (results.length != 3) {
throw "bad seq, try again";
+ }
+ return true;
});
source.removeEventListener('message', sourceListener, false);
@@ -177,6 +182,7 @@ couchTests.changes = function(debug) {
if (lines[5] != '"last_seq":3}') {
throw("still waiting");
}
+ return true;
}, "last_seq");
xhr = CouchDB.newXhr();
@@ -201,6 +207,7 @@ couchTests.changes = function(debug) {
if (lines[3] != '"last_seq":4}') {
throw("still waiting");
}
+ return true;
}, "change_lines");
var change = parse_changes_line(lines[1]);
@@ -233,6 +240,7 @@ couchTests.changes = function(debug) {
if (lines[3] != '"last_seq":5}') {
throw("still waiting");
}
+ return true;
}, "change_lines");
var change = parse_changes_line(lines[1]);
@@ -313,6 +321,7 @@ couchTests.changes = function(debug) {
waitForSuccess(function() {
resp = JSON.parse(xhr.responseText);
+ return true;
}, "longpoll-since");
T(resp.last_seq == 10);
@@ -337,6 +346,7 @@ couchTests.changes = function(debug) {
if (xhr.readyState != 4) {
throw("still waiting");
}
+ return true;
}, "continuous-rusty");
lines = xhr.responseText.split("\n");
var good = false;
@@ -529,6 +539,7 @@ couchTests.changes = function(debug) {
if (xhr.readyState != 4) {
throw("still waiting");
}
+ return true;
}, "andmore-only");
var line = JSON.parse(xhr.responseText.split("\n")[0]);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c43b84dc/share/www/script/test/oauth.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/oauth.js b/share/www/script/test/oauth.js
index 89d3779..9199cd0 100644
--- a/share/www/script/test/oauth.js
+++ b/share/www/script/test/oauth.js
@@ -108,6 +108,7 @@ couchTests.oauth = function(debug) {
if (xhr.responseText.indexOf("\"-pbkdf2-") != 0) {
throw("still waiting");
}
+ return true;
}, "wait-for-admin");
CouchDB.newUuids(2); // so we have one to make the salt
[5/6] git commit: updated refs/heads/master to 9dfddaa
Posted by we...@apache.org.
Added supplementary functions for running tests from command line.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/826eba77
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/826eba77
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/826eba77
Branch: refs/heads/master
Commit: 826eba77b96b885aca9873c649e0d2849e170f7a
Parents: 0ada343
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:45:18 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:45:18 2013 -0700
----------------------------------------------------------------------
test/javascript/test_setup.js | 89 ++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/826eba77/test/javascript/test_setup.js
----------------------------------------------------------------------
diff --git a/test/javascript/test_setup.js b/test/javascript/test_setup.js
new file mode 100644
index 0000000..9347455
--- /dev/null
+++ b/test/javascript/test_setup.js
@@ -0,0 +1,89 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+/*
+ * Add global couchTests object required for existing tests.
+ */
+var couchTests = {};
+
+var console = {
+ log: function(arg) {
+ var msg = (arg.toString()).replace(/\n/g, "\n ");
+ print(msg, true);
+ }
+};
+
+var fmtStack = function(stack) {
+ if(!stack) {
+ console.log("No stack information");
+ return;
+ }
+ console.log("Trace back (most recent call first):\n");
+ var re = new RegExp("(.*?)@([^:]*):(.*)$");
+ var lines = stack.split("\n");
+ for(var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if(!line.length) continue;
+ var match = re.exec(line);
+ if(!match) continue
+ var match = re.exec(line);
+ if(!match) continue
+ var source = match[1].substr(0, 70);
+ var file = match[2];
+ var lnum = match[3];
+ while(lnum.length < 3) lnum = " " + lnum;
+ console.log(" " + lnum + ": " + file);
+ console.log(" " + source);
+ }
+}
+
+function T(arg1, arg2) {
+ if(!arg1) {
+ var result = (arg2 ? arg2 : arg1);
+ throw((result instanceof Error ? result : Error(result)));
+ }
+}
+
+function waitForSuccess(fun, tag) {
+ var start = new Date().getTime();
+ var complete = false;
+
+ while (!complete) {
+ var now = new Date().getTime();
+ if (now > start + 5000) {
+ complete = true;
+ print('FAIL');
+ print(tag);
+ quit(1);
+ }
+ try {
+ while (new Date().getTime() < now + 500);
+ complete = fun();
+ } catch (e) {}
+ }
+}
+
+function restartServer() {
+ print('restart');
+ var start = new Date().getTime();
+ while (new Date().getTime() < start + 1000);
+ waitForSuccess(CouchDB.isRunning, 'restart');
+}
+
+/*
+ * If last_req is an object, we got something back. This might be an error, but
+ * CouchDB is up and running!
+ */
+CouchDB.isRunning = function() {
+ CouchDB.last_req = CouchDB.request("GET", "/");
+ return typeof CouchDB.last_req == 'object';
+};
[6/6] git commit: updated refs/heads/master to 9dfddaa
Posted by we...@apache.org.
Refactor javascript runner script to handle couchdb restarts. Single interpreter per test.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9dfddaa7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9dfddaa7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9dfddaa7
Branch: refs/heads/master
Commit: 9dfddaa7bf30d30c8fbbc4e1cc2bff4dc35dadac
Parents: 826eba7
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:46:54 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:46:54 2013 -0700
----------------------------------------------------------------------
test/javascript/run.tpl | 117 +++++++++++++++++++++++++++--------------
1 files changed, 77 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9dfddaa7/test/javascript/run.tpl
----------------------------------------------------------------------
diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
index 39a47a6..d9f7365 100644
--- a/test/javascript/run.tpl
+++ b/test/javascript/run.tpl
@@ -27,9 +27,83 @@ if [ -z "$MAKE" ]; then
MAKE=make
fi
+trap 'abort' EXIT INT
+
+start() {
+ ./utils/run -b -r 0 -n \
+ -a $BUILD_DIR/etc/couchdb/default_dev.ini \
+ -a $SRC_DIR/test/random_port.ini \
+ -a $BUILD_DIR/etc/couchdb/local_dev.ini 1>/dev/null
+}
+
+stop() {
+ ./utils/run -d 1>/dev/null
+}
+
+restart() {
+ stop
+ start
+}
+
+abort() {
+ trap - 0
+ stop
+ exit 2
+}
+
+process_response() {
+ while read data
+ do
+ if [ $data = 'restart' ];
+ then
+ restart
+ else
+ echo "$data"
+ fi
+ done
+}
+
+run() {
+ # start the tests
+ echo -n "$1 ... "
+ $COUCHJS -H -u $COUCH_URI_FILE \
+ $SCRIPT_DIR/json2.js \
+ $SCRIPT_DIR/sha1.js \
+ $SCRIPT_DIR/oauth.js \
+ $SCRIPT_DIR/couch.js \
+ $SCRIPT_DIR/replicator_db_inc.js \
+ $SCRIPT_DIR/couch_test_runner.js \
+ $JS_TEST_DIR/couch_http.js \
+ $JS_TEST_DIR/test_setup.js \
+ $1 \
+ $JS_TEST_DIR/cli_runner.js | process_response
+
+ if [ -z $RESULT ]; then
+ RESULT=$?
+ elif [ "$?" -eq 1 ]; then
+ RESULT=$?
+ fi
+
+}
+
+# start CouchDB
+if [ -z $COUCHDB_NO_START ]; then
+ $MAKE dev
+ start
+fi
+
+echo "Running javascript tests ..."
+
if [ "$#" -eq 0 ];
then
- TEST_SRC="$SCRIPT_DIR/test/*.js"
+ COUNTER=1
+ FILES=($SCRIPT_DIR/test/*.js)
+ for TEST_SRC in "${FILES[@]}"
+ do
+ echo -n "$COUNTER/${#FILES[@]} "
+ let COUNTER=COUNTER+1
+ run $TEST_SRC
+ done
else
TEST_SRC="$1"
if [ ! -f $TEST_SRC ]; then
@@ -40,47 +114,10 @@ else
echo "file $1 does not exist"
exit 1
fi
+ run $TEST_SRC
fi
fi
fi
-# stop CouchDB on exit from various signals
-abort() {
- trap - 0
- ./utils/run -d
- exit 2
-}
-
-# start CouchDB
-if [ -z $COUCHDB_NO_START ]; then
- $MAKE dev
- trap 'abort' EXIT INT
- ./utils/run -b -r 1 -n \
- -a $BUILD_DIR/etc/couchdb/default_dev.ini \
- -a $SRC_DIR/test/random_port.ini \
- -a $BUILD_DIR/etc/couchdb/local_dev.ini
- sleep 1 # give it a sec
-fi
-
-# start the tests
-$COUCHJS -H -u $COUCH_URI_FILE \
- $SCRIPT_DIR/json2.js \
- $SCRIPT_DIR/sha1.js \
- $SCRIPT_DIR/oauth.js \
- $SCRIPT_DIR/couch.js \
- $SCRIPT_DIR/couch_test_runner.js \
- $SCRIPT_DIR/couch_tests.js \
- $SCRIPT_DIR/replicator_db_inc.js \
- $TEST_SRC \
- $JS_TEST_DIR/couch_http.js \
- $JS_TEST_DIR/cli_runner.js
-
-RESULT=$?
-
-if [ -z $COUCHDB_NO_START ]; then
- # stop CouchDB
- ./utils/run -d
- trap - 0
-fi
-
+trap - 0
exit $RESULT
[4/6] git commit: updated refs/heads/master to 9dfddaa
Posted by we...@apache.org.
Remove setup functions from test runner, only allow a single test to be run at a time.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0ada3431
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0ada3431
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0ada3431
Branch: refs/heads/master
Commit: 0ada3431ac286298c06f103f5eebc978b7173a2b
Parents: df011f7
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:43:46 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:43:46 2013 -0700
----------------------------------------------------------------------
test/javascript/cli_runner.js | 84 ++++++++++--------------------------
1 files changed, 23 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0ada3431/test/javascript/cli_runner.js
----------------------------------------------------------------------
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js
index fcb4633..e8ebd2e 100644
--- a/test/javascript/cli_runner.js
+++ b/test/javascript/cli_runner.js
@@ -9,77 +9,39 @@
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
+//
-var console = {
- log: function(arg) {
- var msg = (arg.toString()).replace(/\n/g, "\n ");
- print(msg, true);
- }
-};
+/*
+ * Futon test suite was designed to be able to run all tests populated into
+ * couchTests. Here we should only be loading one test, so we'll pop the first
+ * test off the list and run the test. If more than one item is loaded in the
+ * test object, return an error.
+ */
+function runTest() {
+ var count = 0;
+ var start = new Date().getTime();
-var fmtStack = function(stack) {
- if(!stack) {
- console.log("No stack information");
- return;
- }
- console.log("Trace back (most recent call first):\n");
- var re = new RegExp("(.*?)@([^:]*):(.*)$");
- var lines = stack.split("\n");
- for(var i = 0; i < lines.length; i++) {
- var line = lines[i];
- if(!line.length) continue;
- var match = re.exec(line);
- if(!match) continue
- var source = match[1].substr(0, 70);
- var file = match[2];
- var lnum = match[3];
- while(lnum.length < 3) lnum = " " + lnum;
- console.log(" " + lnum + ": " + file);
- console.log(" " + source);
+ for(var name in couchTests) {
+ count++;
}
-}
-
-function T(arg1, arg2) {
- if(!arg1) {
- var result = (arg2 ? arg2 : arg1);
- throw((result instanceof Error ? result : Error(result)));
+ if (count !== 1) {
+ console.log('Only one test per file is allowed.');
+ quit(1);
}
-}
-function runTestConsole(num, name, func) {
- var passed = false;
try {
- func();
- passed = true;
- print("ok " + num + " " + name);
+ // Add artificial wait for each test of 1 sec
+ while (new Date().getTime() < start + 1200);
+ couchTests[name]();
+ print('OK');
} catch(e) {
- print("not ok " + num + " " + name);
- console.log("Reason: " + e.message);
+ console.log("FAIL\nReason: " + e.message);
fmtStack(e.stack);
+ quit(1);
}
- return passed;
}
-function runAllTestsConsole() {
- var numTests = 0;
- var numPassed = 0;
- for(var t in couchTests) { numTests += 1; }
- print("1.." + numTests);
- var testId = 0;
- for(var t in couchTests) {
- testId += 1;
- if(runTestConsole(testId, t, couchTests[t])) {
- numPassed++;
- }
- }
- if(numPassed != numTests) {
- console.log("Test failures: " + (numTests - numPassed));
- quit(1);
- } else {
- console.log("All tests passed");
- }
-};
+waitForSuccess(CouchDB.isRunning, 'isRunning');
-waitForSuccess(CouchDB.getVersion);
-runAllTestsConsole();
+runTest();
[2/6] git commit: updated refs/heads/master to 9dfddaa
Posted by we...@apache.org.
Creating existing database causes test to fail. Allowing config PUT to create replicator db.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/abcaec9a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/abcaec9a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/abcaec9a
Branch: refs/heads/master
Commit: abcaec9a083961cca3df4943366dd39027afada8
Parents: c43b84d
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:40:42 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:40:42 2013 -0700
----------------------------------------------------------------------
share/www/script/test/replicator_db_survives.js | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/abcaec9a/share/www/script/test/replicator_db_survives.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/replicator_db_survives.js b/share/www/script/test/replicator_db_survives.js
index dcaa101..38273ca 100644
--- a/share/www/script/test/replicator_db_survives.js
+++ b/share/www/script/test/replicator_db_survives.js
@@ -38,8 +38,6 @@ couchTests.replicator_db_survives = function(debug) {
});
T(xhr.status === 200);
- repDb.createDb(); // the config put above should create this db
-
populate_db(dbA, docs1);
populate_db(dbB, []);
@@ -125,4 +123,4 @@ couchTests.replicator_db_survives = function(debug) {
dbA.deleteDb();
dbB.deleteDb();
usersDb.deleteDb();
-}
\ No newline at end of file
+}
[3/6] git commit: updated refs/heads/master to 9dfddaa
Posted by we...@apache.org.
PUT call to database that is not guaranted to exist.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/df011f70
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/df011f70
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/df011f70
Branch: refs/heads/master
Commit: df011f70d4981dc3272e3547b18b7e239525cef7
Parents: abcaec9
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:41:40 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:41:40 2013 -0700
----------------------------------------------------------------------
share/www/script/test/rev_stemming.js | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/df011f70/share/www/script/test/rev_stemming.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/rev_stemming.js b/share/www/script/test/rev_stemming.js
index 3e36f96..954da79 100644
--- a/share/www/script/test/rev_stemming.js
+++ b/share/www/script/test/rev_stemming.js
@@ -11,6 +11,9 @@
// the License.
couchTests.rev_stemming = function(debug) {
+ var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
+ db.deleteDb();
+ db.createDb();
var db = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();