4
%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
23
-include("test_server.hrl").
24
-include("test_server_line.hrl").
26
%% General testcases bodies called from httpd_SUITE
27
-export([load_test/5]).
30
-export([load_test_client/8]).
32
%%-------------------------------------------------------------------------
33
%% Test cases starts here.
34
%%-------------------------------------------------------------------------
35
load_test(Type, Port, Host, Node, NofTesters) ->
44
Fun = fun(Mod, Host1, Port1, Node1, Req, Exp) ->
45
ok = httpd_test_lib:verify_request(Mod, Host1, Port1,
48
load_test(Fun, URIs ++ URIs, Type, Host, Port, Node, NofTesters, []).
49
%%--------------------------------------------------------------------
51
%%--------------------------------------------------------------------
53
load_test(_, _, _, _, _, _, 0, []) ->
55
load_test(Fun, URIs, Type, Host, Port, Node, 0, List) ->
58
load_test(Fun, URIs, Type, Host, Port, Node, 0,
59
lists:delete(Pid, List));
60
{'EXIT', Pid, normal} ->
61
load_test(Fun, URIs, Type, Host, Port, Node, 0,
62
lists:delete(Pid, List));
63
{'EXIT', Pid, Reason} ->
64
Str = lists:flatten(io_lib:format("client ~p exited: ~p",
66
test_server:fail(Str);
68
load_test(Fun, URIs, Type, Host, Port, Node, 0, List)
71
load_test(Fun, URIs, Type, Host, Port, Node, X, List) ->
72
Pid = spawn_link(?MODULE, load_test_client,
73
[Fun, URIs, Type, Host, Port, Node, self(), 100]),
74
load_test(Fun, lists:reverse(URIs), Type, Host, Port, Node, X-1,
77
load_test_client(_Fun, [], _Type, _Host, _Port, _Node, Boss, _Timeout) ->
78
load_test_client_done(Boss);
79
load_test_client(Fun, [URI|URIs], Type, Host, Port, Node, Boss, Timeout) ->
80
Req = "GET "++URI++" HTTP/1.0\r\nConnection: Close\r\n"
81
"From: m@erix\r\nReferer: http://www.ericsson.se/\r\n\r\n",
83
case (catch Fun(Type, Host, Port, Node, Req,
84
[{statuscode, 200}, {statuscode, 500},
85
{statuscode, 503}, {version, "HTTP/1.0"}])) of
86
{'EXIT', {suite_failed, connection_closed, _, _}} ->
87
%% Some platforms seems to handle heavy load badly.
88
%% So, back off and see if this helps
89
%%?LOG("load_test_client->requestfailed:connection_closed"[]),
94
test_server:sleep(Timeout1),
95
load_test_client(Fun, URIs, Type, Host, Port, Node, Boss, Timeout1).
97
load_test_client_done(Boss) ->
98
Boss ! {self(), done}.