summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2020-01-04 16:48:55 +0000
committerJan Lehnardt <jan@apache.org>2020-01-04 17:48:55 +0100
commit3f1f711b451d0fb2c841cc845b1937a573224caf (patch)
tree46b8abc378fd53b15eef08d161c45178792b08c2
parentd5568d1bbbed134091e34a1fa292f1ae2b361adf (diff)
downloadcouchdb-3f1f711b451d0fb2c841cc845b1937a573224caf.tar.gz
Autoupdate false test (#2311)
* restore tests removed in 0a85b75ee150 * disable autoupdate when testing for stale indexes
-rw-r--r--test/javascript/tests/design_docs.js32
-rw-r--r--test/javascript/tests/view_update_seq.js3
2 files changed, 33 insertions, 2 deletions
diff --git a/test/javascript/tests/design_docs.js b/test/javascript/tests/design_docs.js
index f06efc8eb..e28cb2e83 100644
--- a/test/javascript/tests/design_docs.js
+++ b/test/javascript/tests/design_docs.js
@@ -253,7 +253,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");
@@ -262,6 +264,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();
};
@@ -275,6 +284,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..c14453f05 100644
--- a/test/javascript/tests/view_update_seq.js
+++ b/test/javascript/tests/view_update_seq.js
@@ -26,6 +26,7 @@ couchTests.view_update_seq = function(debug) {
var designDoc = {
_id:"_design/test",
language: "javascript",
+ autoupdate: false,
views: {
all_docs: {
map: "function(doc) { emit(doc.integer, doc.string) }"
@@ -86,7 +87,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;