You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2021/10/27 18:22:56 UTC

[couchdb] 03/04: Use unique ddoc id to prevent collisions

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

jaydoane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 537fd31185142190ff3dc55d707f9d899b455b17
Author: Jay Doane <ja...@apache.org>
AuthorDate: Tue Oct 26 21:24:34 2021 -0700

    Use unique ddoc id to prevent collisions
    
    Prevent failures like this from repeated test runs:
    
        mem3_bdu_test:73: mem3_bdu_shard_doc_test_ (t_design_docs_are_not_validated)...*failed*
    in function mem3_bdu_test:'-t_design_docs_are_not_validated/1-fun-0-'/1 (test/eunit/mem3_bdu_test.erl, line 206)
    in call from mem3_bdu_test:t_design_docs_are_not_validated/1 (test/eunit/mem3_bdu_test.erl, line 206)
    in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
    in call from eunit_proc:run_test/1 (eunit_proc.erl, line 510)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 335)
    in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 493)
    in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 435)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 325)
    **error:{assertEqual,[{module,mem3_bdu_test},
                  {line,206},
                  {expression,"Code"},
                  {expected,201},
                  {value,409}]}
      output:<<"">>
---
 src/mem3/test/eunit/mem3_bdu_test.erl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mem3/test/eunit/mem3_bdu_test.erl b/src/mem3/test/eunit/mem3_bdu_test.erl
index 27d5783..ad047f6 100644
--- a/src/mem3/test/eunit/mem3_bdu_test.erl
+++ b/src/mem3/test/eunit/mem3_bdu_test.erl
@@ -201,12 +201,14 @@ t_by_range_val_not_array({Top, Db, ShardsDb}) ->
 
 
 t_design_docs_are_not_validated({Top, _, ShardsDb}) ->
-    DDoc = #{<<"_id">> => <<"_design/ddoc_bdu_test">>},
+    Suffix = integer_to_list(erlang:system_time() + rand:uniform(1000)),
+    DDocId = list_to_binary("_design/ddoc_bdu_test-" ++ Suffix),
+    DDoc = #{<<"_id">> => DDocId},
     {Code, Res} = req(post, Top ++ ShardsDb, DDoc),
     ?assertEqual(201, Code),
     #{<<"rev">> := Rev} = Res,
     Deleted = #{
-        <<"id">> => <<"_design/ddoc_bdu_test">>,
+        <<"id">> => DDocId,
         <<"_rev">> => Rev,
         <<"_deleted">> => true
     },