You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ra...@apache.org on 2012/01/27 02:37:12 UTC

[2/7] git commit: COUCHDB-1338 - run js tests with port=0

COUCHDB-1338 - run js tests with port=0

When the JS tests POST to /_restart, the server comes back up on a
different port. To work around this, add a getter property for the
CouchHTTP.prototype.base_url property, using a reserved slot on the
object to store the value.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926

Branch: refs/heads/master
Commit: d20e792617db738dd5ad0e046ae847cd740f586f
Parents: 257eb52
Author: Randall Leeds <ra...@apache.org>
Authored: Sat Jan 7 14:21:29 2012 -0800
Committer: Randall Leeds <ra...@apache.org>
Committed: Thu Jan 26 17:03:10 2012 -0800

----------------------------------------------------------------------
 src/couchdb/priv/couch_js/help.h  |    2 +
 src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
 src/couchdb/priv/couch_js/http.h  |    3 ++
 src/couchdb/priv/couch_js/sm170.c |    8 ++++
 src/couchdb/priv/couch_js/sm180.c |    8 ++++
 src/couchdb/priv/couch_js/sm185.c |    8 ++++
 src/couchdb/priv/couch_js/util.c  |    3 +-
 src/couchdb/priv/couch_js/util.h  |    2 +
 test/Makefile.am                  |    1 +
 test/etap/Makefile.am             |    1 -
 test/etap/random_port.ini         |   19 ----------
 test/etap/test_util.erl.in        |    2 +-
 test/javascript/Makefile.am       |    1 +
 test/javascript/couch_http.js     |    9 ++---
 test/javascript/run.tpl           |    9 ++++-
 test/random_port.ini              |   19 ++++++++++
 16 files changed, 125 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/help.h
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/help.h b/src/couchdb/priv/couch_js/help.h
index 4102594..b31bb8c 100644
--- a/src/couchdb/priv/couch_js/help.h
+++ b/src/couchdb/priv/couch_js/help.h
@@ -50,6 +50,8 @@ static const char USAGE_TEMPLATE[] =
     "              if package was built with cURL available)\n"
     "  -S SIZE     specify that the interpreter should set the\n"
     "              stack quota for JS contexts to SIZE bytes\n"
+    "  -u FILE     path to a .uri file containing the address\n"
+    "              (or addresses) of one or more servers\n"
     "\n"
     "Report bugs at <%s>.\n";
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/http.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/http.c b/src/couchdb/priv/couch_js/http.c
index fb54869..e8cd789 100644
--- a/src/couchdb/priv/couch_js/http.c
+++ b/src/couchdb/priv/couch_js/http.c
@@ -13,9 +13,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include <jsapi.h>
 #include "config.h"
 #include "utf8.h"
+#include "util.h"
 
 // Soft dependency on cURL bindings because they're
 // only used when running the JS tests from the
@@ -71,6 +75,12 @@ http_status(JSContext* cx, JSObject* req, jsval body)
     return -1;
 }
 
+JSBool
+http_uri(JSContext* cx, JSObject* req, couch_args* args, jsval* uri_val)
+{
+    return JS_FALSE;
+}
+
 
 #else
 #include <curl/curl.h>
@@ -342,6 +352,42 @@ http_status(JSContext* cx, JSObject* req)
     return http->last_status;
 }
 
+JSBool
+http_uri(JSContext* cx, JSObject* req, couch_args* args, jsval* uri_val)
+{
+    FILE* uri_fp = NULL;
+    JSString* uri_str;
+
+    // Default is http://localhost:5984/ when no uri file is specified
+    if (!args->uri_file) {
+        uri_str = JS_InternString(cx, "http://localhost:5984/");
+        *uri_val = STRING_TO_JSVAL(uri_str);
+        return JS_TRUE;
+    }
+
+    // Else check to see if the base url is cached in a reserved slot
+    if (JS_GetReservedSlot(cx, req, 0, uri_val) && !JSVAL_IS_VOID(*uri_val)) {
+        return JS_TRUE;
+    }
+
+    // Read the first line of the couch.uri file.
+    if(!((uri_fp = fopen(args->uri_file, "r")) &&
+         (uri_str = couch_readline(cx, uri_fp)))) {
+        JS_ReportError(cx, "Failed to read couch.uri file.");
+        goto error;
+    }
+
+    fclose(uri_fp);
+    *uri_val = STRING_TO_JSVAL(uri_str);
+    JS_SetReservedSlot(cx, req, 0, *uri_val);
+    return JS_TRUE;
+
+error:
+    if(uri_fp) fclose(uri_fp);
+    return JS_FALSE;
+}
+
+
 // Curl Helpers
 
 typedef struct {
@@ -373,6 +419,7 @@ static JSBool
 go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen)
 {
     CurlState state;
+    char* referer;
     JSString* jsbody;
     JSBool ret = JS_FALSE;
     jsval tmp;
@@ -400,7 +447,6 @@ go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen)
         curl_easy_setopt(HTTP_HANDLE, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
         curl_easy_setopt(HTTP_HANDLE, CURLOPT_ERRORBUFFER, ERRBUF);
         curl_easy_setopt(HTTP_HANDLE, CURLOPT_COOKIEFILE, "");
-        curl_easy_setopt(HTTP_HANDLE, CURLOPT_REFERER, "http://127.0.0.1:5984/");
         curl_easy_setopt(HTTP_HANDLE, CURLOPT_USERAGENT,
                                             "CouchHTTP Client - Relax");
     }
@@ -410,6 +456,18 @@ go(JSContext* cx, JSObject* obj, HTTPData* http, char* body, size_t bodylen)
         goto done;
     }
 
