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

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

commit 54b2301c51d33282dbc792dd0b89efdeb3306a32
Author: Robert Newson <[email protected]>
AuthorDate: Tue Jun 24 15:31:06 2025 +0100

    add delete_peer_checkpoint command
---
 test/elixir/test/drop_seq_statem_test.exs | 83 ++++++++++++++++++++-----------
 1 file changed, 54 insertions(+), 29 deletions(-)

diff --git a/test/elixir/test/drop_seq_statem_test.exs 
b/test/elixir/test/drop_seq_statem_test.exs
index b6aceeed4..657098bfb 100644
--- a/test/elixir/test/drop_seq_statem_test.exs
+++ b/test/elixir/test/drop_seq_statem_test.exs
@@ -88,6 +88,11 @@ defmodule DropSeqStateM do
           EOF
           """)
 
+        {:set, _var, {:call, __MODULE__, :delete_peer_checkpoint, [_dbname]}} 
->
+          IO.puts("""
+          curl --fail -X DELETE "#{db_url}/_local/peer-checkpoint-foo"
+          """)
+
         {:set, _var, {:call, __MODULE__, :split_shard, [_dbname]}} ->
           IO.puts("""
           RANGE=$(curl --fail -X GET "#{db_url}/_shards" | jq -r '.shards | 
keys[]' | shuf -n 1)
@@ -183,37 +188,39 @@ defmodule DropSeqStateM do
         {:call, __MODULE__, :check_actual_state, [{:var, :dbname}]}
 
       %State{} ->
-        base_cmds = [
-          {10, {:call, __MODULE__, :update_document, [{:var, :dbname}, 
doc_id()]}},
-          {10, {:call, __MODULE__, :update_peer_checkpoint, [{:var, 
:dbname}]}},
-          {10, {:call, __MODULE__, :compact_db, [{:var, :dbname}]}},
-          {5, {:call, __MODULE__, :split_shard, [{:var, :dbname}]}},
-          {1, {:call, __MODULE__, :create_index, [{:var, :dbname}, 
index_type()]}},
-          {5, {:call, __MODULE__, :update_indexes, [{:var, :dbname}]}}
-        ]
-
-        cond do
-          s.docs == [] and s.deleted_docs == [] ->
-            frequency(base_cmds)
-
-          s.docs != [] ->
-            frequency(
-              base_cmds ++
-                [
+        # repro's restrictions in precondition function as runs fail with
+        # "Precondition failed" if propcheck chooses a command that fails the
+        # precondition instead of generating a new one like the docs say it 
should
+        # clearly I'm doing something wrong to make this crap necessary. fix 
me.
+        frequency(
+          [
+            {10, {:call, __MODULE__, :update_document, [{:var, :dbname}, 
doc_id()]}},
+            {10, {:call, __MODULE__, :update_peer_checkpoint, [{:var, 
:dbname}]}},
+            {10, {:call, __MODULE__, :compact_db, [{:var, :dbname}]}},
+            {5, {:call, __MODULE__, :split_shard, [{:var, :dbname}]}},
+            {1, {:call, __MODULE__, :create_index, [{:var, :dbname}, 
index_type()]}},
+            {5, {:call, __MODULE__, :update_indexes, [{:var, :dbname}]}}
+          ] ++
+            for cmd <- [
                   {10,
-                   {:call, __MODULE__, :delete_document, [{:var, :dbname}, 
doc_id(s)]}},
-                  {10, {:call, __MODULE__, :update_drop_seq, [{:var, 
:dbname}]}}
-                ]
-            )
-
-          true ->
-            frequency(
-              base_cmds ++
-                [
+                   {:call, __MODULE__, :delete_document, [{:var, :dbname}, 
doc_id(s)]}}
+                ],
+                s.docs != [] do
+              cmd
+            end ++
+            for cmd <- [
                   {10, {:call, __MODULE__, :update_drop_seq, [{:var, 
:dbname}]}}
-                ]
-            )
-        end
+                ],
+                s.docs != [] or s.deleted_docs != [] do
+              cmd
+            end ++
+            for cmd <- [
+                  {10, {:call, __MODULE__, :delete_peer_checkpoint, [{:var, 
:dbname}]}}
+                ],
+                s.peer_checkpoint_seq != nil do
+              cmd
+            end
+        )
     end
   end
 
@@ -285,6 +292,12 @@ defmodule DropSeqStateM do
     seq_to_shards(update_seq)
   end
 
+  def delete_peer_checkpoint(db_name) do
+    resp = Couch.delete("/#{db_name}/_local/peer-checkpoint-foo")
+    assert resp.status_code == 200
+    wait_for_internal_replication(db_name)
+  end
+
   def update_drop_seq(db_name) do
     resp = Couch.post("/#{db_name}/_update_drop_seq")
 
@@ -462,6 +475,10 @@ defmodule DropSeqStateM do
     s.index_seq != nil
   end
 
+  def precondition(s, {:call, _, :delete_peer_checkpoint, [_db_name]}) do
+    s.peer_checkpoint_seq != nil
+  end
+
   def precondition(_, _) do
     true
   end
@@ -494,6 +511,14 @@ defmodule DropSeqStateM do
     }
   end
 
+  def next_state(s, _v, {:call, _, :delete_peer_checkpoint, [_db_name]}) do
+    %State{
+      s
+      | peer_checkpoint_seq: nil,
+        check_actual_state: true
+    }
+  end
+
   def next_state(s, _v, {:call, _, :update_drop_seq, [_db_name]}) do
     drop_seq =
       cond do

Reply via email to