couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r885329 - in /couchdb/trunk: share/www/script/test/changes.js src/couchdb/couch_httpd_db.erl
Date Mon, 30 Nov 2009 03:59:03 GMT
Author: jchris
Date: Mon Nov 30 03:59:02 2009
New Revision: 885329

URL: http://svn.apache.org/viewvc?rev=885329&view=rev
Log:
work on COUCHDB-582, fixes issues with filtered longpoll requests closing early

Modified:
    couchdb/trunk/share/www/script/test/changes.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/test/changes.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/changes.js?rev=885329&r1=885328&r2=885329&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/changes.js (original)
+++ couchdb/trunk/share/www/script/test/changes.js Mon Nov 30 03:59:02 2009
@@ -26,10 +26,10 @@
   var resp = JSON.parse(req.responseText);
 
   T(resp.results.length == 0 && resp.last_seq==0, "empty db")
-
   var docFoo = {_id:"foo", bar:1};
   T(db.save(docFoo).ok);
-
+  T(db.ensureFullCommit().ok);
+  
   req = CouchDB.request("GET", "/test_suite_db/_changes");
   var resp = JSON.parse(req.responseText);
 
@@ -186,6 +186,7 @@
   T(resp.results.length == 0); 
 
   db.save({"bop" : "foom"});
+  db.save({"bop" : false});
   
   var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/bop");
   var resp = JSON.parse(req.responseText);
@@ -199,6 +200,27 @@
   resp = JSON.parse(req.responseText);
   T(resp.results.length == 1);
 
+  if (!is_safari && xhr) { // full test requires parallel connections
+    // filter with longpoll
+    // longpoll filters full history when run without a since seq
+    xhr = CouchDB.newXhr();
+    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&filter=changes_filter/bop",
true);
+    xhr.send("");
+    sleep(100);
+    var resp = JSON.parse(xhr.responseText);
+    T(resp.last_seq == 7);
+    // longpoll waits until a matching change before returning
+    xhr = CouchDB.newXhr();
+    xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&since=7&filter=changes_filter/bop",
true);
+    xhr.send("");
+    db.save({"bop" : ""}); // empty string is falsy
+    var id = db.save({"bop" : "bingo"}).id;
+    sleep(100);
+    var resp = JSON.parse(xhr.responseText);
+    T(resp.last_seq == 9);
+    T(resp.results && resp.results.length > 0 && resp.results[0]["id"]
== id, "filter the correct update");
+  }
+
   // error conditions
 
   // non-existing design doc
@@ -224,7 +246,7 @@
   var req = CouchDB.request("GET", 
     "/test_suite_db/_changes?filter=changes_filter/bop&style=all_docs");
   var resp = JSON.parse(req.responseText);
-  TEquals(1, resp.results.length, "should return one result row");
+  TEquals(2, resp.results.length, "should return two rows");
   
   // test for userCtx
   run_on_modified_server(
@@ -248,6 +270,7 @@
 
       var docResp = db.save({"user" : "Chris Anderson"});
       T(docResp.ok);
+      T(db.ensureFullCommit().ok);
       req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/userCtx",
authOpts);
       resp = JSON.parse(req.responseText);
       T(resp.results.length == 1, "userCtx");

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=885329&r1=885328&r2=885329&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Mon Nov 30 03:59:02 2009
@@ -159,7 +159,7 @@
         Prepend, ResponseType, Limit, Filter, End),
     couch_db:close(Db),
     if
-    EndSeq > StartSeq, ResponseType == "longpoll" ->
+    Limit > NewLimit, ResponseType == "longpoll" ->
         end_sending_changes(Resp, EndSeq, ResponseType);
     true ->
         case wait_db_updated(Timeout, TimeoutFun) of



Mime
View raw message