+    if(!JS_GetReservedSlot(cx, obj, 0, &tmp)) {
+      JS_ReportError(cx, "Failed to readreserved slot.");
+      goto done;
+    }
+
+    if(!(referer = enc_string(cx, tmp, NULL))) {
+      JS_ReportError(cx, "Failed to encode referer.");
+      goto done;
+    }
+    curl_easy_setopt(HTTP_HANDLE, CURLOPT_REFERER, referer);
+    free(referer);
+
     if(http->method < 0 || http->method > OPTIONS) {
         JS_ReportError(cx, "INTERNAL: Unknown method.");
         goto done;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/http.h
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/http.h b/src/couchdb/priv/couch_js/http.h
index 373d1e4..63d45bd 100644
--- a/src/couchdb/priv/couch_js/http.h
+++ b/src/couchdb/priv/couch_js/http.h
@@ -13,6 +13,8 @@
 #ifndef COUCH_JS_HTTP_H
 #define COUCH_JS_HTTP_H
 
+#include "util.h"
+
 void http_check_enabled();
 JSBool http_ctor(JSContext* cx, JSObject* req);
 void http_dtor(JSContext* cx, JSObject* req);
@@ -20,5 +22,6 @@ JSBool http_open(JSContext* cx, JSObject* req, jsval mth, jsval url, jsval snc);
 JSBool http_set_hdr(JSContext* cx, JSObject* req, jsval name, jsval val);
 JSBool http_send(JSContext* cx, JSObject* req, jsval body);
 int http_status(JSContext* cx, JSObject* req);
+JSBool http_uri(JSContext* cx, JSObject *req, couch_args* args, jsval* uri);
 
 #endif

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/sm170.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/sm170.c b/src/couchdb/priv/couch_js/sm170.c
index 5e136de..4a18d8f 100644
--- a/src/couchdb/priv/couch_js/sm170.c
+++ b/src/couchdb/priv/couch_js/sm170.c
@@ -114,6 +114,13 @@ req_status(JSContext* cx, JSObject* obj, jsval idval, jsval* rval)
 
 static JSBool
 base_url(JSContext *cx, JSObject* obj, jsval idval, jsval* rval)
+{
+    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
+    return http_uri(cx, obj, args, rval);
+}
+
+
+static JSBool
 evalcx(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
     JSString *str;
@@ -317,6 +324,7 @@ main(int argc, const char* argv[])
 
     JS_SetErrorReporter(cx, couch_error);
     JS_ToggleOptions(cx, JSOPTION_XML);
+    JS_SetContextPrivate(cx, args);
     
     SETUP_REQUEST(cx);
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/sm180.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/sm180.c b/src/couchdb/priv/couch_js/sm180.c
index 5b6984a..9ffd1df 100644
--- a/src/couchdb/priv/couch_js/sm180.c
+++ b/src/couchdb/priv/couch_js/sm180.c
@@ -117,6 +117,13 @@ req_status(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
 
 static JSBool
 base_url(JSContext *cx, JSObject* obj, jsid pid, jsval* vp)
+{
+    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
+    return http_uri(cx, obj, args, &JS_RVAL(cx, vp));
+}
+
+
+static JSBool
 evalcx(JSContext *cx, uintN argc, jsval* vp)
 {
     jsval* argv = JS_ARGV(cx, vp);
@@ -326,6 +333,7 @@ main(int argc, const char* argv[])
 
     JS_SetErrorReporter(cx, couch_error);
     JS_ToggleOptions(cx, JSOPTION_XML);
+    JS_SetContextPrivate(cx, args);
     
     SETUP_REQUEST(cx);
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/sm185.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/sm185.c b/src/couchdb/priv/couch_js/sm185.c
index 52a81a4..c11e885 100644
--- a/src/couchdb/priv/couch_js/sm185.c
+++ b/src/couchdb/priv/couch_js/sm185.c
@@ -135,6 +135,13 @@ req_status(JSContext* cx, JSObject* obj, jsid pid, jsval* vp)
 
 static JSBool
 base_url(JSContext *cx, JSObject* obj, jsid pid, jsval* vp)
+{
+    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
+    return http_uri(cx, obj, args, &JS_RVAL(cx, vp));
+}
+
+
+static JSBool
 evalcx(JSContext *cx, uintN argc, jsval* vp)
 {
     jsval* argv = JS_ARGV(cx, vp);
@@ -338,6 +345,7 @@ main(int argc, const char* argv[])
 
     JS_SetErrorReporter(cx, couch_error);
     JS_ToggleOptions(cx, JSOPTION_XML);
+    JS_SetContextPrivate(cx, args);
     
     SETUP_REQUEST(cx);
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/util.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/util.c b/src/couchdb/priv/couch_js/util.c
index d41d9e9..5c88402 100644
--- a/src/couchdb/priv/couch_js/util.c
+++ b/src/couchdb/priv/couch_js/util.c
@@ -94,6 +94,8 @@ couch_parse_args(int argc, const char* argv[])
                 fprintf(stderr, "Invalid stack size.\n");
                 exit(2);
             }
+        } else if(strcmp("-u", argv[i]) == 0) {
+            args->uri_file = argv[++i];
         } else if(strcmp("--", argv[i]) == 0) {
             i++;
             break;
@@ -290,4 +292,3 @@ couch_load_funcs(JSContext* cx, JSObject* obj, JSFunctionSpec* funcs)
     }
     return JS_TRUE;
 }
-

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/src/couchdb/priv/couch_js/util.h
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_js/util.h b/src/couchdb/priv/couch_js/util.h
index 1319e62..65a2a06 100644
--- a/src/couchdb/priv/couch_js/util.h
+++ b/src/couchdb/priv/couch_js/util.h
@@ -19,6 +19,8 @@ typedef struct {
     int          use_http;
     int          stack_size;
     const char** scripts;
+    const char*  uri_file;
+    JSString*    uri;
 } couch_args;
 
 couch_args* couch_parse_args(int argc, const char* argv[]);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/Makefile.am
----------------------------------------------------------------------
diff --git a/test/Makefile.am b/test/Makefile.am
index 45130a6..7c70a5a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -11,4 +11,5 @@
 ## the License.
 
 SUBDIRS = bench etap javascript view_server
+EXTRA_DIST = random_port.ini
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/etap/Makefile.am
----------------------------------------------------------------------
diff --git a/test/etap/Makefile.am b/test/etap/Makefile.am
index be85c49..b72b982 100644
--- a/test/etap/Makefile.am
+++ b/test/etap/Makefile.am
@@ -32,7 +32,6 @@ DISTCLEANFILES = temp.*
 EXTRA_DIST = \
     run.tpl \
     test_web.erl \
-    random_port.ini \
     001-load.t \
     002-icu-driver.t \
     010-file-basics.t \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/etap/random_port.ini
----------------------------------------------------------------------
diff --git a/test/etap/random_port.ini b/test/etap/random_port.ini
deleted file mode 100644
index ada3c13..0000000
--- a/test/etap/random_port.ini
+++ /dev/null
@@ -1,19 +0,0 @@
-; Licensed to the Apache Software Foundation (ASF) under one
-; or more contributor license agreements.  See the NOTICE file
-; distributed with this work for additional information
-; regarding copyright ownership.  The ASF licenses this file
-; to you under the Apache License, Version 2.0 (the
-; "License"); you may not use this file except in compliance
-; with the License.  You may obtain a copy of the License at
-; 
-;   http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing,
-; software distributed under the License is distributed on an
-; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-; KIND, either express or implied.  See the License for the
-; specific language governing permissions and limitations
-; under the License.
-
-[httpd]
-port = 0

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/etap/test_util.erl.in
----------------------------------------------------------------------
diff --git a/test/etap/test_util.erl.in b/test/etap/test_util.erl.in
index 92b9208..352714e 100644
--- a/test/etap/test_util.erl.in
+++ b/test/etap/test_util.erl.in
@@ -46,7 +46,7 @@ build_file(Name) ->
 config_files() ->
     [
         build_file("etc/couchdb/default_dev.ini"),
-        source_file("test/etap/random_port.ini"),
+        source_file("test/random_port.ini"),
         build_file("etc/couchdb/local_dev.ini")
     ].
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/Makefile.am
----------------------------------------------------------------------
diff --git a/test/javascript/Makefile.am b/test/javascript/Makefile.am
index 71f9ae6..d7367e0 100644
--- a/test/javascript/Makefile.am
+++ b/test/javascript/Makefile.am
@@ -21,5 +21,6 @@ CLEANFILES = run
 run: run.tpl
 	sed -e "s|%abs_top_srcdir%|$(abs_top_srcdir)|" \
 		-e "s|%abs_top_builddir%|$(abs_top_builddir)|" \
+		-e "s|%localstaterundir%|$(abs_top_builddir)/tmp/run|g" \
 	< $< > $@
 	chmod +x $@

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/couch_http.js
----------------------------------------------------------------------
diff --git a/test/javascript/couch_http.js b/test/javascript/couch_http.js
index 141993e..c44ce28 100644
--- a/test/javascript/couch_http.js
+++ b/test/javascript/couch_http.js
@@ -11,15 +11,14 @@
 // the License.
 
 (function() {
-  CouchHTTP.prototype.base_url = "http://127.0.0.1:5984"
-
   if(typeof(CouchHTTP) != "undefined") {
     CouchHTTP.prototype.open = function(method, url, async) {
       if(!/^\s*http:\/\//.test(url)) {
-        if(/^[^\/]/.test(url)) {
-          url = this.base_url + "/" + url;
+        if(/^\//.test(url)) {
+          // The couch.uri file (base_url) has a trailing slash
+          url = this.base_url + url.slice(1);
         } else {
-         url = this.base_url + url;
+          url = this.base_url + url;
         }
       }
       

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
----------------------------------------------------------------------
diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
index 47d2f6e..ac78b50 100644
--- a/test/javascript/run.tpl
+++ b/test/javascript/run.tpl
@@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
 JS_TEST_DIR=$SRC_DIR/test/javascript
 
 COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
+COUCH_URI_FILE=%localstaterundir%/couch.uri
 
 if [ "$#" -eq 0 ];
 then
@@ -48,11 +49,15 @@ abort() {
 if [ -z $COUCHDB_NO_START ]; then
         make dev
 	trap 'abort' 0 1 2 3 4 6 8 15
-	./utils/run -b -r 1
+	./utils/run -b -r 1 -n \
+		-a $SRC_DIR/etc/couchdb/default_dev.ini \
+		-a $SRC_DIR/test/random_port.ini \
+		-a $SRC_DIR/etc/couchdb/local_dev.ini
 	sleep 1 # give it a sec
 fi
 
-$COUCHJS -H \
+# start the tests
+$COUCHJS -H -u $COUCH_URI_FILE \
 	$SCRIPT_DIR/json2.js \
 	$SCRIPT_DIR/sha1.js \
 	$SCRIPT_DIR/oauth.js \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/random_port.ini
----------------------------------------------------------------------
diff --git a/test/random_port.ini b/test/random_port.ini
new file mode 100644
index 0000000..2b2d130
--- /dev/null
+++ b/test/random_port.ini
@@ -0,0 +1,19 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements.  See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership.  The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License.  You may obtain a copy of the License at
+;
+;   http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied.  See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[httpd]
+port = 0


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Paul Davis <pa...@gmail.com>.
I assumed it was the cookie auth thing detecting that a secret hasn't
been set so it generates its own. I gave it about 30s of thought and
couldn't think of something that was better than making sure the
local_dev.ini was writable (which it should be).

On Fri, Apr 27, 2012 at 5:42 AM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On Apr 27, 2012, at 02:30 , Paul Davis wrote:
>
>> Found it:
>>
>> {set,"couch_httpd_auth","secret","81732db8242bbeacb35ce76fe44b554d",true}
>>
>> I'm just gonna make local_dev.ini writable and forget about it. This
>> is just a VPATH build artifact because it forces the local.ini to be
>> read-only.
>
> I'd prefer making that set not persistent. In addition, this call doesn't
> occur in cookie_auth.js.
>
> Cheers
> Jan
> --
>
>
>>
>> On Thu, Apr 26, 2012 at 7:20 PM, Randall Leeds <ra...@gmail.com> wrote:
>>> On Thu, Apr 26, 2012 at 17:03, Paul Davis <pa...@gmail.com> wrote:
>>>> Now we figure out what its trying to write to.
>>>
>>> Blind guess: not using X-Couch-Persist: false for something?
>>>
>>>>
>>>> On Thu, Apr 26, 2012 at 4:30 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>> The problem is that the vpath directory has -w perms. Running
>>>>> chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
>>>>> ./test/javascript/run again, it all works.
>>>>>
>>>>> What now? :)
>>>>>
>>>>> Cheers
>>>>> Jan
>>>>> --
>>>>>
>>>>>
>>>>> On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:
>>>>>
>>>>>>
>>>>>> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
>>>>>>
>>>>>>>
>>>>>>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>>>>>>>
>>>>>>>> Reproduces for me. Also looks related to the vpath build because it
>>>>>>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>>>>>>>
>>>>>>> one more interesting point, if you cd into the distcheck build dir,
>>>>>>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>>>>>>> and then run ./test/javascript/run it all succeeds as well.
>>>>>>>
>>>>>>> Maybe we are digging in the wrong place?
>>>>>>
>>>>>> This however reproduces the failure:
>>>>>>
>>>>>>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
>>>>>>
>>>>>> *keeps digging*
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>> Actually, no.
>>>>>>>>>
>>>>>>>>> I can now repeatedly get make distcheck to fail at
>>>>>>>>>
>>>>>>>>> not ok 18 cookie_auth
>>>>>>>>>
>>>>>>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>>>>>>>
>>>>>>>>> Full log:
>>>>>>>>>
>>>>>>>>> not ok 18 cookie_auth
>>>>>>>>> Reason: false
>>>>>>>>> Trace back (most recent call first):
>>>>>>>>>
>>>>>>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>>>    T(false)
>>>>>>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>>>    ()
>>>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>>>>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>>>    ()
>>>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>>>>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>>>    runAllTestsConsole()
>>>>>>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>>>>>>>
>>>>>>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>>>>>>>
>>>>>>>>>> Cheers!
>>>>>>>>>>
>>>>>>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>>>>>>>
>>>>>>>>>>> Thanks for the replies!
>>>>>>>>>>>
>>>>>>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>>>>>>>
>>>>>>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>>>>>>>
>>>>>>>>>>> What now? :)
>>>>>>>>>>>
>>>>>>>>>>> Jan
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>>>>>>> or so.
>>>>>>>>>>>>
>>>>>>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>>>>>>> object to store the value.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> [...]
>>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>>>>>>    make dev
>>>>>>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> … and the -a lines …
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>>>>>>> preference over default_dev.ini or something).
>>>>>>>>>>>>>
>>>>>>>>>>>>> -R
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
On Apr 27, 2012, at 02:30 , Paul Davis wrote:

> Found it:
> 
> {set,"couch_httpd_auth","secret","81732db8242bbeacb35ce76fe44b554d",true}
> 
> I'm just gonna make local_dev.ini writable and forget about it. This
> is just a VPATH build artifact because it forces the local.ini to be
> read-only.

I'd prefer making that set not persistent. In addition, this call doesn't
occur in cookie_auth.js.

Cheers
Jan
--


> 
> On Thu, Apr 26, 2012 at 7:20 PM, Randall Leeds <ra...@gmail.com> wrote:
>> On Thu, Apr 26, 2012 at 17:03, Paul Davis <pa...@gmail.com> wrote:
>>> Now we figure out what its trying to write to.
>> 
>> Blind guess: not using X-Couch-Persist: false for something?
>> 
>>> 
>>> On Thu, Apr 26, 2012 at 4:30 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>> The problem is that the vpath directory has -w perms. Running
>>>> chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
>>>> ./test/javascript/run again, it all works.
>>>> 
>>>> What now? :)
>>>> 
>>>> Cheers
>>>> Jan
>>>> --
>>>> 
>>>> 
>>>> On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:
>>>> 
>>>>> 
>>>>> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
>>>>> 
>>>>>> 
>>>>>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>>>>>> 
>>>>>>> Reproduces for me. Also looks related to the vpath build because it
>>>>>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>>>>>> 
>>>>>> one more interesting point, if you cd into the distcheck build dir,
>>>>>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>>>>>> and then run ./test/javascript/run it all succeeds as well.
>>>>>> 
>>>>>> Maybe we are digging in the wrong place?
>>>>> 
>>>>> This however reproduces the failure:
>>>>> 
>>>>>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
>>>>> 
>>>>> *keeps digging*
>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>> Actually, no.
>>>>>>>> 
>>>>>>>> I can now repeatedly get make distcheck to fail at
>>>>>>>> 
>>>>>>>> not ok 18 cookie_auth
>>>>>>>> 
>>>>>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>>>>>> 
>>>>>>>> Full log:
>>>>>>>> 
>>>>>>>> not ok 18 cookie_auth
>>>>>>>> Reason: false
>>>>>>>> Trace back (most recent call first):
>>>>>>>> 
>>>>>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>>    T(false)
>>>>>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>>    ()
>>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>>>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>>    ()
>>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>>>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>>    runAllTestsConsole()
>>>>>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>>>>>> 
>>>>>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>>>>>> 
>>>>>>>>> Cheers!
>>>>>>>>> 
>>>>>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>>>>>> 
>>>>>>>>>> Thanks for the replies!
>>>>>>>>>> 
>>>>>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>>>>>> 
>>>>>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>>>>>> 
>>>>>>>>>> What now? :)
>>>>>>>>>> 
>>>>>>>>>> Jan
>>>>>>>>>> --
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>>>>>> 
>>>>>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>>>>>> or so.
>>>>>>>>>>> 
>>>>>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>>>>>> object to store the value.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> [...]
>>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>>>>>> then
>>>>>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>>>>>    make dev
>>>>>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> … and the -a lines …
>>>>>>>>>>>> 
>>>>>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>>>>>> preference over default_dev.ini or something).
>>>>>>>>>>>> 
>>>>>>>>>>>> -R
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>> 
>>>> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Paul Davis <pa...@gmail.com>.
Found it:

{set,"couch_httpd_auth","secret","81732db8242bbeacb35ce76fe44b554d",true}

I'm just gonna make local_dev.ini writable and forget about it. This
is just a VPATH build artifact because it forces the local.ini to be
read-only.

On Thu, Apr 26, 2012 at 7:20 PM, Randall Leeds <ra...@gmail.com> wrote:
> On Thu, Apr 26, 2012 at 17:03, Paul Davis <pa...@gmail.com> wrote:
>> Now we figure out what its trying to write to.
>
> Blind guess: not using X-Couch-Persist: false for something?
>
>>
>> On Thu, Apr 26, 2012 at 4:30 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>> The problem is that the vpath directory has -w perms. Running
>>> chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
>>> ./test/javascript/run again, it all works.
>>>
>>> What now? :)
>>>
>>> Cheers
>>> Jan
>>> --
>>>
>>>
>>> On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:
>>>
>>>>
>>>> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
>>>>
>>>>>
>>>>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>>>>>
>>>>>> Reproduces for me. Also looks related to the vpath build because it
>>>>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>>>>>
>>>>> one more interesting point, if you cd into the distcheck build dir,
>>>>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>>>>> and then run ./test/javascript/run it all succeeds as well.
>>>>>
>>>>> Maybe we are digging in the wrong place?
>>>>
>>>> This however reproduces the failure:
>>>>
>>>>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
>>>>
>>>> *keeps digging*
>>>>
>>>>>
>>>>>
>>>>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>> Actually, no.
>>>>>>>
>>>>>>> I can now repeatedly get make distcheck to fail at
>>>>>>>
>>>>>>> not ok 18 cookie_auth
>>>>>>>
>>>>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>>>>>
>>>>>>> Full log:
>>>>>>>
>>>>>>> not ok 18 cookie_auth
>>>>>>> Reason: false
>>>>>>> Trace back (most recent call first):
>>>>>>>
>>>>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>    T(false)
>>>>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>    ()
>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>>    ()
>>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>    runAllTestsConsole()
>>>>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>>>>>
>>>>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>>>>>
>>>>>>>> Cheers!
>>>>>>>>
>>>>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>>>>>
>>>>>>>>> Thanks for the replies!
>>>>>>>>>
>>>>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>>>>>
>>>>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>>>>>
>>>>>>>>> What now? :)
>>>>>>>>>
>>>>>>>>> Jan
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>>>>>
>>>>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>>>>> or so.
>>>>>>>>>>
>>>>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>>>>> object to store the value.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> [...]
>>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>>>>> then
>>>>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>>>>    make dev
>>>>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>>>>>
>>>>>>>>>>>> … and the -a lines …
>>>>>>>>>>>
>>>>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>>>>> preference over default_dev.ini or something).
>>>>>>>>>>>
>>>>>>>>>>> -R
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>
>>>

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Randall Leeds <ra...@gmail.com>.
On Thu, Apr 26, 2012 at 17:03, Paul Davis <pa...@gmail.com> wrote:
> Now we figure out what its trying to write to.

