summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2013-03-12 15:23:07 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2013-03-20 06:02:57 -0500
commit86ba6dbe513875df50f7e3e35cbd5975c38307ed (patch)
tree3a094270e0df3178afc9c336855b1d287612b018 /share
parent91b5d7033f6c8472b6d44f5c7e3e34bf5212a45d (diff)
downloadcouchdb-86ba6dbe513875df50f7e3e35cbd5975c38307ed.tar.gz
Fix core etap tests
Diffstat (limited to 'share')
-rw-r--r--share/www/script/test/oauth.js3
-rw-r--r--share/www/script/test/proxyauth.js7
-rw-r--r--share/www/script/test/replication.js20
-rw-r--r--share/www/script/test/replicator_db.js11
-rw-r--r--share/www/script/test/view_compaction.js26
-rw-r--r--share/www/script/test/view_include_docs.js2
-rw-r--r--share/www/script/test/view_update_seq.js10
7 files changed, 51 insertions, 28 deletions
diff --git a/share/www/script/test/oauth.js b/share/www/script/test/oauth.js
index 89d377944..96293f0a4 100644
--- a/share/www/script/test/oauth.js
+++ b/share/www/script/test/oauth.js
@@ -23,12 +23,14 @@ couchTests.oauth = function(debug) {
var dbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
var dbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"});
var dbC = new CouchDB("test_suite_db_c", {"X-Couch-Full-Commit":"false"});
+ var dbD = new CouchDB("test_suite_users", {"X-Couch-Full-Commit":"false"});
dbA.deleteDb();
dbA.createDb();
dbB.deleteDb();
dbB.createDb();
dbC.deleteDb();
dbC.createDb();
+ dbD.deleteDb();
// Simple secret key generator
function generateSecret(length) {
@@ -124,7 +126,6 @@ couchTests.oauth = function(debug) {
"X-Couch-Full-Commit":"false",
"Authorization": adminBasicAuthHeaderValue()
});
- usersDb.deleteDb();
// Create a user
var jasonUserDoc = CouchDB.prepareUserDoc({
diff --git a/share/www/script/test/proxyauth.js b/share/www/script/test/proxyauth.js
index 016cec5ea..1677a6636 100644
--- a/share/www/script/test/proxyauth.js
+++ b/share/www/script/test/proxyauth.js
@@ -19,7 +19,9 @@ couchTests.proxyauth = function(debug) {
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
if (debug) debugger;
-
+
+ usersDb.deleteDb();
+
// Simple secret key generator
function generateSecret(length) {
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -33,7 +35,6 @@ couchTests.proxyauth = function(debug) {
var secret = generateSecret(64);
function TestFun() {
- usersDb.deleteDb();
db.deleteDb();
db.createDb();
@@ -126,4 +127,4 @@ couchTests.proxyauth = function(debug) {
TestFun
);
-}; \ No newline at end of file
+};
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index fd60dd41b..7e4ecc1b3 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -1359,17 +1359,24 @@ couchTests.replication = function(debug) {
TEquals(true, repResult.ok);
TEquals('string', typeof repResult._local_id);
- var xhr = CouchDB.request("GET", "/_active_tasks");
- var tasks = JSON.parse(xhr.responseText);
-
TEquals(true, sourceDb.compact().ok);
while (sourceDb.info().compact_running) {};
TEquals(true, sourceDb.save(makeDocs(30, 31)[0]).ok);
xhr = CouchDB.request("GET", "/_active_tasks");
- var tasksAfter = JSON.parse(xhr.responseText);
- TEquals(tasks.length, tasksAfter.length);
+ var xhr = CouchDB.request("GET", "/_active_tasks");
+ var tasks = JSON.parse(xhr.responseText);
+
+ var found_task = false;
+ for(var i = 0; i < tasks.length; i++) {
+ if(tasks[i].replication_id == repResult._local_id) {
+ found_task = true;
+ break;
+ }
+ }
+ TEquals(true, found_task);
+
waitForSeq(sourceDb, targetDb);
T(sourceDb.open("30") !== null);
@@ -1695,6 +1702,9 @@ couchTests.replication = function(debug) {
TEquals(true, repResult.ok);
TEquals('string', typeof repResult._local_id);
+ // Race conditions are awesome
+ wait(500);
+
xhr = CouchDB.request("GET", "/_active_tasks");
tasks = JSON.parse(xhr.responseText);
diff --git a/share/www/script/test/replicator_db.js b/share/www/script/test/replicator_db.js
index edc85f49f..230acd500 100644
--- a/share/www/script/test/replicator_db.js
+++ b/share/www/script/test/replicator_db.js
@@ -240,6 +240,8 @@ couchTests.replicator_db = function(debug) {
T(copy !== null);
T(copy.value === 1001);
+ wait(250);
+
var repDoc1 = repDb.open(repDoc._id);
T(repDoc1 !== null);
T(repDoc1.source === repDoc.source);
@@ -276,6 +278,8 @@ couchTests.replicator_db = function(debug) {
// stop replication by deleting the replication document
T(repDb.deleteDoc(repDoc1).ok);
+ wait(200);
+
// add another doc to source, it will NOT be replicated to target
var docY = {
_id: "foo666",
@@ -498,6 +502,8 @@ couchTests.replicator_db = function(debug) {
T(copy.value === doc.value);
}
+ wait(250);
+
repDoc1 = repDb.open("foo_dup_cont_rep_doc_1");
T(repDoc1 !== null);
T(repDoc1._replication_state === "triggered");
@@ -542,6 +548,8 @@ couchTests.replicator_db = function(debug) {
// deleting the 1st replication document stops the replication
T(repDb.deleteDoc(repDoc1).ok);
+ wait(wait_rep_doc); //how to remove wait?
+
var newDoc3 = {
_id: "foo1983",
value: 1983
@@ -655,6 +663,7 @@ couchTests.replicator_db = function(debug) {
"GET", "/_config/replicator/db").responseText;
repDb.deleteDb();
+ repDb.createDb();
var xhr = CouchDB.request("PUT", "/_config/replicator/db", {
body : JSON.stringify(repDb.name),
@@ -807,6 +816,8 @@ couchTests.replicator_db = function(debug) {
TEquals("joe", CouchDB.session().userCtx.name);
TEquals(-1, CouchDB.session().userCtx.roles.indexOf("_admin"));
+ wait(500);
+
var repDoc = {
_id: "foo_rep",
source: CouchDB.protocol + CouchDB.host + "/" + dbA.name,
diff --git a/share/www/script/test/view_compaction.js b/share/www/script/test/view_compaction.js
index 151ce932e..35d627696 100644
--- a/share/www/script/test/view_compaction.js
+++ b/share/www/script/test/view_compaction.js
@@ -27,7 +27,7 @@ couchTests.view_compaction = function(debug) {
map: "function(doc) { emit(doc._id, doc.value) }"
},
view2: {
- map: "function(doc) { emit(doc._id, doc.value); }",
+ map: "function(doc) { if (typeof(doc.integer) === 'number') {emit(doc._id, doc.integer);} }",
reduce: "function(keys, values, rereduce) { return sum(values); }"
}
}
@@ -38,13 +38,13 @@ couchTests.view_compaction = function(debug) {
db.bulkSave(docs);
var resp = db.view('foo/view1', {});
- T(resp.rows.length === 10000);
+ TEquals(10000, resp.rows.length);
resp = db.view('foo/view2', {});
- T(resp.rows.length === 1);
+ TEquals(1, resp.rows.length);
resp = db.designInfo("_design/foo");
- T(resp.view_index.update_seq === 10001);
+ TEquals(10001, resp.view_index.update_seq);
// update docs
@@ -55,13 +55,13 @@ couchTests.view_compaction = function(debug) {
resp = db.view('foo/view1', {});
- T(resp.rows.length === 10000);
+ TEquals(10000, resp.rows.length);
resp = db.view('foo/view2', {});
- T(resp.rows.length === 1);
+ TEquals(1, resp.rows.length);
resp = db.designInfo("_design/foo");
- T(resp.view_index.update_seq === 20001);
+ TEquals(20001, resp.view_index.update_seq);
// update docs again...
@@ -72,13 +72,13 @@ couchTests.view_compaction = function(debug) {
resp = db.view('foo/view1', {});
- T(resp.rows.length === 10000);
+ TEquals(10000, resp.rows.length);
resp = db.view('foo/view2', {});
- T(resp.rows.length === 1);
+ TEquals(1, resp.rows.length);
resp = db.designInfo("_design/foo");
- T(resp.view_index.update_seq === 30001);
+ TEquals(30001, resp.view_index.update_seq);
var disk_size_before_compact = resp.view_index.disk_size;
var data_size_before_compact = resp.view_index.data_size;
@@ -97,13 +97,13 @@ couchTests.view_compaction = function(debug) {
resp = db.view('foo/view1', {});
- T(resp.rows.length === 10000);
+ TEquals(10000, resp.rows.length);
resp = db.view('foo/view2', {});
- T(resp.rows.length === 1);
+ TEquals(1, resp.rows.length);
resp = db.designInfo("_design/foo");
- T(resp.view_index.update_seq === 30001);
+ TEquals(30001, resp.view_index.update_seq);
T(resp.view_index.disk_size < disk_size_before_compact);
TEquals("number", typeof resp.view_index.data_size, "data size is a number");
T(resp.view_index.data_size < resp.view_index.disk_size, "data size < file size");
diff --git a/share/www/script/test/view_include_docs.js b/share/www/script/test/view_include_docs.js
index 944c91034..dab79b824 100644
--- a/share/www/script/test/view_include_docs.js
+++ b/share/www/script/test/view_include_docs.js
@@ -33,7 +33,7 @@ couchTests.view_include_docs = function(debug) {
map: "function(doc) {if(doc.link_id) { var value = {'_id':doc.link_id}; if (doc.link_rev) {value._rev = doc.link_rev}; emit(doc._id, value);}};"
},
summate: {
- map:"function (doc) {emit(doc.integer, doc.integer)};",
+ map:"function (doc) { if (typeof doc.integer === 'number') {emit(doc.integer, doc.integer)};}",
reduce:"function (keys, values) { return sum(values); };"
}
}
diff --git a/share/www/script/test/view_update_seq.js b/share/www/script/test/view_update_seq.js
index 69b8c42df..df92b11d6 100644
--- a/share/www/script/test/view_update_seq.js
+++ b/share/www/script/test/view_update_seq.js
@@ -31,7 +31,7 @@ couchTests.view_update_seq = function(debug) {
map: "function(doc) { emit(doc.integer, doc.string) }"
},
summate: {
- map:"function (doc) {emit(doc.integer, doc.integer)};",
+ map:"function (doc) { if (typeof doc.integer === 'number') { emit(doc.integer, doc.integer)}; }",
reduce:"function (keys, values) { return sum(values); };"
}
}
@@ -68,12 +68,12 @@ couchTests.view_update_seq = function(debug) {
T(resp.rows.length == 1);
T(resp.update_seq == 101);
- db.save({"id":"0"});
+ db.save({"id":"0", "integer": 1});
resp = db.view('test/all_docs', {limit: 1,stale: "ok", update_seq:true});
T(resp.rows.length == 1);
T(resp.update_seq == 101);
- db.save({"id":"00"});
+ db.save({"id":"00", "integer": 2});
resp = db.view('test/all_docs',
{limit: 1, stale: "update_after", update_seq: true});
T(resp.rows.length == 1);
@@ -100,7 +100,7 @@ couchTests.view_update_seq = function(debug) {
resp = db.view('test/all_docs',{update_seq:true},["0","1"]);
T(resp.update_seq == 103);
- resp = db.view('test/summate',{group:true, update_seq:true},["0","1"]);
- T(resp.update_seq == 103);
+ resp = db.view('test/summate',{group:true, update_seq:true},[0,1]);
+ TEquals(103, resp.update_seq);
};