diff options
author | Robert Newson <rnewson@apache.org> | 2019-11-14 11:54:13 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2019-11-14 11:54:13 +0000 |
commit | fff26df4f32925c69dbcde0bc522a97f6761cb7e (patch) | |
tree | 731d74b15b69690b00c3830581b0990f56fcfd3d | |
parent | ec23c342b722db289c3dd54fc61221ae26dec7b5 (diff) | |
download | couchdb-fff26df4f32925c69dbcde0bc522a97f6761cb7e.tar.gz |
restore tests removed in 0a85b75ee150
-rw-r--r-- | test/javascript/tests/design_docs.js | 32 | ||||
-rw-r--r-- | test/javascript/tests/view_update_seq.js | 2 |
2 files changed, 32 insertions, 2 deletions
diff --git a/test/javascript/tests/design_docs.js b/test/javascript/tests/design_docs.js index b23075bea..780fc1354 100644 --- a/test/javascript/tests/design_docs.js +++ b/test/javascript/tests/design_docs.js @@ -252,7 +252,9 @@ couchTests.design_docs = function(debug) { db.bulkSave(makeDocs(1, numDocs + 1)); T(db.ensureFullCommit().ok); - // test that we get correct design doc info back. + // test that we get correct design doc info back, + // and also that GET /db/_design/test/_info + // hasn't triggered an update of the views db.view("test/summate", {stale: "ok"}); // make sure view group's open for (var i = 0; i < 2; i++) { var dinfo = db.designInfo("_design/test"); @@ -261,6 +263,13 @@ couchTests.design_docs = function(debug) { TEquals(prev_view_size, vinfo.sizes.file, "view group disk size didn't change"); TEquals(false, vinfo.compact_running); TEquals(prev_view_sig, vinfo.signature, 'ddoc sig'); + // wait some time (there were issues where an update + // of the views had been triggered in the background) + var start = new Date().getTime(); + while (new Date().getTime() < start + 2000); + TEquals(0, db.view("test/all_docs_twice", {stale: "ok"}).total_rows, 'view info'); + TEquals(0, db.view("test/single_doc", {stale: "ok"}).total_rows, 'view info'); + TEquals(0, db.view("test/summate", {stale: "ok"}).rows.length, 'view info'); T(db.ensureFullCommit().ok); // restartServer(); }; @@ -274,6 +283,27 @@ couchTests.design_docs = function(debug) { var start = new Date().getTime(); while (new Date().getTime() < start + 2000); + // test that POST /db/_view_cleanup + // doesn't trigger an update of the views + var len1 = db.view("test/all_docs_twice", {stale: "ok"}).total_rows; + var len2 = db.view("test/single_doc", {stale: "ok"}).total_rows; + var len3 = db.view("test/summate", {stale: "ok"}).rows.length; + for (i = 0; i < 2; i++) { + T(db.viewCleanup().ok); + // wait some time (there were issues where an update + // of the views had been triggered in the background) + start = new Date().getTime(); + while (new Date().getTime() < start + 2000); + TEquals(len1, db.view("test/all_docs_twice", {stale: "ok"}).total_rows, 'view cleanup'); + TEquals(len2, db.view("test/single_doc", {stale: "ok"}).total_rows, 'view cleanup'); + TEquals(len3, db.view("test/summate", {stale: "ok"}).rows.length, 'view cleanup'); + T(db.ensureFullCommit().ok); + // restartServer(); + // we'll test whether the view group stays closed + // and the views stay uninitialized (they should!) + len1 = len2 = len3 = 0; + }; + // test commonjs in map functions resp = db.view("test/commonjs", {limit:1}); T(resp.rows[0].value == 'ok'); diff --git a/test/javascript/tests/view_update_seq.js b/test/javascript/tests/view_update_seq.js index eaba4042e..a74b08d9f 100644 --- a/test/javascript/tests/view_update_seq.js +++ b/test/javascript/tests/view_update_seq.js @@ -86,7 +86,7 @@ couchTests.view_update_seq = function(debug) { resp = db.view('test/all_docs', {limit: 1, stale: "update_after", update_seq: true}); T(resp.rows.length == 1); - T(seqInt(resp.update_seq) == 101 || seqInt(resp.update_seq) == 102); + TEquals(101, seqInt(resp.update_seq)); // wait 5 seconds for the next assertions to pass in very slow machines var t0 = new Date(), t1; |