Blind guess: not using X-Couch-Persist: false for something?

>
> On Thu, Apr 26, 2012 at 4:30 PM, Jan Lehnardt <ja...@apache.org> wrote:
>> The problem is that the vpath directory has -w perms. Running
>> chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
>> ./test/javascript/run again, it all works.
>>
>> What now? :)
>>
>> Cheers
>> Jan
>> --
>>
>>
>> On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:
>>
>>>
>>> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
>>>
>>>>
>>>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>>>>
>>>>> Reproduces for me. Also looks related to the vpath build because it
>>>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>>>>
>>>> one more interesting point, if you cd into the distcheck build dir,
>>>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>>>> and then run ./test/javascript/run it all succeeds as well.
>>>>
>>>> Maybe we are digging in the wrong place?
>>>
>>> This however reproduces the failure:
>>>
>>>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
>>>
>>> *keeps digging*
>>>
>>>>
>>>>
>>>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>> Actually, no.
>>>>>>
>>>>>> I can now repeatedly get make distcheck to fail at
>>>>>>
>>>>>> not ok 18 cookie_auth
>>>>>>
>>>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>>>>
>>>>>> Full log:
>>>>>>
>>>>>> not ok 18 cookie_auth
>>>>>> Reason: false
>>>>>> Trace back (most recent call first):
>>>>>>
>>>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>    T(false)
>>>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>    ()
>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>>    ()
>>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>    runAllTestsConsole()
>>>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>>>>
>>>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>>>>
>>>>>>> Cheers!
>>>>>>>
>>>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>>>>
>>>>>>>> Thanks for the replies!
>>>>>>>>
>>>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>>>>
>>>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>>>>
>>>>>>>> What now? :)
>>>>>>>>
>>>>>>>> Jan
>>>>>>>> --
>>>>>>>>
>>>>>>>>
>>>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>>>>
>>>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>>>> or so.
>>>>>>>>>
>>>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>>>>
>>>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>>>>
>>>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>>>> object to store the value.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>>>>
>>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>>>>
>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> [...]
>>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>>>>
>>>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>>>>
>>>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>>>> then
>>>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>>>    make dev
>>>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>>>>
>>>>>>>>>>> … and the -a lines …
>>>>>>>>>>
>>>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>>>> preference over default_dev.ini or something).
>>>>>>>>>>
>>>>>>>>>> -R
>>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>>
>>

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Paul Davis <pa...@gmail.com>.
Now we figure out what its trying to write to.

