You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/11/10 20:11:41 UTC

[couchdb] 03/03: Fix flaky test

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 1a138804f692d0e578a7d4a19f9f13099a59a1cd
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Nov 10 12:46:07 2020 -0600

    Fix flaky test
    
    Waiting for the timeout option to be set means we could still sneak in
    and grab the old FDB database handle before fabric2_server updated it in
    the application environment.
    
    This new approach just waits until the handle has been updated by
    watching the value in the application environment directly.
---
 src/fabric/test/fabric2_tx_options_tests.erl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/fabric/test/fabric2_tx_options_tests.erl b/src/fabric/test/fabric2_tx_options_tests.erl
index b93cc3d..3232922 100644
--- a/src/fabric/test/fabric2_tx_options_tests.erl
+++ b/src/fabric/test/fabric2_tx_options_tests.erl
@@ -84,9 +84,15 @@ can_configure_options_at_runtime(_) ->
 
     meck:reset(erlfdb),
 
+    % Wait until after fabric2_server has updated the new fdb handle
+    OldDbHandle = get(?PDICT_DB_KEY),
     config:delete("fdb_tx_options", "size_limit", false),
-    % Assert that we get a new handle and are setting our default values
-    meck:wait(erlfdb, set_option, ['_', timeout, '_'], 4000),
+    test_util:wait(fun() ->
+        case application:get_env(fabric, db) of
+            {ok, OldDbHandle} -> wait;
+            {ok, _} -> ok
+        end
+    end),
     erase(?PDICT_DB_KEY),
 
     {ok, Db1} = fabric2_db:open(DbName, [?ADMIN_CTX]),