You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/07/28 20:34:00 UTC

[couchdb] branch prototype/fdb-layer updated: Use _scheduler/jobs instead of _active_tasks in replication Elixir tests

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

vatamane pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
     new 77e1c8c  Use _scheduler/jobs instead of _active_tasks in replication Elixir tests
77e1c8c is described below

commit 77e1c8c2bc93e07f2508ef4fb8dd7476ccd59425
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Jul 28 16:10:05 2020 -0400

    Use _scheduler/jobs instead of _active_tasks in replication Elixir tests
    
    After _active_tasks was implemented on FDB, single-node (previous)
    _active_tasks implementation, had stopped working. It turns out were were
    relying on it to run Elixir replication tests.
    
    To not lose test coverage, and before we implement replicator on FDB, switch
    the tests to use `_scheduler/jobs`.
---
 test/elixir/test/replication_test.exs | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index 78f3660..8b657d9 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -127,7 +127,7 @@ defmodule ReplicationTest do
     task = get_task(repl_id, 3_000)
     assert is_map(task)
 
-    assert task["replication_id"] == repl_id
+    assert task["id"] == repl_id
 
     repl_body = %{
       "replication_id" => repl_id,
@@ -1749,8 +1749,13 @@ defmodule ReplicationTest do
 
   def wait_for_repl(src_db_name, repl_id, expect_revs_checked, wait_left) do
     task = get_task(repl_id, 0)
-    through_seq = task["through_seq"] || "0"
-    revs_checked = task["revisions_checked"]
+    info = if task["info"] == :null do
+        %{"through_seq" => "0", "revisions_checked" => "0"}
+    else
+        task["info"]
+    end
+    through_seq = info["through_seq"] || "0"
+    revs_checked = info["revisions_checked"] || "0"
     changes = get_db_changes(src_db_name, %{:since => through_seq})
 
     if length(changes["results"]) > 0 or revs_checked < expect_revs_checked do
@@ -1799,13 +1804,14 @@ defmodule ReplicationTest do
   end
 
   def try_get_task(repl_id) do
-    resp = Couch.get("/_active_tasks")
-    assert HTTPotion.Response.success?(resp)
-    assert is_list(resp.body)
+    resp = Couch.get("/_scheduler/jobs/#{repl_id}")
 
-    Enum.find(resp.body, nil, fn task ->
-      task["replication_id"] == repl_id
-    end)
+    if HTTPotion.Response.success?(resp) do
+        assert is_map(resp.body)
+        resp.body
+    else
+        nil
+    end
   end
 
   def set_user(uri, userinfo) do