couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r927545 - in /couchdb/trunk: share/www/script/couch_tests.js share/www/script/test/reader_acl.js src/couchdb/couch_server_sup.erl
Date Thu, 25 Mar 2010 19:06:52 GMT
Author: jchris
Date: Thu Mar 25 19:06:52 2010
New Revision: 927545

URL: http://svn.apache.org/viewvc?rev=927545&view=rev
Log:
restart using init:restart() for better test reliability

Modified:
    couchdb/trunk/share/www/script/couch_tests.js
    couchdb/trunk/share/www/script/test/reader_acl.js
    couchdb/trunk/src/couchdb/couch_server_sup.erl

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=927545&r1=927544&r2=927545&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Thu Mar 25 19:06:52 2010
@@ -149,6 +149,25 @@ function stringFun(fun) {
   return string;
 }
 
+function waitForRestart() {
+  var waiting = true;
+  while (waiting) {
+    try {
+      CouchDB.request("GET", "/");
+      CouchDB.request("GET", "/");
+      waiting = false;
+    } catch(e) {
+      // the request will fail until restart completes
+    }
+  }
+};
+
 function restartServer() {
-  CouchDB.request("POST", "/_restart");
+  var xhr;
+  try {
+    CouchDB.request("POST", "/_restart");
+  } catch(e) {
+    // this request may sometimes fail
+  }
+  waitForRestart();
 }

Modified: couchdb/trunk/share/www/script/test/reader_acl.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/reader_acl.js?rev=927545&r1=927544&r2=927545&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/reader_acl.js (original)
+++ couchdb/trunk/share/www/script/test/reader_acl.js Thu Mar 25 19:06:52 2010
@@ -28,6 +28,7 @@ couchTests.reader_acl = function(debug) 
         roles : ["top-secret"]
       }, "funnybone");
       T(usersDb.save(jchrisUserDoc).ok);
+      usersDb.ensureFullCommit();
 
       T(CouchDB.session().userCtx.name == null);
 
@@ -41,12 +42,15 @@ couchTests.reader_acl = function(debug) 
           names : ["joe","barb"]
         }
       }).ok);
-      
-      usersDb.ensureFullCommit();
-      // security changes will always commit synchronously
-      restartServer();
-      
-      // can't read it as jchris
+    } finally {
+      CouchDB.logout();
+    }
+  }
+  
+  // split into 2 funs so we can test restart behavior
+  function testFun2() {
+    try {
+      // can't read it as jchris b/c he's missing the needed role
       T(CouchDB.login("jchris@apache.org", "funnybone").ok);
       T(CouchDB.session().userCtx.name == "jchris@apache.org");
 
@@ -151,7 +155,7 @@ couchTests.reader_acl = function(debug) 
     } finally {
       CouchDB.logout();
     }
-  }
+  };
 
   run_on_modified_server(
     [{section: "httpd",
@@ -161,4 +165,16 @@ couchTests.reader_acl = function(debug) 
       key: "authentication_db", value: "test_suite_users"}],
     testFun
   );
+        
+  // security changes will always commit synchronously
+  restartServer();
+  
+  run_on_modified_server(
+    [{section: "httpd",
+      key: "authentication_handlers",
+      value: "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}"},
+     {section: "couch_httpd_auth",
+      key: "authentication_db", value: "test_suite_users"}],
+    testFun2
+  );
 }

Modified: couchdb/trunk/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server_sup.erl?rev=927545&r1=927544&r2=927545&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server_sup.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server_sup.erl Thu Mar 25 19:06:52 2010
@@ -32,12 +32,7 @@ start_link(IniFiles) ->
     end.
 
 restart_core_server() ->
-    supervisor:terminate_child(couch_primary_services, couch_server),
-    supervisor:terminate_child(couch_secondary_services, stats_aggregator),
-    supervisor:terminate_child(couch_secondary_services, stats_collector),
-    supervisor:restart_child(couch_primary_services, couch_server),
-    supervisor:restart_child(couch_secondary_services, stats_collector),
-    supervisor:restart_child(couch_secondary_services, stats_aggregator).
+    init:restart().
 
 couch_config_start_link_wrapper(IniFiles, FirstConfigPid) ->
     case is_process_alive(FirstConfigPid) of



Mime
View raw message