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

rnewson pushed a commit to branch auto-delete-3
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/auto-delete-3 by this push:
     new 4aa64f2d9 extract functional parts of algorithm to aid testing
4aa64f2d9 is described below

commit 4aa64f2d9200d543a981129537a6af46d6d95ecb
Author: Robert Newson <[email protected]>
AuthorDate: Fri May 9 11:16:07 2025 +0100

    extract functional parts of algorithm to aid testing
---
 src/fabric/src/fabric_drop_seq.erl | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/fabric/src/fabric_drop_seq.erl 
b/src/fabric/src/fabric_drop_seq.erl
index 333031185..c322561fe 100644
--- a/src/fabric/src/fabric_drop_seq.erl
+++ b/src/fabric/src/fabric_drop_seq.erl
@@ -33,11 +33,9 @@
 
 go(DbName) ->
     Shards0 = mem3:shards(DbName),
-    {ok, PeerCheckpoints0} = get_peer_checkpoint_docs(DbName),
-    PeerCheckpoints1 = substitute_splits(Shards0, PeerCheckpoints0),
+    {ok, PeerCheckpoints} = get_peer_checkpoint_docs(DbName),
     {ok, ShardSyncHistory} = get_all_shard_sync_docs(Shards0),
-    Shards1 = fully_replicated_shards_only(Shards0, ShardSyncHistory),
-    DropSeqs = calculate_drop_seqs(PeerCheckpoints1, ShardSyncHistory),
+    {Shards1, DropSeqs} = go_int(Shards0, PeerCheckpoints, ShardSyncHistory),
     Workers = lists:filtermap(
         fun(Shard) ->
             #shard{range = Range, node = Node, name = ShardName} = Shard,
@@ -83,6 +81,12 @@ go(DbName) ->
             end
     end.
 
+go_int(Shards, PeerCheckpoints, ShardSyncHistory) ->
+    {
+        fully_replicated_shards_only(Shards, ShardSyncHistory),
+        calculate_drop_seqs(substitute_splits(Shards, PeerCheckpoints), 
ShardSyncHistory)
+    }.
+
 -spec calculate_drop_seqs(peer_checkpoints(), shard_sync_history()) -> 
peer_checkpoints().
 calculate_drop_seqs(PeerCheckpoints0, ShardSyncHistory) ->
     ShardSyncCheckpoints = latest_shard_sync_checkpoints(ShardSyncHistory),
@@ -684,4 +688,19 @@ substitute_splits_test() ->
         substitute_splits(Shards, PeerCheckpoints)
     ).
 
+go_int_test() ->
+    Range = [0, 10],
+    Subrange1 = [0, 5],
+    Subrange2 = [6, 10],
+    Node1 = '[email protected]',
+    Shards = [#shard{range = Subrange1, node = Node1}, #shard{range = 
Subrange2, node = Node1}],
+    PeerCheckpoints = #{{Range, Node1} => {<<"uuid1">>, 12}},
+    ShardSyncHistory = #{},
+    ?assertEqual(
+        {Shards, #{
+            {Subrange1, Node1} => {<<"uuid1">>, 12}, {Subrange2, Node1} => 
{<<"uuid1">>, 12}
+        }},
+        go_int(Shards, PeerCheckpoints, ShardSyncHistory)
+    ).
+
 -endif.

Reply via email to