summaryrefslogtreecommitdiff
path: root/test/it_url_slow.t
diff options
context:
space:
mode:
authorNathan Gass2023-11-20 18:21:37 +0100
committerNathan Gass2023-11-20 18:21:37 +0100
commitd72f3476b4cd7d64280fbcdb73c8a15e99f66aa5 (patch)
treeb37322a9f9dc675358252edd321c1a8b94113e56 /test/it_url_slow.t
parenta059593f4301d8a28b1e019908bfd46530ff0747 (diff)
downloaditools-d72f3476b4cd7d64280fbcdb73c8a15e99f66aa5.tar.gz
itools-d72f3476b4cd7d64280fbcdb73c8a15e99f66aa5.tar.bz2
itools-d72f3476b4cd7d64280fbcdb73c8a15e99f66aa5.zip
use random port to avoid races
Diffstat (limited to 'test/it_url_slow.t')
-rwxr-xr-xtest/it_url_slow.t14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/it_url_slow.t b/test/it_url_slow.t
index 28b1bf9..59afe7e 100755
--- a/test/it_url_slow.t
+++ b/test/it_url_slow.t
@@ -9,7 +9,7 @@ require 'it_url_server.php';
handle_server(
is(
- it_url::get('http://localhost:8000/short_sleep'),
+ it_url::get("http://$host/short_sleep"),
"Testserver output after short sleep",
'it_url::get() receives full output after short sleep'
)
@@ -17,7 +17,7 @@ handle_server(
$start = microtime(true);
$res = is(
- it_url::get(['url' => 'http://localhost:8000/long_sleep', 'timeout' => 4, 'retries' => 0, 'it_error' => false]),
+ it_url::get(['url' => "http://$host/long_sleep", 'timeout' => 4, 'retries' => 0, 'it_error' => false]),
false,
'it_url::get() fails after timeout seconds with no output'
);
@@ -33,7 +33,7 @@ if (!$res || !$res2)
handle_server(
is(
- it_url::get('http://localhost:8000/slow_response'),
+ it_url::get("http://$host/slow_response"),
implode('', it::map('"Testserver slow output $v\n"', range(0, 5))),
'it_url::get() waits for slow response with continuous output'
)
@@ -41,7 +41,7 @@ handle_server(
$start = microtime(true);
$res = ok(
- !it_url::get(['url' => 'http://localhost:8000/slow_response', 'totaltimeout' => 5, 'retries' => 0, 'it_error' => false]),
+ !it_url::get(['url' => "http://$host/slow_response", 'totaltimeout' => 5, 'retries' => 0, 'it_error' => false]),
'it_url::get() fails for response slower than totaltimeout'
);
$res2 = is(
@@ -55,7 +55,7 @@ if (!$res || !$res2)
$start = microtime(true);
$res = ok(
- !it_url::get(['url' => 'http://localhost:8000/slow_response', 'maxlength' => 10, 'retries' => 0, 'it_error' => false]),
+ !it_url::get(['url' => "http://$host/slow_response", 'maxlength' => 10, 'retries' => 0, 'it_error' => false]),
'it_url::get() fails for response larger than maxlength'
);
$res2 = is(
@@ -69,12 +69,12 @@ if (!$res || !$res2)
handle_server(
ok(
- it_url::get(U('http://localhost:8000/repeat', ['string' => "abc", 'num' => 1024 * 1024])) == str_repeat("abc", 1024 * 1024),
+ it_url::get(U("http://$host/repeat", ['string' => "abc", 'num' => 1024 * 1024])) == str_repeat("abc", 1024 * 1024),
'it_url::get() handles large response'
)
);
$start = microtime(true);
-it_url::get_multi(['urls' => ['slow' => 'http://localhost:8000/long_sleep', 'fast' => ['url' => 'http://search.ch/', 'handler' => function () {return true;}]]]);
+it_url::get_multi(['urls' => ['slow' => "http://$host/long_sleep", 'fast' => ['url' => 'http://search.ch/', 'handler' => function () {return true;}]]]);
ok(intval(microtime(true) - $start) < 4, 'get_multi with handler aborts after fast request');
$output = server_output();