You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/10/29 16:53:31 UTC

[GitHub] janl closed pull request #930: fix(peruser_test): on slow CI vms, we can get Cluster timeouts

janl closed pull request #930: fix(peruser_test): on slow CI vms, we can get Cluster timeouts
URL: https://github.com/apache/couchdb/pull/930
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/couch_peruser/test/couch_peruser_test.erl b/src/couch_peruser/test/couch_peruser_test.erl
index cf6bdf14c3..2bc98af66f 100644
--- a/src/couch_peruser/test/couch_peruser_test.erl
+++ b/src/couch_peruser/test/couch_peruser_test.erl
@@ -42,7 +42,6 @@ setup() ->
     set_config("couch_peruser", "cluster_start_period", "1"),
     set_config("couch_peruser", "enable", "true"),
     set_config("cluster", "n", "1"),
-    set_config("log", "level", "debug"),
     timer:sleep(1000),
     TestAuthDb.
 
@@ -53,7 +52,6 @@ teardown(TestAuthDb) ->
     set_config("couch_peruser", "cluster_quiet_period", "60"),
     set_config("couch_peruser", "cluster_start_period", "5"),
     set_config("cluster", "n", "3"),
-    set_config("log", "level", "info"),
     do_request(delete, get_cluster_base_url() ++ "/" ++ ?b2l(TestAuthDb)),
     do_request(delete, get_base_url() ++ "/" ++ ?b2l(TestAuthDb)),
     lists:foreach(fun (DbName) ->
@@ -128,6 +126,10 @@ all_dbs() ->
     {ok, 200, _, Body} = do_request(get, get_cluster_base_url() ++ "/_all_dbs"),
     jiffy:decode(Body).
 
+all_dbs_with_errors() ->
+    {Result, StatusCode, _Headers, Body} = do_request(get, get_cluster_base_url() ++ "/_all_dbs"),
+    {Result, StatusCode, _Headers, jiffy:decode(Body)}.
+
 get_base_url() ->
     Addr = config:get("httpd", "bind_address", "127.0.0.1"),
     Port = integer_to_list(mochiweb_socket_server:get(couch_httpd, port)),
@@ -316,21 +318,33 @@ should_remove_user_from_db_members(TestAuthDb) ->
 % infinite loop waiting for a db to be created, either this returns true
 % or we get a test timeout error
 wait_for_db_create(UserDbName) ->
-    case lists:member(UserDbName, all_dbs()) of
-        true -> true;
-        _Else ->
+    case all_dbs_with_errors() of
+        {error, _, _ , _} ->
             timer:sleep(?WAIT_FOR_DB_TIMEOUT),
-            wait_for_db_create(UserDbName)
+            wait_for_db_create(UserDbName);
+        {ok, _, _, AllDbs} ->
+            case lists:member(UserDbName, AllDbs) of
+                true -> true;
+                _Else ->
+                    timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+                    wait_for_db_create(UserDbName)
+            end
     end.
 
 % infinite loop waiting for a db to be deleted, either this returns true
 % or we get a test timeout error
 wait_for_db_delete(UserDbName) ->
-    case not lists:member(UserDbName, all_dbs()) of
-        true -> true;
-        _Else ->
+    case all_dbs_with_errors() of
+        {ok, 500, _ , _} ->
             timer:sleep(?WAIT_FOR_DB_TIMEOUT),
-            wait_for_db_delete(UserDbName)
+            wait_for_db_delete(UserDbName);
+        {ok, _, _, AllDbs} ->
+            case not lists:member(UserDbName, AllDbs) of
+                true -> true;
+                _Else ->
+                    timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+                    wait_for_db_delete(UserDbName)
+            end
     end.
 
 wait_for_security_create(Type, User, UserDbName) ->


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services