summaryrefslogtreecommitdiff
path: root/test/it_url_slow.t
diff options
context:
space:
mode:
authorUrban Müller2018-06-21 16:42:32 +0200
committerUrban Müller2018-06-21 16:43:32 +0200
commit3dabbbd5325c9fad9582cd44b1da68dece78eaa0 (patch)
tree92d951b948f0e01dc6b7ae3f11b9c03034edb69a /test/it_url_slow.t
parent455b15f7a850a58ef667ad170732769043eb1522 (diff)
downloaditools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.tar.gz
itools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.tar.bz2
itools-3dabbbd5325c9fad9582cd44b1da68dece78eaa0.zip
no reason for different naming
Diffstat (limited to 'test/it_url_slow.t')
-rwxr-xr-xtest/it_url_slow.t59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/it_url_slow.t b/test/it_url_slow.t
new file mode 100755
index 0000000..32f0963
--- /dev/null
+++ b/test/it_url_slow.t
@@ -0,0 +1,59 @@
+#!/www/server/bin/php -qC
+<?php
+
+# slow tests for url.class
+
+# TESTFLAGS SLOW
+
+require 'it_url_server.php';
+
+handle_server(
+ is(
+ it_url::get('http://localhost:8000/short_sleep'),
+ "Testserver output after short sleep",
+ 'it_url::get() waits for 4 seconds'
+ )
+);
+
+$start = microtime(true);
+$res = ok(
+ !it_url::get(array('url' => 'http://localhost:8000/long_sleep', 'timeout' => 5, 'retries' => 0, 'it_error' => false)),
+ 'it_url::get() fails after timeout seconds with no output'
+);
+$res2 = is(
+ intval(microtime(true) - $start), 5,
+ '... and fails as soon as timeout is surpassed'
+);
+sleep(1); # wait for testserver
+$output = server_output();
+if (!$res || !$res2)
+ diag($output);
+
+handle_server(
+ is(
+ it_url::get('http://localhost:8000/slow_response'),
+ join('', it::map('"Testserver slow output $v\n"', range(0, 5))),
+ 'it_url::get() waits for slow response with continuous output'
+ )
+);
+
+$start = microtime(true);
+$res = ok(
+ !it_url::get(array('url' => 'http://localhost:8000/slow_response', 'totaltimeout' => 5, 'retries' => 0, 'it_error' => false)),
+ 'it_url::get() fails for response slower than totaltimeout'
+);
+$res2 = is(
+ intval(microtime(true) - $start), 5,
+ '... and fails as soon as totaltimeout is surpassed'
+);
+sleep(1); # wait for testserver
+$output = server_output();
+if (!$res || !$res2)
+ diag($output);
+
+handle_server(
+ ok(
+ it_url::get(U('http://localhost:8000/repeat', array('string' => "abc", 'num' => 1024 * 1024))) == str_repeat("abc", 1024 * 1024),
+ 'it_url::get() handles large response'
+ )
+);