On Thu, Apr 26, 2012 at 4:30 PM, Jan Lehnardt <ja...@apache.org> wrote:
> The problem is that the vpath directory has -w perms. Running
> chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
> ./test/javascript/run again, it all works.
>
> What now? :)
>
> Cheers
> Jan
> --
>
>
> On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:
>
>>
>> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
>>
>>>
>>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>>>
>>>> Reproduces for me. Also looks related to the vpath build because it
>>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>>>
>>> one more interesting point, if you cd into the distcheck build dir,
>>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>>> and then run ./test/javascript/run it all succeeds as well.
>>>
>>> Maybe we are digging in the wrong place?
>>
>> This however reproduces the failure:
>>
>>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
>>
>> *keeps digging*
>>
>>>
>>>
>>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>>> Actually, no.
>>>>>
>>>>> I can now repeatedly get make distcheck to fail at
>>>>>
>>>>> not ok 18 cookie_auth
>>>>>
>>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>>>
>>>>> Full log:
>>>>>
>>>>> not ok 18 cookie_auth
>>>>> Reason: false
>>>>> Trace back (most recent call first):
>>>>>
>>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>    T(false)
>>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>    ()
>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>>    ()
>>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>    runAllTestsConsole()
>>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>>>
>>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>>>
>>>>>> Cheers!
>>>>>>
>>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>>>
>>>>>>> Thanks for the replies!
>>>>>>>
>>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>>>
>>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>>>
>>>>>>> What now? :)
>>>>>>>
>>>>>>> Jan
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>>>
>>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>>> or so.
>>>>>>>>
>>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>>>
>>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>>>
>>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>>>
>>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>>> object to store the value.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>>>
>>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>>>
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> [...]
>>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>>>
>>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>>>
>>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>>> then
>>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>>    make dev
>>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>>>
>>>>>>>>>> … and the -a lines …
>>>>>>>>>
>>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>>> preference over default_dev.ini or something).
>>>>>>>>>
>>>>>>>>> -R
>>>>>>>
>>>>>>
>>>>>
>>>
>>
>

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
The problem is that the vpath directory has -w perms. Running
chmod -R +w apache-couchdb-1.3.0a-eb3d5d8-git and then
./test/javascript/run again, it all works.

What now? :)

Cheers
Jan
--


On Apr 26, 2012, at 22:55 , Jan Lehnardt wrote:

