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
commit 94fbdc9806b84591c39b3fd94a954f07d324fed1 Author: Robert Newson <[email protected]> AuthorDate: Thu May 29 23:42:01 2025 +0100 split shards in proper --- Makefile | 1 - test/elixir/test/drop_seq_statem_test.exs | 37 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 317188fe0..58076a31b 100644 --- a/Makefile +++ b/Makefile @@ -257,7 +257,6 @@ elixir-cluster-with-quorum: elixir-init devclean .PHONY: elixir-cluster elixir-cluster: export MIX_ENV=integration elixir-cluster: elixir-init devclean -# @rm -f _build/propcheck.ctex @dev/run -n 3 -q -a adm:pass \ --no-eval 'mix test --trace --only with_cluster $(EXUNIT_OPTS)' diff --git a/test/elixir/test/drop_seq_statem_test.exs b/test/elixir/test/drop_seq_statem_test.exs index 631fac3a5..1e67cc3a7 100644 --- a/test/elixir/test/drop_seq_statem_test.exs +++ b/test/elixir/test/drop_seq_statem_test.exs @@ -64,7 +64,8 @@ defmodule DropSeqStateM do {:call, __MODULE__, :update_peer_checkpoint, [{:var, :dbname}]}, {:call, __MODULE__, :update_drop_seq, [{:var, :dbname}]}, {:call, __MODULE__, :compact_db, [{:var, :dbname}]}, - {:call, __MODULE__, :changes, [{:var, :dbname}]} + {:call, __MODULE__, :changes, [{:var, :dbname}]}, + {:call, __MODULE__, :split_shard, [{:var, :dbname}]} ]) end @@ -150,6 +151,36 @@ defmodule DropSeqStateM do end) end + def split_shard(db_name) do + resp = Couch.get("/#{db_name}/_shards") + assert resp.status_code == 200 + range = Enum.random(Map.keys(resp.body["shards"])) + + resp = + Couch.post("/_reshard/jobs", + body: %{ + type: "split", + db: db_name, + range: range + } + ) + + assert resp.status_code == 201 + + retry_until( + fn -> + resp = Couch.get("/_reshard/jobs") + assert resp.status_code == 200 + + Enum.all?(resp.body["jobs"], fn job -> + job["job_state"] == "completed" + end) + end, + 200, + 10_000 + ) + end + def sync_shards(db_name) do resp = Couch.post("/#{db_name}/_sync_shards") assert resp.status_code == 202 @@ -217,6 +248,10 @@ defmodule DropSeqStateM do s end + def next_state(s, _v, {:call, _, :split_shard, [_db_name]}) do + s + end + def postcondition(s, {:call, _, :changes, [_db_name]}, {doc_ids, del_doc_ids}) do doc_ids == doc_ids(s) and del_doc_ids == deleted_doc_ids(s) end
