From e5acebced31345e47bca2571a7de9432d4f9855b Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Sun, 27 Mar 2011 19:20:59 +0000 Subject: Backport fix for COUCHDB-1093 (revision 1086007) Fix for crashes in continuous and filtered changes feeds Fixes COUCHDB-1093. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1086009 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/replication.js | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'share/www') diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js index 5acff4ab..7f92891e 100644 --- a/share/www/script/test/replication.js +++ b/share/www/script/test/replication.js @@ -724,6 +724,67 @@ couchTests.replication = function(debug) { run_on_modified_server(server_config, test_fun); + // COUCHDB-1093 - filtered and continuous _changes feed dies when the + // database is compacted + dbA = new CouchDB("test_suite_db_a"); + dbB = new CouchDB("test_suite_db_b"); + + dbA.deleteDb(); + dbA.createDb(); + dbB.deleteDb(); + dbB.createDb(); + + var docs = makeDocs(1, 10); + docs.push({ + _id: "_design/foo", + language: "javascript", + filters: { + myfilter: (function(doc, req) { return true; }).toString() + } + }); + dbA.bulkSave(docs).ok; + + var repResult = CouchDB.replicate( + CouchDB.protocol + host + "/" + dbA.name, + dbB.name, + { + body: { + continuous: true, + filter: "foo/myfilter" + } + } + ); + 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, dbA.compact().ok); + while (dbA.info().compact_running) {}; + + TEquals(true, dbA.save(makeDocs(30, 31)[0]).ok); + xhr = CouchDB.request("GET", "/_active_tasks"); + + var tasksAfter = JSON.parse(xhr.responseText); + TEquals(tasks.length, tasksAfter.length); + T(dbB.open("30") !== null); + + repResult = CouchDB.replicate( + CouchDB.protocol + host + "/" + dbA.name, + dbB.name, + { + body: { + continuous: true, + filter: "foo/myfilter", + cancel: true + } + } + ); + TEquals(true, repResult.ok); + TEquals('string', typeof repResult._local_id); + + // cleanup dbA.deleteDb(); dbB.deleteDb(); -- cgit v1.2.3