> 
> On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:
> 
>> 
>> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
>> 
>>> Reproduces for me. Also looks related to the vpath build because it
>>> only reproduces in distcheck and runs fine otherwise. Looking into it.
>> 
>> one more interesting point, if you cd into the distcheck build dir,
>> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
>> and then run ./test/javascript/run it all succeeds as well.
>> 
>> Maybe we are digging in the wrong place?
> 
> This however reproduces the failure:
> 
>> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth
> 
> *keeps digging*
> 
>> 
>> 
>>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>>> Actually, no.
>>>> 
>>>> I can now repeatedly get make distcheck to fail at
>>>> 
>>>> not ok 18 cookie_auth
>>>> 
>>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>>> 
>>>> Full log:
>>>> 
>>>> not ok 18 cookie_auth
>>>> Reason: false
>>>> Trace back (most recent call first):
>>>> 
>>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>    T(false)
>>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>    ()
>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>    run_on_modified_server([object Array],(function () {try {var ddoc = op
>>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>>    ()
>>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>>    var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>>    runAllTestsConsole()
>>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>>> 
>>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>>> 
>>>>> Cheers!
>>>>> 
>>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>>> 
>>>>>> Thanks for the replies!
>>>>>> 
>>>>>> ./test/javascript/run.tpl, line 15:
>>>>>> 
>>>>>> SRC_DIR=%abs_top_srcdir%
>>>>>> 
>>>>>> What now? :)
>>>>>> 
>>>>>> Jan
>>>>>> --
>>>>>> 
>>>>>> 
>>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>>> 
>>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>>> or so.
>>>>>>> 
>>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>>> 
>>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>>> 
>>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>>> 
>>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>>> object to store the value.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>>> 
>>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>>> Parents: 257eb52
>>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>>> 
>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> [...]
>>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>>> 
>>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>>> 
>>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>>> then
>>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>>    make dev
>>>>>>>>>>>  trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>>> 
>>>>>>>>> … and the -a lines …
>>>>>>>> 
>>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>>> preference over default_dev.ini or something).
>>>>>>>> 
>>>>>>>> -R
>>>>>> 
>>>>> 
>>>> 
>> 
> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
On Apr 26, 2012, at 22:26 , Jan Lehnardt wrote:

> 
> On Apr 26, 2012, at 19:38 , Paul Davis wrote:
> 
>> Reproduces for me. Also looks related to the vpath build because it
>> only reproduces in distcheck and runs fine otherwise. Looking into it.
> 
> one more interesting point, if you cd into the distcheck build dir,
> currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
> and then run ./test/javascript/run it all succeeds as well.
> 
> Maybe we are digging in the wrong place?

This however reproduces the failure:

> ./apache-couchdb-1.3.0a-eb3d5d8-git/_build/test/javascript/run cookie_auth

*keeps digging*

> 
> 
>> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>>> Actually, no.
>>> 
>>> I can now repeatedly get make distcheck to fail at
>>> 
>>> not ok 18 cookie_auth
>>> 
>>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>>> 
>>> Full log:
>>> 
>>> not ok 18 cookie_auth
>>> Reason: false
>>> Trace back (most recent call first):
>>> 
>>> 46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>     T(false)
>>> 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>     ()
>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>     run_on_modified_server([object Array],(function () {try {var ddoc = op
>>> 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>>     ()
>>> "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>>     var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>> 72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>>     runAllTestsConsole()
>>> 85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>>> 
>>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>>> 
>>>> Cheers!
>>>> 
>>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>>> 
>>>>> Thanks for the replies!
>>>>> 
>>>>> ./test/javascript/run.tpl, line 15:
>>>>> 
>>>>> SRC_DIR=%abs_top_srcdir%
>>>>> 
>>>>> What now? :)
>>>>> 
>>>>> Jan
>>>>> --
>>>>> 
>>>>> 
>>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>>> 
>>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>>> or so.
>>>>>> 
>>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>>> 
>>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>>> 
>>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>>> 
>>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>>> object to store the value.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>>> 
>>>>>>>>>> Branch: refs/heads/master
>>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>>> Parents: 257eb52
>>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>>> 
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> [...]
>>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>>> 
>>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>>> 
>>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>>> then
>>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>>     make dev
>>>>>>>>>>   trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>>> 
>>>>>>>> … and the -a lines …
>>>>>>> 
>>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>>> preference over default_dev.ini or something).
>>>>>>> 
>>>>>>> -R
>>>>> 
>>>> 
>>> 
> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
On Apr 26, 2012, at 19:38 , Paul Davis wrote:

> Reproduces for me. Also looks related to the vpath build because it
> only reproduces in distcheck and runs fine otherwise. Looking into it.

one more interesting point, if you cd into the distcheck build dir,
currently apache-couchdb-1.3.0a-eb3d5d8-git/_build after the test fails
and then run ./test/javascript/run it all succeeds as well.

Maybe we are digging in the wrong place?


> On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
>> Actually, no.
>> 
>> I can now repeatedly get make distcheck to fail at
>> 
>>  not ok 18 cookie_auth
>> 
>> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>> 
>> Full log:
>> 
>> not ok 18 cookie_auth
>> Reason: false
>> Trace back (most recent call first):
>> 
>>  46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>      T(false)
>>  133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>      ()
>>  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>      run_on_modified_server([object Array],(function () {try {var ddoc = op
>>  286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>>      ()
>>  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>>      var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>>  72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>>      runAllTestsConsole()
>>  85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>> 
>> 
>> 
>> 
>> 
>> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>> 
>>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>> 
>>> Cheers!
>>> 
>>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>> 
>>>> Thanks for the replies!
>>>> 
>>>> ./test/javascript/run.tpl, line 15:
>>>> 
>>>> SRC_DIR=%abs_top_srcdir%
>>>> 
>>>> What now? :)
>>>> 
>>>> Jan
>>>> --
>>>> 
>>>> 
>>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>> 
>>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>>> those needs to support write backs by one of the tests. Basic solution
>>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>>> or so.
>>>>> 
>>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>> 
>>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>> 
>>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>> 
>>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>>> object to store the value.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>> 
>>>>>>>>> Branch: refs/heads/master
>>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>>> Parents: 257eb52
>>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>> 
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> [...]
>>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>> 
>>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>> 
>>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>>> then
>>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>>      make dev
>>>>>>>>>    trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>> 
>>>>>>> … and the -a lines …
>>>>>> 
>>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>>> preference over default_dev.ini or something).
>>>>>> 
>>>>>> -R
>>>> 
>>> 
>> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Paul Davis <pa...@gmail.com>.
Reproduces for me. Also looks related to the vpath build because it
only reproduces in distcheck and runs fine otherwise. Looking into it.

On Thu, Apr 26, 2012 at 6:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
> Actually, no.
>
> I can now repeatedly get make distcheck to fail at
>
>  not ok 18 cookie_auth
>
> on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.
>
> Full log:
>
> not ok 18 cookie_auth
> Reason: false
> Trace back (most recent call first):
>
>  46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>      T(false)
>  133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>      ()
>  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>      run_on_modified_server([object Array],(function () {try {var ddoc = op
>  286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
>      ()
>  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
>      var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
>  72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>      runAllTestsConsole()
>  85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
>
>
>
>
>
> On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:
>
>> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
>>
>> Cheers!
>>
>> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
>>
>>> Thanks for the replies!
>>>
>>> ./test/javascript/run.tpl, line 15:
>>>
>>> SRC_DIR=%abs_top_srcdir%
>>>
>>> What now? :)
>>>
>>> Jan
>>> --
>>>
>>>
>>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>>>
>>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>>> depending on how they're used. It can be a bit of a PITA if one of
>>>> those needs to support write backs by one of the tests. Basic solution
>>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>>> or so.
>>>>
>>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>>>
>>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>>>
>>>>>>>
>>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>>>
>>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>>>
>>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>>> different port. To work around this, add a getter property for the
>>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>>> object to store the value.
>>>>>>>>
>>>>>>>>
>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>>>
>>>>>>>> Branch: refs/heads/master
>>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>>> Parents: 257eb52
>>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>>> test/Makefile.am                  |    1 +
>>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>
>>>>>>>> [...]
>>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>>> --- a/test/javascript/run.tpl
>>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>>>
>>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>>>
>>>>>>>> if [ "$#" -eq 0 ];
>>>>>>>> then
>>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>>      make dev
>>>>>>>>    trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>>> -    ./utils/run -b -r 1
>>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>>>
>>>>>>>
>>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>>>
>>>>>> … and the -a lines …
>>>>>
>>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>>> of the patch. I can't remember at this moment why I needed to specify
>>>>> exactly all the configs and use the -n to reset the config chain, but
>>>>> I'm sure there was a reason (like random_port.ini not getting
>>>>> preference over default_dev.ini or something).
>>>>>
>>>>> -R
>>>
>>
>

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
Actually, no.

I can now repeatedly get make distcheck to fail at

  not ok 18 cookie_auth

on two different machines. I don't know if this was introduced in the "fixing" commit or one of Paul's others.

Full log:

not ok 18 cookie_auth
Reason: false
Trace back (most recent call first):
    
  46: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
      T(false)
 133: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
      ()
  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/couch_test_runner.js:380: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
      run_on_modified_server([object Array],(function () {try {var ddoc = op
 286: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../share/www/script/test/cookie_auth.js
      ()
  "jchris@apache.org"}, "eh, Boo-Boo?");try {usersDb.save(duplicateJchrisDoc);T(false && "Can't create duplicate user names. Should have thrown an error.");} catch (e) {T(e.error == "conflict");T(usersDb.last_req.status == 409);}var underscoreUserDoc = CouchDB.prepareUserDoc({name: "_why"}, "copperfield");try {usersDb.save(underscoreUserDoc);T(false && "Can't create underscore user names. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}var badIdDoc = CouchDB.prepareUserDoc({name: "foo"}, "bar");badIdDoc._id = "org.apache.couchdb:w00x";try {usersDb.save(badIdDoc);T(false && "Can't create malformed docids. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.login("Jason Davies", password).ok);T(CouchDB.session().userCtx.name == "Jason Davies");var xhr = CouchDB.request("POST", "/_session", {headers: {'Content-Type': "application/json"}, body: JSON.stringify({name: "Jason Davies", password: password})});T(JSON.parse(xhr.responseText).ok);T(CouchDB.session().userCtx.name == "Jason Davies");jasonUserDoc.foo = 2;T(usersDb.save(jasonUserDoc).ok);T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);try {usersDb.deleteDoc(jchrisUserDoc);T(false && "Can't delete other users docs. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(!CouchDB.login("Jason Davies", "2.71828").ok);T(!CouchDB.login("Robert Allen Zimmerman", "d00d").ok);T(CouchDB.session().userCtx.name != "Jason Davies");xhr = CouchDB.request("POST", "/_session?next=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=" + encodeURIComponent(password)});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}xhr = CouchDB.request("POST", "/_session?fail=/", {headers: {'Content-Type': "application/x-www-form-urlencoded"}, body: "name=Jason%20Davies&password=foobar"});if (xhr.status == 200) {T(/Welcome/.test(xhr.responseText));}T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.length == 0);jasonUserDoc.foo = 3;try {usersDb.save(jasonUserDoc);T(false && "Can't update someone else's user doc. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}jchrisUserDoc.roles = ["foo"];try {usersDb.save(jchrisUserDoc);T(false && "Can't set roles unless you are admin. Should have thrown an error.");} catch (e) {T(e.error == "forbidden");T(usersDb.last_req.status == 403);}T(CouchDB.logout().ok);jchrisUserDoc.foo = ["foo"];T(save_as(usersDb, jchrisUserDoc, "jan"));jchrisUserDoc.roles = ["_bar"];var res = save_as(usersDb, jchrisUserDoc, "jan");T(res.error == "forbidden");T(usersDb.last_req.status == 403);T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);T(CouchDB.logout().ok);TEquals(true, CouchDB.login("jan", "apple").ok);run_on_modified_server([{section: "admins", key: "jchris@apache.org", value: "funnybone"}], function () {T(CouchDB.login("jchris@apache.org", "funnybone").ok);T(CouchDB.session().userCtx.name == "jchris@apache.org");T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1);T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);jchrisUserDoc = usersDb.open(jchrisUserDoc._id);delete jchrisUserDoc.salt;delete jchrisUserDoc.password_sha;T(usersDb.save(jchrisUserDoc).ok);T(CouchDB.logout().ok);T(CouchDB.login("jchris@apache.org", "funnybone").ok);var s = CouchDB.session();T(s.userCtx.name == "jchris@apache.org");T(s.userCtx.roles.indexOf("_admin") != -1);T(s.info.authenticated == "cookie");T(s.info.authentication_db == "test_suite_users");T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);});} finally {T(CouchDB.logout().ok);}TEquals(true, CouchDB.login("jan", "apple").ok);};var usersDb = new CouchDB("test_suite_users", {'X-Couch-Full-Commit': "false"});usersDb.deleteDb();usersDb.createDb();run_on_modified_server([{section: "couch_httpd_auth", key: "authentication_db", value: "test_suite_users"}, {section: "couch_httpd_auth", key: "iterations", value: "1"}, {section: "admins", key: "jan", value: "apple"}], testFun);}))@/Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js:53: apache.org"}, "funnybone");T(usersDb.save(jchrisUserDoc).ok);var duplicateJchrisDoc = CouchDB.prepareUserDoc({name
      var testFun = function () {try {var ddoc = open_as(usersDb, "_design/_
  72: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
      runAllTestsConsole()
  85: /Users/jan/Work/couchdb/apache-couchdb-1.3.0a-0250310-git/_build/../test/javascript/cli_runner.js
      




On Apr 26, 2012, at 13:27 , Jan Lehnardt wrote:

> Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102
> 
> Cheers!
> 
> On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:
> 
>> Thanks for the replies!
>> 
>> ./test/javascript/run.tpl, line 15:
>> 
>> SRC_DIR=%abs_top_srcdir%
>> 
>> What now? :)
>> 
>> Jan
>> -- 
>> 
>> 
>> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
>> 
>>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>>> depending on how they're used. It can be a bit of a PITA if one of
>>> those needs to support write backs by one of the tests. Basic solution
>>> is to name them foo.ini.tpl and then "build" foo.ini and use
>>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>>> or so.
>>> 
>>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>>> 
>>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>>> 
>>>>>> 
>>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>>> 
>>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>>> 
>>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>>> different port. To work around this, add a getter property for the
>>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>>> object to store the value.
>>>>>>> 
>>>>>>> 
>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>>> 
>>>>>>> Branch: refs/heads/master
>>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>>> Parents: 257eb52
>>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>>> 
>>>>>>> ----------------------------------------------------------------------
>>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>>> test/Makefile.am                  |    1 +
>>>>>>> test/etap/Makefile.am             |    1 -
>>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>>> ----------------------------------------------------------------------
>>>>>>> 
>>>>>>> 
>>>>>>> [...]
>>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>>> ----------------------------------------------------------------------
>>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>>> index 47d2f6e..ac78b50 100644
>>>>>>> --- a/test/javascript/run.tpl
>>>>>>> +++ b/test/javascript/run.tpl
>>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>>> 
>>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>>> 
>>>>>>> if [ "$#" -eq 0 ];
>>>>>>> then
>>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>>      make dev
>>>>>>>    trap 'abort' 0 1 2 3 4 6 8 15
>>>>>>> -    ./utils/run -b -r 1
>>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>>> 
>>>>>> 
>>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>>> 
>>>>> … and the -a lines …
>>>> 
>>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>>> The -a ...random_port.ini is the crucial one, because that's the point
>>>> of the patch. I can't remember at this moment why I needed to specify
>>>> exactly all the configs and use the -n to reset the config chain, but
>>>> I'm sure there was a reason (like random_port.ini not getting
>>>> preference over default_dev.ini or something).
>>>> 
>>>> -R
>> 
> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
Paul fixed this in http://git-wip-us.apache.org/repos/asf/couchdb/commit/02503102

Cheers!

On Apr 24, 2012, at 20:39 , Jan Lehnardt wrote:

> Thanks for the replies!
> 
> ./test/javascript/run.tpl, line 15:
> 
> SRC_DIR=%abs_top_srcdir%
> 
> What now? :)
> 
> Jan
> -- 
> 
> 
> On Apr 24, 2012, at 20:25 , Paul Davis wrote:
> 
>> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
>> depending on how they're used. It can be a bit of a PITA if one of
>> those needs to support write backs by one of the tests. Basic solution
>> is to name them foo.ini.tpl and then "build" foo.ini and use
>> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
>> or so.
>> 
>> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>>> 
>>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>>> 
>>>>> 
>>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>>> 
>>>>>> COUCHDB-1338 - run js tests with port=0
>>>>>> 
>>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>>> different port. To work around this, add a getter property for the
>>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>>> object to store the value.
>>>>>> 
>>>>>> 
>>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>>> 
>>>>>> Branch: refs/heads/master
>>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>>> Parents: 257eb52
>>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>>> 
>>>>>> ----------------------------------------------------------------------
>>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>>> test/Makefile.am                  |    1 +
>>>>>> test/etap/Makefile.am             |    1 -
>>>>>> test/etap/random_port.ini         |   19 ----------
>>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>>> test/javascript/Makefile.am       |    1 +
>>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>>> test/random_port.ini              |   19 ++++++++++
>>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>>> ----------------------------------------------------------------------
>>>>>> 
>>>>>> 
>>>>>> [...]
>>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>>> ----------------------------------------------------------------------
>>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>>> index 47d2f6e..ac78b50 100644
>>>>>> --- a/test/javascript/run.tpl
>>>>>> +++ b/test/javascript/run.tpl
>>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>>> 
>>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>>> 
>>>>>> if [ "$#" -eq 0 ];
>>>>>> then
>>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>>       make dev
>>>>>>     trap 'abort' 0 1 2 3 4 6 8 15
>>>>>> -    ./utils/run -b -r 1
>>>>>> +    ./utils/run -b -r 1 -n \
>>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>>> 
>>>>> 
>>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>>> 
>>>> … and the -a lines …
>>> 
>>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>>> The -a ...random_port.ini is the crucial one, because that's the point
>>> of the patch. I can't remember at this moment why I needed to specify
>>> exactly all the configs and use the -n to reset the config chain, but
>>> I'm sure there was a reason (like random_port.ini not getting
>>> preference over default_dev.ini or something).
>>> 
>>> -R
> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
Thanks for the replies!

./test/javascript/run.tpl, line 15:

SRC_DIR=%abs_top_srcdir%

What now? :)

Jan
-- 


On Apr 24, 2012, at 20:25 , Paul Davis wrote:

> Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
> depending on how they're used. It can be a bit of a PITA if one of
> those needs to support write backs by one of the tests. Basic solution
> is to name them foo.ini.tpl and then "build" foo.ini and use
> $(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
> or so.
> 
> On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
>> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>> 
>>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>> 
>>>> 
>>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>> 
>>>>> COUCHDB-1338 - run js tests with port=0
>>>>> 
>>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>>> different port. To work around this, add a getter property for the
>>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>>> object to store the value.
>>>>> 
>>>>> 
>>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>> 
>>>>> Branch: refs/heads/master
>>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>>> Parents: 257eb52
>>>>> Author: Randall Leeds <ra...@apache.org>
>>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>>> Committer: Randall Leeds <ra...@apache.org>
>>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>> 
>>>>> ----------------------------------------------------------------------
>>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>>> test/Makefile.am                  |    1 +
>>>>> test/etap/Makefile.am             |    1 -
>>>>> test/etap/random_port.ini         |   19 ----------
>>>>> test/etap/test_util.erl.in        |    2 +-
>>>>> test/javascript/Makefile.am       |    1 +
>>>>> test/javascript/couch_http.js     |    9 ++---
>>>>> test/javascript/run.tpl           |    9 ++++-
>>>>> test/random_port.ini              |   19 ++++++++++
>>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>>> ----------------------------------------------------------------------
>>>>> 
>>>>> 
>>>>> [...]
>>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>>> index 47d2f6e..ac78b50 100644
>>>>> --- a/test/javascript/run.tpl
>>>>> +++ b/test/javascript/run.tpl
>>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>> 
>>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>> 
>>>>> if [ "$#" -eq 0 ];
>>>>> then
>>>>> @@ -48,11 +49,15 @@ abort() {
>>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>>        make dev
>>>>>      trap 'abort' 0 1 2 3 4 6 8 15
>>>>> -    ./utils/run -b -r 1
>>>>> +    ./utils/run -b -r 1 -n \
>>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>> 
>>>> 
>>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>> 
>>> … and the -a lines …
>> 
>> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
>> The -a ...random_port.ini is the crucial one, because that's the point
>> of the patch. I can't remember at this moment why I needed to specify
>> exactly all the configs and use the -n to reset the config chain, but
>> I'm sure there was a reason (like random_port.ini not getting
>> preference over default_dev.ini or something).
>> 
>> -R


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Paul Davis <pa...@gmail.com>.
Yeah. We'll need an $(abs_top_srcdir) or $(abs_top_builddir) here
depending on how they're used. It can be a bit of a PITA if one of
those needs to support write backs by one of the tests. Basic solution
is to name them foo.ini.tpl and then "build" foo.ini and use
$(abs_top_builddir) in that case. Where by "build" I mean `cp $< $@`
or so.

On Tue, Apr 24, 2012 at 12:04 PM, Randall Leeds <ra...@apache.org> wrote:
> On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>>
>> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>>
>>>
>>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>>
>>>> COUCHDB-1338 - run js tests with port=0
>>>>
>>>> When the JS tests POST to /_restart, the server comes back up on a
>>>> different port. To work around this, add a getter property for the
>>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>>> object to store the value.
>>>>
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>>> Parents: 257eb52
>>>> Author: Randall Leeds <ra...@apache.org>
>>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>>> Committer: Randall Leeds <ra...@apache.org>
>>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>>
>>>> ----------------------------------------------------------------------
>>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>>> test/Makefile.am                  |    1 +
>>>> test/etap/Makefile.am             |    1 -
>>>> test/etap/random_port.ini         |   19 ----------
>>>> test/etap/test_util.erl.in        |    2 +-
>>>> test/javascript/Makefile.am       |    1 +
>>>> test/javascript/couch_http.js     |    9 ++---
>>>> test/javascript/run.tpl           |    9 ++++-
>>>> test/random_port.ini              |   19 ++++++++++
>>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>> [...]
>>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>>> ----------------------------------------------------------------------
>>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>>> index 47d2f6e..ac78b50 100644
>>>> --- a/test/javascript/run.tpl
>>>> +++ b/test/javascript/run.tpl
>>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>>
>>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>>
>>>> if [ "$#" -eq 0 ];
>>>> then
>>>> @@ -48,11 +49,15 @@ abort() {
>>>> if [ -z $COUCHDB_NO_START ]; then
>>>>        make dev
>>>>      trap 'abort' 0 1 2 3 4 6 8 15
>>>> -    ./utils/run -b -r 1
>>>> +    ./utils/run -b -r 1 -n \
>>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>>> +            -a $SRC_DIR/test/random_port.ini \
>>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>>
>>>
>>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>>
>> … and the -a lines …
>
> Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
> The -a ...random_port.ini is the crucial one, because that's the point
> of the patch. I can't remember at this moment why I needed to specify
> exactly all the configs and use the -n to reset the config chain, but
> I'm sure there was a reason (like random_port.ini not getting
> preference over default_dev.ini or something).
>
> -R

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Randall Leeds <ra...@apache.org>.
On Tue, Apr 24, 2012 at 08:08, Jan Lehnardt <ja...@apache.org> wrote:
>
> On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:
>
>>
>> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
>>
>>> COUCHDB-1338 - run js tests with port=0
>>>
>>> When the JS tests POST to /_restart, the server comes back up on a
>>> different port. To work around this, add a getter property for the
>>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>>> object to store the value.
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>>>
>>> Branch: refs/heads/master
>>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>>> Parents: 257eb52
>>> Author: Randall Leeds <ra...@apache.org>
>>> Authored: Sat Jan 7 14:21:29 2012 -0800
>>> Committer: Randall Leeds <ra...@apache.org>
>>> Committed: Thu Jan 26 17:03:10 2012 -0800
>>>
>>> ----------------------------------------------------------------------
>>> src/couchdb/priv/couch_js/help.h  |    2 +
>>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>>> src/couchdb/priv/couch_js/http.h  |    3 ++
>>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>>> src/couchdb/priv/couch_js/util.c  |    3 +-
>>> src/couchdb/priv/couch_js/util.h  |    2 +
>>> test/Makefile.am                  |    1 +
>>> test/etap/Makefile.am             |    1 -
>>> test/etap/random_port.ini         |   19 ----------
>>> test/etap/test_util.erl.in        |    2 +-
>>> test/javascript/Makefile.am       |    1 +
>>> test/javascript/couch_http.js     |    9 ++---
>>> test/javascript/run.tpl           |    9 ++++-
>>> test/random_port.ini              |   19 ++++++++++
>>> 16 files changed, 125 insertions(+), 30 deletions(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>> [...]
>>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>>> ----------------------------------------------------------------------
>>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>>> index 47d2f6e..ac78b50 100644
>>> --- a/test/javascript/run.tpl
>>> +++ b/test/javascript/run.tpl
>>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>>> JS_TEST_DIR=$SRC_DIR/test/javascript
>>>
>>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>>>
>>> if [ "$#" -eq 0 ];
>>> then
>>> @@ -48,11 +49,15 @@ abort() {
>>> if [ -z $COUCHDB_NO_START ]; then
>>>        make dev
>>>      trap 'abort' 0 1 2 3 4 6 8 15
>>> -    ./utils/run -b -r 1
>>> +    ./utils/run -b -r 1 -n \
>>> +            -a $SRC_DIR/etc/couchdb/default_dev.ini \
>>> +            -a $SRC_DIR/test/random_port.ini \
>>> +            -a $SRC_DIR/etc/couchdb/local_dev.ini
>>
>>
>> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.
>
> … and the -a lines …

Hmm. Maybe it should be "$(abs_top_builddir)" instead of SRC_DIR?
The -a ...random_port.ini is the crucial one, because that's the point
of the patch. I can't remember at this moment why I needed to specify
exactly all the configs and use the -n to reset the config chain, but
I'm sure there was a reason (like random_port.ini not getting
preference over default_dev.ini or something).

-R

Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
On Apr 24, 2012, at 17:05 , Jan Lehnardt wrote:

> 
> On Jan 27, 2012, at 02:37 , randall@apache.org wrote:
> 
>> COUCHDB-1338 - run js tests with port=0
>> 
>> When the JS tests POST to /_restart, the server comes back up on a
>> different port. To work around this, add a getter property for the
>> CouchHTTP.prototype.base_url property, using a reserved slot on the
>> object to store the value.
>> 
>> 
>> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
>> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
>> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
>> 
>> Branch: refs/heads/master
>> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
>> Parents: 257eb52
>> Author: Randall Leeds <ra...@apache.org>
>> Authored: Sat Jan 7 14:21:29 2012 -0800
>> Committer: Randall Leeds <ra...@apache.org>
>> Committed: Thu Jan 26 17:03:10 2012 -0800
>> 
>> ----------------------------------------------------------------------
>> src/couchdb/priv/couch_js/help.h  |    2 +
>> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
>> src/couchdb/priv/couch_js/http.h  |    3 ++
>> src/couchdb/priv/couch_js/sm170.c |    8 ++++
>> src/couchdb/priv/couch_js/sm180.c |    8 ++++
>> src/couchdb/priv/couch_js/sm185.c |    8 ++++
>> src/couchdb/priv/couch_js/util.c  |    3 +-
>> src/couchdb/priv/couch_js/util.h  |    2 +
>> test/Makefile.am                  |    1 +
>> test/etap/Makefile.am             |    1 -
>> test/etap/random_port.ini         |   19 ----------
>> test/etap/test_util.erl.in        |    2 +-
>> test/javascript/Makefile.am       |    1 +
>> test/javascript/couch_http.js     |    9 ++---
>> test/javascript/run.tpl           |    9 ++++-
>> test/random_port.ini              |   19 ++++++++++
>> 16 files changed, 125 insertions(+), 30 deletions(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> [...]
>> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
>> ----------------------------------------------------------------------
>> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
>> index 47d2f6e..ac78b50 100644
>> --- a/test/javascript/run.tpl
>> +++ b/test/javascript/run.tpl
>> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
>> JS_TEST_DIR=$SRC_DIR/test/javascript
>> 
>> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
>> +COUCH_URI_FILE=%localstaterundir%/couch.uri
>> 
>> if [ "$#" -eq 0 ];
>> then
>> @@ -48,11 +49,15 @@ abort() {
>> if [ -z $COUCHDB_NO_START ]; then
>>        make dev
>> 	trap 'abort' 0 1 2 3 4 6 8 15
>> -	./utils/run -b -r 1
>> +	./utils/run -b -r 1 -n \
>> +		-a $SRC_DIR/etc/couchdb/default_dev.ini \
>> +		-a $SRC_DIR/test/random_port.ini \
>> +		-a $SRC_DIR/etc/couchdb/local_dev.ini
> 
> 
> Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.

… and the -a lines …

> 
> To reproduce, just run make distcheck on master. Inside of make distcheck, we'll run make check on a vpath which in turn calls make dev and utils/run in ./test/javascript/run. $SRC_DIR now points to _build/../ instead of of just ./ and thus makes things fail (I think). Either way, removing these lines makes make distcheck work for me. What were the reasons for adding these in the first place?
> 
> Maybe I've gotten in all wrong, but this holds us from getting make distcheck run on the various CI systems :)
> 
> Cheers
> Jan
> -- 
> 
> 
> 
> 
> 
>> 	sleep 1 # give it a sec
>> fi
>> 
>> -$COUCHJS -H \
>> +# start the tests
>> +$COUCHJS -H -u $COUCH_URI_FILE \
>> 	$SCRIPT_DIR/json2.js \
>> 	$SCRIPT_DIR/sha1.js \
>> 	$SCRIPT_DIR/oauth.js \
>> 
> 


Re: [2/7] git commit: COUCHDB-1338 - run js tests with port=0

Posted by Jan Lehnardt <ja...@apache.org>.
On Jan 27, 2012, at 02:37 , randall@apache.org wrote:

> COUCHDB-1338 - run js tests with port=0
> 
> When the JS tests POST to /_restart, the server comes back up on a
> different port. To work around this, add a getter property for the
> CouchHTTP.prototype.base_url property, using a reserved slot on the
> object to store the value.
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d20e7926
> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d20e7926
> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d20e7926
> 
> Branch: refs/heads/master
> Commit: d20e792617db738dd5ad0e046ae847cd740f586f
> Parents: 257eb52
> Author: Randall Leeds <ra...@apache.org>
> Authored: Sat Jan 7 14:21:29 2012 -0800
> Committer: Randall Leeds <ra...@apache.org>
> Committed: Thu Jan 26 17:03:10 2012 -0800
> 
> ----------------------------------------------------------------------
> src/couchdb/priv/couch_js/help.h  |    2 +
> src/couchdb/priv/couch_js/http.c  |   60 +++++++++++++++++++++++++++++++-
> src/couchdb/priv/couch_js/http.h  |    3 ++
> src/couchdb/priv/couch_js/sm170.c |    8 ++++
> src/couchdb/priv/couch_js/sm180.c |    8 ++++
> src/couchdb/priv/couch_js/sm185.c |    8 ++++
> src/couchdb/priv/couch_js/util.c  |    3 +-
> src/couchdb/priv/couch_js/util.h  |    2 +
> test/Makefile.am                  |    1 +
> test/etap/Makefile.am             |    1 -
> test/etap/random_port.ini         |   19 ----------
> test/etap/test_util.erl.in        |    2 +-
> test/javascript/Makefile.am       |    1 +
> test/javascript/couch_http.js     |    9 ++---
> test/javascript/run.tpl           |    9 ++++-
> test/random_port.ini              |   19 ++++++++++
> 16 files changed, 125 insertions(+), 30 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> [...]
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/d20e7926/test/javascript/run.tpl
> ----------------------------------------------------------------------
> diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
> index 47d2f6e..ac78b50 100644
> --- a/test/javascript/run.tpl
> +++ b/test/javascript/run.tpl
> @@ -17,6 +17,7 @@ SCRIPT_DIR=$SRC_DIR/share/www/script
> JS_TEST_DIR=$SRC_DIR/test/javascript
> 
> COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
> +COUCH_URI_FILE=%localstaterundir%/couch.uri
> 
> if [ "$#" -eq 0 ];
> then
> @@ -48,11 +49,15 @@ abort() {
> if [ -z $COUCHDB_NO_START ]; then
>         make dev
> 	trap 'abort' 0 1 2 3 4 6 8 15
> -	./utils/run -b -r 1
> +	./utils/run -b -r 1 -n \
> +		-a $SRC_DIR/etc/couchdb/default_dev.ini \
> +		-a $SRC_DIR/test/random_port.ini \
> +		-a $SRC_DIR/etc/couchdb/local_dev.ini


Randall, this breaks vpath builds. removing the -n option and the -n lines makes it work for me.

To reproduce, just run make distcheck on master. Inside of make distcheck, we'll run make check on a vpath which in turn calls make dev and utils/run in ./test/javascript/run. $SRC_DIR now points to _build/../ instead of of just ./ and thus makes things fail (I think). Either way, removing these lines makes make distcheck work for me. What were the reasons for adding these in the first place?

Maybe I've gotten in all wrong, but this holds us from getting make distcheck run on the various CI systems :)

Cheers
Jan
-- 





> 	sleep 1 # give it a sec
> fi
> 
> -$COUCHJS -H \
> +# start the tests
> +$COUCHJS -H -u $COUCH_URI_FILE \
> 	$SCRIPT_DIR/json2.js \
> 	$SCRIPT_DIR/sha1.js \
> 	$SCRIPT_DIR/oauth.js \
>