summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Avdey <eiri@eiri.ca>2017-06-16 15:39:08 -0300
committerGitHub <noreply@github.com>2017-06-16 15:39:08 -0300
commita00d6834ea0f614cc59276b4421bf306feeb4573 (patch)
tree8a07592104b58aef3877aef3dc1cf24d85ab8fb6
parentd3bae3f14062b6957f5daaa7208c4b7ed63154ac (diff)
parent4249ab34c0e7685285685401f7710559e3c77d01 (diff)
downloadcouchdb-a00d6834ea0f614cc59276b4421bf306feeb4573.tar.gz
Merge pull request #600 from cloudant/fix-couchdb_views_tests
Fix race in couchdb_views_tests
-rw-r--r--src/couch/test/couchdb_views_tests.erl15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/couch/test/couchdb_views_tests.erl b/src/couch/test/couchdb_views_tests.erl
index 05a4d98ab..e320b54c6 100644
--- a/src/couch/test/couchdb_views_tests.erl
+++ b/src/couch/test/couchdb_views_tests.erl
@@ -168,7 +168,7 @@ should_not_remember_docs_in_index_after_backup_restore(DbName) ->
?assert(has_doc("doc3", Rows0)),
?assert(has_doc("doc666", Rows0)),
- restore_backup_db_file(DbName),
+ ?assertEqual(ok, restore_backup_db_file(DbName)),
Rows1 = query_view(DbName, "foo", "bar"),
?assert(has_doc("doc1", Rows1)),
@@ -565,14 +565,21 @@ backup_db_file(DbName) ->
restore_backup_db_file(DbName) ->
DbDir = config:get("couchdb", "database_dir"),
- {ok, Db} = couch_db:open_int(DbName, []),
+ {ok, #db{main_pid = UpdaterPid} = Db} = couch_db:open_int(DbName, []),
ok = couch_db:close(Db),
- exit(Db#db.main_pid, shutdown),
+ exit(UpdaterPid, shutdown),
DbFile = filename:join([DbDir, ?b2l(DbName) ++ ".couch"]),
ok = file:delete(DbFile),
ok = file:rename(DbFile ++ ".backup", DbFile),
- ok.
+
+ test_util:wait(fun() ->
+ case couch_server:open(DbName, [{timeout, ?TIMEOUT}]) of
+ {ok, #db{main_pid = UpdaterPid}} -> wait;
+ {ok, _} -> ok;
+ Else -> Else
+ end
+ end, ?TIMEOUT, ?DELAY).
compact_db(DbName) ->
{ok, Db} = couch_db:open_int(DbName, []),