rnewson commented on code in PR #5558:
URL: https://github.com/apache/couchdb/pull/5558#discussion_r2159284262


##########
test/elixir/test/drop_seq_test.exs:
##########
@@ -0,0 +1,248 @@
+defmodule DropSeqTest do
+  use CouchTestCase
+
+  @moduletag :drop_seq
+
+  @tag :with_db
+  test "peer checkpoint - mrview", context do
+    db_name = context[:db_name]
+    ddoc_id = "_design/foo"
+
+    create_checkpoint_fn = fn ->
+      resp = Couch.put("/#{db_name}/#{ddoc_id}", body: %{
+        views: %{
+          bar: %{
+            map: "function(doc) {}"
+          }
+        }
+      })
+      assert resp.status_code == 201
+    end
+
+    update_checkpoint_fn = fn ->
+      assert Couch.get("/#{db_name}/#{ddoc_id}/_view/bar").status_code == 200
+    end
+
+    checkpoint_test_helper(context[:db_name], create_checkpoint_fn, 
update_checkpoint_fn)
+  end
+
+  @tag :with_db
+  test "peer checkpoint - search", context do
+    db_name = context[:db_name]
+    ddoc_id = "_design/foo"
+
+    create_checkpoint_fn = fn ->
+      resp = Couch.put("/#{db_name}/#{ddoc_id}", body: %{
+        indexes: %{
+          bar: %{
+            index: "function(doc) {}"
+          }
+        }
+      })
+      assert resp.status_code == 201
+    end
+
+    update_checkpoint_fn = fn ->
+      assert Couch.get("/#{db_name}/#{ddoc_id}/_search/bar?q=*:*").status_code 
== 200
+    end
+
+    checkpoint_test_helper(context[:db_name], create_checkpoint_fn, 
update_checkpoint_fn)
+  end
+
+  @tag :with_db
+  test "peer checkpoint - nouveau", context do
+    db_name = context[:db_name]
+    ddoc_id = "_design/foo"
+
+    create_checkpoint_fn = fn ->
+      resp = Couch.put("/#{db_name}/#{ddoc_id}", body: %{
+        nouveau: %{
+          bar: %{
+            index: "function(doc) {}"
+          }
+        }
+      })
+      assert resp.status_code == 201
+    end
+
+    update_checkpoint_fn = fn ->
+      # need to add a new document to force nouveau update to run each time
+      # as we only advance the peer checkpoint when JVM-side nouveau has 
committed
+      # the index
+      assert Couch.post("/#{db_name}", body: %{}).status_code == 201
+      assert 
Couch.get("/#{db_name}/#{ddoc_id}/_nouveau/bar?q=*:*").status_code == 200
+    end
+
+    checkpoint_test_helper(context[:db_name], create_checkpoint_fn, 
update_checkpoint_fn)
+  end
+
+  @tag :with_db
+  test "peer checkpoint - custom", context do
+    db_name = context[:db_name]
+    peer_checkpoint_id = "_local/peer-checkpoint-foo"
+
+    update_checkpoint_fn = fn ->
+      resp = Couch.get("/#{db_name}")
+      assert resp.status_code == 200
+      update_seq = resp.body["update_seq"]
+
+      resp = Couch.put("/#{db_name}/#{peer_checkpoint_id}", body: %{
+        update_seq: update_seq
+      })
+      assert resp.status_code == 201
+    end
+
+    checkpoint_test_helper(context[:db_name], update_checkpoint_fn, 
update_checkpoint_fn)
+  end
+
+  @tag :with_db
+  test "peer checkpoint - shard split", context do
+    db_name = context[:db_name]
+    peer_checkpoint_id = "_local/peer-checkpoint-foo"
+
+    create_checkpoint_fn = fn ->
+      resp = Couch.get("/#{db_name}")
+      assert resp.status_code == 200
+      update_seq = resp.body["update_seq"]
+
+      resp = Couch.put("/#{db_name}/#{peer_checkpoint_id}", body: %{
+        update_seq: update_seq
+      })
+      assert resp.status_code == 201
+
+      resp = Couch.get("/#{db_name}/_shards")
+      assert resp.status_code == 200
+      ranges = Map.keys(resp.body["shards"])
+      Enum.each(ranges, fn r ->
+        resp = Couch.post("/_reshard/jobs", body: %{
+          type: "split",
+          db: db_name,
+          range: r
+        })
+        assert resp.status_code == 201
+      end)
+      wait_for_reshard_jobs_to_complete()
+    end
+
+    after_doc_deletion_fn = fn ->
+      split_all_shard_ranges(db_name)
+      wait_for_reshard_jobs_to_complete()

Review Comment:
   no, split_all_shard_ranges calls _reshard/jobs and those jobs run async. 
wait_for_reshard_jobs_to_complete then waits for the reshard jobs to complete. 
;)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to