You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/07/24 09:40:05 UTC

[GitHub] janl closed pull request #1463: Clean up replication dbs on exit

janl closed pull request #1463: Clean up replication dbs on exit
URL: https://github.com/apache/couchdb/pull/1463
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index a9e11e5c1b..fed4ca94bf 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -48,6 +48,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     doc = %{"_id" => "doc1"}
     [doc] = save_docs(src_db_name, [doc])
@@ -113,6 +114,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     save_docs(src_db_name, make_docs(1..6))
 
@@ -151,6 +153,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     save_docs(src_db_name, make_docs(1..6))
 
@@ -246,9 +249,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     att1_data = get_att1_data()
     att2_data = get_att2_data()
@@ -561,9 +562,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     docs = make_docs(1..5)
     docs = save_docs(src_db_name, docs)
@@ -611,9 +610,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     docs = make_docs(1..7)
     docs = for doc <- docs do
@@ -673,10 +670,8 @@ defmodule ReplicationTest do
     repl_tgt = tgt_prefix <> tgt_db_name
 
     create_db(src_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    # This is created by the replication
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
+    # tgt_db_name is created by the replication
 
     docs = make_docs(1..2)
     save_docs(src_db_name, docs)
@@ -702,9 +697,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     docs = make_docs(1..30)
     ddoc = %{
@@ -813,9 +806,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     filter_fun_1 = """
       function(doc, req) {
@@ -961,9 +952,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
-
-    on_exit(fn -> delete_db(src_db_name) end)
-    on_exit(fn -> delete_db(tgt_db_name) end)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     docs = make_docs(1..10)
     ddoc = %{
@@ -1163,6 +1152,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     ddoc = %{
       "_id" => "_design/mydesign",
@@ -1377,6 +1367,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     doc = %{"_id" => "foobar"}
     [doc] = save_docs(src_db_name, [doc])
@@ -1424,6 +1415,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     set_security(tgt_db_name, %{
         :admins => %{
@@ -1474,6 +1466,7 @@ defmodule ReplicationTest do
 
     create_db(src_db_name)
     create_db(tgt_db_name)
+    delete_on_exit [src_db_name, tgt_db_name]
 
     set_security(tgt_db_name, %{
         :admins => %{
@@ -1708,4 +1701,12 @@ defmodule ReplicationTest do
     seq = String.replace(seq, ~r/\d+-/, "", global: false)
     :erlang.binary_to_term(Base.url_decode64!(seq, padding: false))
   end
+
+  def delete_on_exit(db_names) when is_list(db_names) do
+    on_exit(fn ->
+      Enum.each(db_names, fn(name) ->
+        delete_db name
+      end)
+    end)
+  end
 end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services