aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/inets/test')
-rw-r--r--lib/inets/test/Makefile2
-rw-r--r--lib/inets/test/httpd_SUITE.erl144
-rw-r--r--lib/inets/test/httpd_block.erl35
-rw-r--r--lib/inets/test/httpd_test_lib.erl16
-rw-r--r--lib/inets/test/inets_sup_SUITE.erl7
-rw-r--r--lib/inets/test/inets_test_lib.erl6
-rw-r--r--lib/inets/test/old_httpd_SUITE.erl2
7 files changed, 163 insertions, 49 deletions
diff --git a/lib/inets/test/Makefile b/lib/inets/test/Makefile
index 349164792e..c156b34406 100644
--- a/lib/inets/test/Makefile
+++ b/lib/inets/test/Makefile
@@ -203,7 +203,7 @@ INETS_FILES = inets.config $(INETS_SPECS)
# inets_tftp_suite
INETS_DATADIRS = inets_SUITE_data inets_sup_SUITE_data
-HTTPD_DATADIRS = httpd_test_data httpd_SUITE_data httpd_basic_SUITE_data
+HTTPD_DATADIRS = httpd_test_data httpd_SUITE_data httpd_basic_SUITE_data old_httpd_SUITE_data
HTTPC_DATADIRS = httpc_SUITE_data httpc_proxy_SUITE_data
FTP_DATADIRS = ftp_SUITE_data
diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl
index 7864bc7bdd..34d701eb26 100644
--- a/lib/inets/test/httpd_SUITE.erl
+++ b/lib/inets/test/httpd_SUITE.erl
@@ -31,6 +31,9 @@
%% Note: This directive should only be used in test suites.
-compile(export_all).
+-record(httpd_user, {user_name, password, user_data}).
+-record(httpd_group, {group_name, userlist}).
+
%%--------------------------------------------------------------------
%% Common Test interface functions -----------------------------------
%%--------------------------------------------------------------------
@@ -47,7 +50,8 @@ groups() ->
[
{http, [], all_groups()},
%{https, [], all_groups()},
- {http_1_1, [], [host, chunked, expect, cgi] ++ http_head() ++ http_get()},
+ {http_1_1, [], [host, chunked, expect, cgi, max_clients
+ ] ++ http_head() ++ http_get()},
{http_1_0, [], [host, cgi] ++ http_head() ++ http_get()},
{http_0_9, [], http_head() ++ http_get()}
].
@@ -61,7 +65,9 @@ all_groups ()->
http_head() ->
[head].
http_get() ->
- [alias, get, basic_auth, esi, ssi].
+ [alias, get,
+ basic_auth,
+ esi, ssi].
init_per_suite(Config) ->
PrivDir = ?config(priv_dir, Config),
@@ -99,14 +105,21 @@ init_per_group(http_0_9, Config) ->
[{http_version, "HTTP/0.9"} | Config];
init_per_group(_, Config) ->
Config.
-end_per_group(_, _Config) ->
+end_per_group(http, _Config) ->
+ inets:stop();
+end_per_group(https, _Config) ->
+ ssl:stop(),
+ inets:stop();
+end_per_group(_, _) ->
ok.
+
init_httpd(Group, Config0) ->
- Config = proplists:delete(port, Config0),
- Port = server_start(Group, server_config(Group, Config)),
- [{port, Port} | Config].
+ Config1 = proplists:delete(port, Config0),
+ Config = proplists:delete(server_pid, Config1),
+ {Pid, Port} = server_start(Group, server_config(Group, Config)),
+ [{server_pid, Pid}, {port, Port} | Config].
%%--------------------------------------------------------------------
-init_per_testcase(host, Config) ->
+init_per_testcase(host = Case, Config) ->
Prop = ?config(tc_group_properties, Config),
Name = proplists:get_value(name, Prop),
Cb = case Name of
@@ -115,11 +128,47 @@ init_per_testcase(host, Config) ->
http_1_1 ->
httpd_1_1
end,
- [{version_cb, Cb} | proplists:delete(version_cb, Config)];
+ common_init_per_test_case(Case, [{version_cb, Cb} | proplists:delete(version_cb, Config)]);
-init_per_testcase(_Case, Config) ->
- Config.
+%% init_per_testcase(basic_auth = Case, Config) ->
+%% start_mnesia(?config(node, Config)),
+%% common_init_per_test_case(Case, Config);
+
+init_per_testcase(max_clients, Config) ->
+ Pid = ?config(server_pid, Config),
+ Prop = httpd:info(Pid),
+ Port = proplists:get_value(port, Prop),
+ TempProp = [{port, Port} | proplists:delete(port, server_config(http, Config))],
+ NewProp = [{max_clients, 1} | TempProp],
+ httpd:reload_config(NewProp, non_disturbing),
+ Config;
+init_per_testcase(_Case, Config) ->
+ common_init_per_test_case(_Case, Config).
+
+%%% Should be run by all test cases except max_clients, to make
+%%% sure failiure of max_clients does not affect other test cases
+common_init_per_test_case(_Case, Config) ->
+ Pid = ?config(server_pid, Config),
+ Prop = httpd:info(Pid),
+ case proplists:get_value(max_clients, Prop, 150) of
+ 150 ->
+ Config;
+ _ ->
+ end_per_testcase(max_clients, Config)
+ end.
+
+end_per_testcase(max_clients, Config) ->
+ Pid = ?config(server_pid, Config),
+ Prop = httpd:info(Pid),
+ Port = proplists:get_value(port, Prop),
+ TempProp = [{port, Port} | proplists:delete(port, server_config(http, Config))],
+ NewProp = proplists:delete(max_clients, TempProp),
+ httpd:reload_config(NewProp, non_disturbing),
+ Config;
+
+%% end_per_testcase(basic_auth, Config) ->
+%% cleanup_mnesia();
end_per_testcase(_Case, _Config) ->
ok.
@@ -185,7 +234,7 @@ basic_auth(Config) ->
Config, [{statuscode, 200}]),
%% Authentication still required!
basic_auth_requiered(Config).
-
+
ssi() ->
[{doc, "HTTP GET server side include test"}].
ssi(Config) when is_list(Config) ->
@@ -221,6 +270,35 @@ expect(Config) when is_list(Config) ->
httpd_1_1:expect(?config(type, Config), ?config(port, Config),
?config(host, Config), ?config(node, Config)).
+max_clients() ->
+ [{doc, "Test max clients limit"}].
+
+max_clients(Config) when is_list(Config) ->
+ Version = ?config(http_version, Config),
+ Host = ?config(host, Config),
+ Pid = ?config(server_pid, Config),
+ ct:pal("Configurartion: ~p~n", [httpd:info(Pid)]),
+ spawn(fun() -> httpd_test_lib:verify_request(?config(type, Config), Host,
+ ?config(port, Config), ?config(node, Config),
+ http_request("GET /eval?httpd_example:delay(1000) ",
+ Version, Host),
+ [{statuscode, 200},
+ {version, Version}])
+ end),
+ ok = httpd_test_lib:verify_request(?config(type, Config), Host,
+ ?config(port, Config), ?config(node, Config),
+ http_request("GET /index.html ", Version, Host),
+ [{statuscode, 503},
+ {version, Version}]),
+ receive
+ after 1000 ->
+ ok = httpd_test_lib:verify_request(?config(type, Config), Host,
+ ?config(port, Config), ?config(node, Config),
+ http_request("GET /index.html ", Version, Host),
+ [{statuscode, 200},
+ {version, Version}])
+ end.
+
esi() ->
[{doc, "Test mod_esi"}].
@@ -559,7 +637,7 @@ server_start(_, HttpdConfig) ->
{ok, Pid} = inets:start(httpd, HttpdConfig),
Serv = inets:services_info(),
{value, {_, _, Info}} = lists:keysearch(Pid, 2, Serv),
- proplists:get_value(port, Info).
+ {Pid, proplists:get_value(port, Info)}.
server_config(http, Config) ->
ServerRoot = ?config(server_root, Config),
@@ -668,12 +746,48 @@ auth_status(AuthRequest, Config, Expected) ->
Expected ++ [{version, Version}]).
basic_auth_requiered(Config) ->
- ok = http_status("GET /secret/dummy.html ", Config, [{statuscode, 401},
- {header, "WWW-Authenticate"}]),
ok = http_status("GET /open/ ", Config, [{statuscode, 401},
{header, "WWW-Authenticate"}]),
ok = http_status("GET /secret/ ", Config, [{statuscode, 401},
{header, "WWW-Authenticate"}]),
- ok = http_status("GET /secret/top_secret ", Config, [{statuscode, 401},
+ ok = http_status("GET /secret/top_secret/ ", Config, [{statuscode, 401},
{header, "WWW-Authenticate"}]).
+start_mnesia(Node) ->
+ case rpc:call(Node, ?MODULE, cleanup_mnesia, []) of
+ ok ->
+ ok;
+ Other ->
+ ct:fail({failed_to_cleanup_mnesia, Other})
+ end,
+ case rpc:call(Node, ?MODULE, setup_mnesia, []) of
+ {atomic, ok} ->
+ ok;
+ Other2 ->
+ ct:fail({failed_to_setup_mnesia, Other2})
+ end,
+ ok.
+
+setup_mnesia() ->
+ setup_mnesia([node()]).
+
+setup_mnesia(Nodes) ->
+ ok = mnesia:create_schema(Nodes),
+ ok = mnesia:start(),
+ {atomic, ok} = mnesia:create_table(httpd_user,
+ [{attributes,
+ record_info(fields, httpd_user)},
+ {disc_copies,Nodes}, {type, set}]),
+ {atomic, ok} = mnesia:create_table(httpd_group,
+ [{attributes,
+ record_info(fields,
+ httpd_group)},
+ {disc_copies,Nodes}, {type,bag}]).
+
+cleanup_mnesia() ->
+ mnesia:start(),
+ mnesia:delete_table(httpd_user),
+ mnesia:delete_table(httpd_group),
+ stopped = mnesia:stop(),
+ mnesia:delete_schema([node()]),
+ ok.
diff --git a/lib/inets/test/httpd_block.erl b/lib/inets/test/httpd_block.erl
index 2f56096f75..706d014bda 100644
--- a/lib/inets/test/httpd_block.erl
+++ b/lib/inets/test/httpd_block.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2013. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -19,8 +19,7 @@
%%
-module(httpd_block).
--include("test_server.hrl").
--include("test_server_line.hrl").
+-include_lib("common_test/include/ct.hrl").
%% General testcases bodies called from httpd_SUITE
-export([block_disturbing_idle/4, block_non_disturbing_idle/4,
@@ -88,7 +87,7 @@ block_503(Type, Port, Host, Node) ->
block_disturbing_active(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Pid = long_poll(Type, Host, Port, Node, 200, 60000),
- test_server:sleep(15000),
+ ct:sleep(15000),
block_server(Node, Host, Port),
await_suite_failed_process_exit(Pid, "poller", 60000,
connection_closed),
@@ -100,7 +99,7 @@ block_disturbing_active(Type, Port, Host, Node) ->
block_non_disturbing_active(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 60000),
- test_server:sleep(15000),
+ ct:sleep(15000),
ok = block_nd_server(Node, Host, Port),
await_normal_process_exit(Poller, "poller", 60000),
blocked = get_admin_state(Node, Host, Port),
@@ -111,7 +110,7 @@ block_non_disturbing_active(Type, Port, Host, Node) ->
block_disturbing_active_timeout_not_released(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 60000),
- test_server:sleep(15000),
+ ct:sleep(15000),
Blocker = blocker(Node, Host, Port, 50000),
await_normal_process_exit(Blocker, "blocker", 50000),
await_normal_process_exit(Poller, "poller", 30000),
@@ -123,7 +122,7 @@ block_disturbing_active_timeout_not_released(Type, Port, Host, Node) ->
block_disturbing_active_timeout_released(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 40000),
- test_server:sleep(5000),
+ ct:sleep(5000),
Blocker = blocker(Node, Host, Port, 10000),
await_normal_process_exit(Blocker, "blocker", 15000),
await_suite_failed_process_exit(Poller, "poller", 40000,
@@ -146,7 +145,7 @@ block_non_disturbing_active_timeout_not_released(Type, Port, Host, Node) ->
block_non_disturbing_active_timeout_released(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 45000),
- test_server:sleep(5000),
+ ct:sleep(5000),
Blocker = blocker_nd(Node, Host, Port ,10000, {error,timeout}),
await_normal_process_exit(Blocker, "blocker", 15000),
await_normal_process_exit(Poller, "poller", 50000),
@@ -157,9 +156,9 @@ block_non_disturbing_active_timeout_released(Type, Port, Host, Node) ->
disturbing_blocker_dies(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 60000),
- test_server:sleep(5000),
+ ct:sleep(5000),
Blocker = blocker(Node, Host, Port, 10000),
- test_server:sleep(5000),
+ ct:sleep(5000),
exit(Blocker,simulate_blocker_crash),
await_normal_process_exit(Poller, "poller", 60000),
unblocked = get_admin_state(Node, Host, Port),
@@ -170,9 +169,9 @@ disturbing_blocker_dies(Type, Port, Host, Node) ->
non_disturbing_blocker_dies(Type, Port, Host, Node) ->
process_flag(trap_exit, true),
Poller = long_poll(Type, Host, Port, Node, 200, 60000),
- test_server:sleep(5000),
+ ct:sleep(5000),
Blocker = blocker_nd(Node, Host, Port, 10000, ok),
- test_server:sleep(5000),
+ ct:sleep(5000),
exit(Blocker, simulate_blocker_crash),
await_normal_process_exit(Poller, "poller", 60000),
unblocked = get_admin_state(Node, Host, Port),
@@ -326,15 +325,15 @@ await_normal_process_exit(Pid, Name, Timeout) ->
io_lib:format("expected normal exit, "
"unexpected exit of ~s process: ~p",
[Name, Reason])),
- test_server:fail(Err)
+ ct:fail(Err)
after Timeout ->
- test_server:fail("timeout while waiting for " ++ Name)
+ ct:fail("timeout while waiting for " ++ Name)
end.
await_suite_failed_process_exit(Pid, Name, Timeout, Why) ->
receive
- {'EXIT', Pid, {suite_failed, Why}} ->
+ {'EXIT', Pid, {test_failed, Why}} ->
ok;
{'EXIT', Pid, Reason} ->
Err =
@@ -342,9 +341,9 @@ await_suite_failed_process_exit(Pid, Name, Timeout, Why) ->
io_lib:format("expected connection_closed, "
"unexpected exit of ~s process: ~p",
[Name, Reason])),
- test_server:fail(Err)
+ ct:fail(Err)
after Timeout ->
- test_server:fail("timeout while waiting for " ++ Name)
+ ct:fail("timeout while waiting for " ++ Name)
end.
long_poll(Type, Host, Port, Node, StatusCode, Timeout) ->
@@ -362,7 +361,7 @@ do_long_poll(Type, Host, Port, Node, StatusCode, Timeout) ->
ok ->
exit(normal);
Reason ->
- test_server:fail(Reason)
+ exit({test_failed, Reason})
end.
diff --git a/lib/inets/test/httpd_test_lib.erl b/lib/inets/test/httpd_test_lib.erl
index 3e82324a30..6406eeae79 100644
--- a/lib/inets/test/httpd_test_lib.erl
+++ b/lib/inets/test/httpd_test_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2001-2013. All Rights Reserved.
+%% Copyright Ericsson AB 2001-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -187,12 +187,12 @@ request(#state{mfa = {Module, Function, Args},
{tcp_closed, Socket} ->
io:format("~p ~w[~w]request -> received (tcp) closed"
"~n", [self(), ?MODULE, ?LINE]),
- test_server:fail(connection_closed);
+ exit({test_failed, connection_closed});
{tcp_error, Socket, Reason} ->
io:format("~p ~w[~w]request -> received (tcp) error"
"~n Reason: ~p"
"~n", [self(), ?MODULE, ?LINE, Reason]),
- test_server:fail({tcp_error, Reason});
+ ct:fail({tcp_error, Reason});
{ssl, Socket, Data} ->
print(ssl, Data, State),
case Module:Function([Data | Args]) of
@@ -207,13 +207,13 @@ request(#state{mfa = {Module, Function, Args},
print(ssl, "closed", State),
State#state{body = hd(Args)};
{ssl_closed, Socket} ->
- test_server:fail(connection_closed);
+ exit({test_failed, connection_closed});
{ssl_error, Socket, Reason} ->
- test_server:fail({ssl_error, Reason})
+ ct:fail({ssl_error, Reason})
after TimeOut ->
io:format("~p ~w[~w]request -> timeout"
"~n", [self(), ?MODULE, ?LINE]),
- test_server:fail(connection_timed_out)
+ ct:fail(connection_timed_out)
end.
handle_http_msg({Version, StatusCode, ReasonPharse, Headers, Body},
@@ -277,7 +277,7 @@ handle_http_body(Body, State = #state{headers = Headers,
request(State#state{mfa = MFA}, 5000)
end;
false ->
- test_server:fail(body_too_big)
+ ct:fail(body_too_big)
end
end.
@@ -405,7 +405,7 @@ check_body(_, _, _, _,_) ->
ok.
print(Proto, Data, #state{print = true}) ->
- test_server:format("Received ~p: ~p~n", [Proto, Data]);
+ ct:pal("Received ~p: ~p~n", [Proto, Data]);
print(_, _, #state{print = false}) ->
ok.
diff --git a/lib/inets/test/inets_sup_SUITE.erl b/lib/inets/test/inets_sup_SUITE.erl
index 0ac940fd3e..12b85a816f 100644
--- a/lib/inets/test/inets_sup_SUITE.erl
+++ b/lib/inets/test/inets_sup_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2013. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -21,7 +21,7 @@
-module(inets_sup_SUITE).
-include_lib("common_test/include/ct.hrl").
--include("test_server_line.hrl").
+
%% Note: This directive should only be used in test suites.
-compile(export_all).
@@ -297,13 +297,14 @@ httpd_subtree(Config) when is_list(Config) ->
%% Check that we have the expected httpd instance children
io:format("httpd_subtree -> verify httpd instance children "
"(acceptor, misc and manager)~n", []),
+ {ok, _} = verify_child(Instance, httpd_connection_sup, supervisor),
{ok, _} = verify_child(Instance, httpd_acceptor_sup, supervisor),
{ok, _} = verify_child(Instance, httpd_misc_sup, supervisor),
{ok, _} = verify_child(Instance, httpd_manager, worker),
%% Check that the httpd instance acc supervisor has children
io:format("httpd_subtree -> verify acc~n", []),
- InstanceAcc = httpd_util:make_name("httpd_acc_sup", Addr, Port),
+ InstanceAcc = httpd_util:make_name("httpd_acceptor_sup", Addr, Port),
case supervisor:which_children(InstanceAcc) of
[_ | _] ->
ok;
diff --git a/lib/inets/test/inets_test_lib.erl b/lib/inets/test/inets_test_lib.erl
index 08aa559b90..4be9d9c8b3 100644
--- a/lib/inets/test/inets_test_lib.erl
+++ b/lib/inets/test/inets_test_lib.erl
@@ -547,14 +547,14 @@ tsp(F) ->
tsp(F, []).
tsp(F, A) ->
Timestamp = formated_timestamp(),
- test_server:format("*** ~s ~p ~p " ++ F ++ "~n",
+ ct:pal("*** ~s ~p ~p " ++ F ++ "~n",
[Timestamp, node(), self() | A]).
tsf(Reason) ->
- test_server:fail(Reason).
+ ct:fail(Reason).
tss(Time) ->
- test_server:sleep(Time).
+ ct:sleep(Time).
timestamp() ->
http_util:timestamp().
diff --git a/lib/inets/test/old_httpd_SUITE.erl b/lib/inets/test/old_httpd_SUITE.erl
index 5dca76b76b..de9aa4562e 100644
--- a/lib/inets/test/old_httpd_SUITE.erl
+++ b/lib/inets/test/old_httpd_SUITE.erl
@@ -18,7 +18,7 @@
%%
%%
--module(httpd_SUITE).
+-module(old_httpd_SUITE).
-include_lib("test_server/include/test_server.hrl").
-include("test_server_line.hrl").