Skip to content

Commit e301500

Browse files
author
Andy Till
authored
Merge pull request #1237 from basho/at-wait-for-webmachine
Wait for Webmachine to be up before running tests
2 parents a7fa32c + 55c787a commit e301500

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/ts_simple_http_api_SUITE.erl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ init_per_suite(Config) ->
3838
[Node|_] = Cluster = ts_setup:start_cluster(1),
3939
rt:wait_until_pingable(Node),
4040
rt:wait_for_service(Node, riak_kv),
41-
[{cluster, Cluster} | Config].
41+
Cfg = [{cluster, Cluster} | Config],
42+
ok = wait_for_web_machine(60, Cfg),
43+
Cfg.
4244

4345
end_per_suite(_Config) ->
4446
ok.
@@ -89,6 +91,17 @@ all() ->
8991
%% column_names_def_1() ->
9092
%% [<<"a">>, <<"b">>, <<"c">>].
9193

94+
wait_for_web_machine(Secs, _) when Secs =< 0 ->
95+
{error, "Webmachine not ready in time."};
96+
wait_for_web_machine(Secs, Cfg) ->
97+
%% use SHOW TABLES to detect readiness because it does not modify state
98+
case execute_query("SHOW TABLES", Cfg) of
99+
{ok, "200", _, _} ->
100+
ok;
101+
{ok, "503", _, _} ->
102+
timer:sleep(1000),
103+
wait_for_web_machine(Secs-1, Cfg)
104+
end.
92105

93106
table_def_bob() ->
94107
"create table bob ("

0 commit comments

Comments
 (0)