couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [couchdb] 11/13: Add test for all_docs partition optimisation
Date Wed, 29 Aug 2018 14:55:42 GMT
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch user-partitioned-dbs-6
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit e80eb7e48ef586b4cf4b8c763ddb4ac0eb90504d
Author: Garren Smith <garren.smith@gmail.com>
AuthorDate: Tue Aug 14 15:43:01 2018 +0200

    Add test for all_docs partition optimisation
    
    Adds tests to validate the all_docs optimisations works for partitions
---
 src/fabric/src/fabric_view_all_docs.erl | 86 +++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/src/fabric/src/fabric_view_all_docs.erl b/src/fabric/src/fabric_view_all_docs.erl
index 83c3790..b12bcde 100644
--- a/src/fabric/src/fabric_view_all_docs.erl
+++ b/src/fabric/src/fabric_view_all_docs.erl
@@ -316,3 +316,89 @@ cancel_read_pids(Pids) ->
         {empty, _} ->
             ok
     end.
+
+-ifdef(TEST).
+
+-include_lib("eunit/include/eunit.hrl").
+
+    shards_for_partition_gets_partitioned_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            start_key = <<"pk:id">>,
+            end_key = <<"pk:idZ">>,
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>, <<"pk:foo">>) ->
[] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+
+    shards_for_no_partition_gets_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            start_key = <<"pk:id">>,
+            end_key = <<"pk:idZ">>,
+            extra = [{partitioned, false}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+    
+    shards_for_different_partitions_gets_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            start_key = <<"pk1:id">>,
+            end_key = <<"pk2:idZ">>,
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+    
+    shards_for_no_startkey_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            end_key = <<"pk:idZ">>,
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+    
+    shards_for_no_endkey_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            start_key = <<"pk:idZ">>,
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+    
+    shards_for_no_keys_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+    
+    shards_for_non_binary_keys_all_shards_test() ->
+        DbName = <<"db">>,
+        Args = #mrargs{
+            start_key = null,
+            end_key = null,
+            extra = [{partitioned, true}]
+        },
+        meck:expect(mem3, shards, fun(<<"db">>) -> [] end),
+        shards(DbName, Args),
+        meck:validate(mem3),
+        meck:unload(mem3).
+
+-endif.


Mime
View raw message