Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 24127 invoked from network); 2 Jun 2010 12:25:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 12:25:38 -0000 Received: (qmail 22021 invoked by uid 500); 2 Jun 2010 12:25:38 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 21985 invoked by uid 500); 2 Jun 2010 12:25:38 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 21978 invoked by uid 99); 2 Jun 2010 12:25:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 12:25:38 +0000 X-ASF-Spam-Status: No, hits=-1679.6 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 12:25:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 59AA52388A3B; Wed, 2 Jun 2010 12:25:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r950533 - in /couchdb/branches/0.11.x/share/www/script/test: changes.js oauth.js Date: Wed, 02 Jun 2010 12:25:17 -0000 To: commits@couchdb.apache.org From: jan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100602122517.59AA52388A3B@eris.apache.org> Author: jan Date: Wed Jun 2 12:25:16 2010 New Revision: 950533 URL: http://svn.apache.org/viewvc?rev=950533&view=rev Log: Merge r931297 from trunk: use waitForSuccess to timeout changes requests that never succeed Modified: couchdb/branches/0.11.x/share/www/script/test/changes.js couchdb/branches/0.11.x/share/www/script/test/oauth.js Modified: couchdb/branches/0.11.x/share/www/script/test/changes.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/changes.js?rev=950533&r1=950532&r2=950533&view=diff ============================================================================== --- couchdb/branches/0.11.x/share/www/script/test/changes.js (original) +++ couchdb/branches/0.11.x/share/www/script/test/changes.js Wed Jun 2 12:25:16 2010 @@ -82,15 +82,12 @@ couchTests.changes = function(debug) { var docBar = {_id:"bar", bar:1}; db.save(docBar); - while(true) { - var lines = xhr.responseText.split("\n"); - try { - var change1 = JSON.parse(lines[0]); - var change2 = JSON.parse(lines[1]); - break; - } catch (e) {} - db.info() // sync http req allow async req to happen - } + var lines, change1, change2; + waitForSuccess(function() { + lines = xhr.responseText.split("\n"); + change1 = JSON.parse(lines[0]); + change2 = JSON.parse(lines[1]); + }, "bar-only"); T(change1.seq == 1) T(change1.id == "foo") @@ -103,15 +100,12 @@ couchTests.changes = function(debug) { var docBaz = {_id:"baz", baz:1}; db.save(docBaz); - while(true) { - var lines = xhr.responseText.split("\n"); - try { - var change3 = JSON.parse(lines[2]); - break; - } catch (e) {} - db.info() // sync http req allow async req to happen - - } + var change3; + waitForSuccess(function() { + lines = xhr.responseText.split("\n"); + change3 = JSON.parse(lines[2]); + }); + T(change3.seq == 3); T(change3.id == "baz"); T(change3.changes[0].rev == docBaz._rev); @@ -123,12 +117,13 @@ couchTests.changes = function(debug) { xhr.open("GET", "/test_suite_db/_changes?feed=continuous&heartbeat=10", true); xhr.send(""); - str = xhr.responseText; - while(str.charAt(str.length - 1) != "\n" || - str.charAt(str.length - 2) != "\n") { - db.info() // sync http req allow async req to happen - str = xhr.responseText; - } + var str; + waitForSuccess(function() { + str = xhr.responseText; + if (str.charAt(str.length - 1) != "\n" || str.charAt(str.length - 2) != "\n") { + throw("keep waiting"); + } + }, "heartbeat"); T(str.charAt(str.length - 1) == "\n") T(str.charAt(str.length - 2) == "\n") @@ -140,15 +135,12 @@ couchTests.changes = function(debug) { xhr.open("GET", "/test_suite_db/_changes?feed=longpoll", true); xhr.send(""); - while(true) { - try { - var lines = xhr.responseText.split("\n"); - if(lines[5]=='"last_seq":3}') { - break; - } - } catch (e) {} - db.info(); // sync http req allow async req to happen - } + waitForSuccess(function() { + lines = xhr.responseText.split("\n"); + if (lines[5] != '"last_seq":3}') { + throw("still waiting"); + } + }, "last_seq"); xhr = CouchDB.newXhr(); @@ -167,14 +159,12 @@ couchTests.changes = function(debug) { return JSON.parse(linetrimmed); } - while(true) { - try { - var lines = xhr.responseText.split("\n"); - if(lines[3]=='"last_seq":4}') - break; - } catch (e) {} - db.info(); // sync http req allow async req to happen - } + waitForSuccess(function() { + lines = xhr.responseText.split("\n"); + if (lines[3] != '"last_seq":4}') { + throw("still waiting"); + } + }, "change_lines"); var change = parse_changes_line(lines[1]); T(change.seq == 4); @@ -235,13 +225,9 @@ couchTests.changes = function(debug) { db.save({"_id":"falsy", "bop" : ""}); // empty string is falsy db.save({"_id":"bingo","bop" : "bingo"}); - while(true) { - try { - var resp = JSON.parse(xhr.responseText); - break; - } catch (e) {} - db.info() // sync http req allow async req to happen - } + waitForSuccess(function() { + resp = JSON.parse(xhr.responseText); + }, "longpoll-since"); T(resp.last_seq == 9); T(resp.results && resp.results.length > 0 && resp.results[0]["id"] == "bingo", "filter the correct update"); @@ -252,14 +238,10 @@ couchTests.changes = function(debug) { xhr.send(""); db.save({"_id":"rusty", "bop" : "plankton"}); - while(true) { - try { - var lines = xhr.responseText.split("\n"); - JSON.parse(lines[3]) - break; - } catch (e) {} - db.info() // sync http req allow async req to happen - } + waitForSuccess(function() { + lines = xhr.responseText.split("\n"); + JSON.parse(lines[3]); + }, "continuous-timeout"); T(JSON.parse(lines[1]).id == "bingo", lines[1]); T(JSON.parse(lines[2]).id == "rusty", lines[2]); Modified: couchdb/branches/0.11.x/share/www/script/test/oauth.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/oauth.js?rev=950533&r1=950532&r2=950533&view=diff ============================================================================== --- couchdb/branches/0.11.x/share/www/script/test/oauth.js (original) +++ couchdb/branches/0.11.x/share/www/script/test/oauth.js Wed Jun 2 12:25:16 2010 @@ -94,17 +94,18 @@ couchTests.oauth = function(debug) { headers: {"X-Couch-Persist": "false"}, body: JSON.stringify(testadminPassword) }); - while (true) { - //loop until the couch server has processed the password - var xhr = CouchDB.request("GET", "http://" + host + "/_config/admins/testadmin?foo="+i,{ - headers: { - "Authorization": adminBasicAuthHeaderValue() - }}) - if (xhr.responseText.indexOf("\"-hashed-") == 0) { - break; - } - console.log("foo:" + xhr.responseText) - } + var i = 0; + waitForSuccess(function() { + //loop until the couch server has processed the password + i += 1; + var xhr = CouchDB.request("GET", "http://" + host + "/_config/admins/testadmin?foo="+i,{ + headers: { + "Authorization": adminBasicAuthHeaderValue() + }}); + if (xhr.responseText.indexOf("\"-hashed-") != 0) { + throw("still waiting"); + } + }, "wait-for-admin"); CouchDB.newUuids(2); // so we have one to make the salt