Skip to content

Commit 95f2583

Browse files
committed
Allow http tests to run in parallel by using ephemeral ports
1 parent cafeec3 commit 95f2583

26 files changed

+193
-210
lines changed

ext/soap/tests/bug47021.phpt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ Bug #47021 SoapClient (SoapClient stumbles over WSDL delivered with "Transfer-En
44
soap.wsdl_cache_enabled=0
55
--SKIPIF--
66
<?php
7-
87
require 'skipif.inc';
9-
10-
require __DIR__.'/../../standard/tests/http/server.inc'; http_server_skipif('tcp://127.0.0.1:12342');
11-
12-
?>
8+
require __DIR__.'/../../standard/tests/http/server.inc';
9+
http_server_skipif();
1310
--FILE--
1411
<?php
1512
require __DIR__.'/../../standard/tests/http/server.inc';
@@ -49,11 +46,11 @@ $responses = [
4946
];
5047

5148

52-
$pid = http_server('tcp://127.0.0.1:12342', $responses);
49+
['pid' => $pid, 'uri' => $uri] = http_server($responses);
5350

5451
$options = [
5552
'trace' => true,
56-
'location' => 'http://127.0.0.1:12342/',
53+
'location' => $uri,
5754
];
5855

5956
class BugSoapClient extends SoapClient
@@ -68,13 +65,12 @@ class BugSoapClient extends SoapClient
6865
}
6966
}
7067

71-
$client = new BugSoapClient('http://127.0.0.1:12342/', $options);
68+
$client = new BugSoapClient($uri, $options);
7269

7370
var_dump(count($client->getItems()));
7471

7572
http_server_kill($pid);
7673

77-
?>
7874
--EXPECT--
7975
int(1291)
8076
int(10)

ext/standard/tests/http/CONFLICTS

Lines changed: 0 additions & 1 deletion
This file was deleted.

ext/standard/tests/http/bug38802.phpt

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ Bug #38802 (ignore_errors and max_redirects)
33
--INI--
44
allow_url_fopen=1
55
--SKIPIF--
6-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
6+
<?php require 'server.inc'; http_server_skipif();
77
--FILE--
88
<?php
99
require 'server.inc';
1010

11+
function genResponses($server) {
12+
$uri = 'http://' . stream_socket_get_name($server, false);
13+
yield "data://text/plain,HTTP/1.1 302 Moved Temporarily\r\nLocation: $uri/foo/bar2\r\n\r\n1";
14+
yield "data://text/plain,HTTP/1.1 301 Moved Permanently\r\nLocation: $uri/foo/bar3\r\n\r\n";
15+
yield "data://text/plain,HTTP/1.1 302 Moved Temporarily\r\nLocation: $uri/foo/bar4\r\n\r\n3";
16+
yield "data://text/plain,HTTP/1.1 200 OK\r\n\r\ndone.";
17+
}
18+
1119
function do_test($context_options) {
1220

1321
$context = stream_context_create(array('http' => $context_options));
1422

15-
$responses = array(
16-
"data://text/plain,HTTP/1.1 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar2\r\n\r\n1",
17-
"data://text/plain,HTTP/1.1 301 Moved Permanently\r\nLocation: http://127.0.0.1:12342/foo/bar3\r\n\r\n",
18-
"data://text/plain,HTTP/1.1 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar4\r\n\r\n3",
19-
"data://text/plain,HTTP/1.1 200 OK\r\n\r\ndone.",
20-
);
21-
22-
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
23+
$uri = null;
24+
['pid' => $pid, 'uri' => $uri ] = http_server('genResponses', $output);
2325

24-
$fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context);
26+
$fd = fopen("$uri/foo/bar", 'rb', false, $context);
2527
var_dump($fd);
2628

2729
if ($fd) {
@@ -73,64 +75,64 @@ array(7) {
7375
[0]=>
7476
string(30) "HTTP/1.1 302 Moved Temporarily"
7577
[1]=>
76-
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
78+
string(%d) "Location: http://%s:%d/foo/bar2"
7779
[2]=>
7880
string(30) "HTTP/1.1 301 Moved Permanently"
7981
[3]=>
80-
string(41) "Location: http://127.0.0.1:12342/foo/bar3"
82+
string(%d) "Location: http://%s:%d/foo/bar3"
8183
[4]=>
8284
string(30) "HTTP/1.1 302 Moved Temporarily"
8385
[5]=>
84-
string(41) "Location: http://127.0.0.1:12342/foo/bar4"
86+
string(%d) "Location: http://%s:%d/foo/bar4"
8587
[6]=>
8688
string(15) "HTTP/1.1 200 OK"
8789
}
8890
string(5) "done."
8991
string(%d) "GET /foo/bar HTTP/1.1
90-
Host: 127.0.0.1:12342
92+
Host: %s:%d
9193
Connection: close
9294

9395
GET /foo/bar2 HTTP/1.1
94-
Host: 127.0.0.1:12342
96+
Host: %s:%d
9597
Connection: close
9698

9799
GET /foo/bar3 HTTP/1.1
98-
Host: 127.0.0.1:12342
100+
Host: %s:%d
99101
Connection: close
100102

101103
GET /foo/bar4 HTTP/1.1
102-
Host: 127.0.0.1:12342
104+
Host: %s:%d
103105
Connection: close
104106

105107
"
106108
-- Test: fail after 2 redirections --
107109

108-
Warning: fopen(http://127.0.0.1:12342/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
110+
Warning: fopen(http://%s:%d/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
109111
bool(false)
110112
string(%d) "GET /foo/bar HTTP/1.1
111-
Host: 127.0.0.1:12342
113+
Host: %s:%d
112114
Connection: close
113115

114116
GET /foo/bar2 HTTP/1.1
115-
Host: 127.0.0.1:12342
117+
Host: %s:%d
116118
Connection: close
117119

118120
"
119121
-- Test: fail at first redirection --
120122

121-
Warning: fopen(http://127.0.0.1:12342/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
123+
Warning: fopen(http://%s:%d/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
122124
bool(false)
123125
string(%d) "GET /foo/bar HTTP/1.1
124-
Host: 127.0.0.1:12342
126+
Host: %s:%d
125127
Connection: close
126128

127129
"
128130
-- Test: fail at first redirection (2) --
129131

130-
Warning: fopen(http://127.0.0.1:12342/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
132+
Warning: fopen(http://%s:%d/foo/bar): Failed to open stream: Redirection limit reached, aborting in %s
131133
bool(false)
132134
string(%d) "GET /foo/bar HTTP/1.1
133-
Host: 127.0.0.1:12342
135+
Host: %s:%d
134136
Connection: close
135137

136138
"
@@ -140,11 +142,11 @@ array(2) {
140142
[0]=>
141143
string(30) "HTTP/1.1 302 Moved Temporarily"
142144
[1]=>
143-
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
145+
string(%d) "Location: http://%s:%d/foo/bar2"
144146
}
145147
string(1) "1"
146148
string(%d) "GET /foo/bar HTTP/1.1
147-
Host: 127.0.0.1:12342
149+
Host: %s:%d
148150
Connection: close
149151

150152
"
@@ -154,11 +156,11 @@ array(2) {
154156
[0]=>
155157
string(30) "HTTP/1.1 302 Moved Temporarily"
156158
[1]=>
157-
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
159+
string(%d) "Location: http://%s:%d/foo/bar2"
158160
}
159161
string(1) "1"
160162
string(%d) "GET /foo/bar HTTP/1.1
161-
Host: 127.0.0.1:12342
163+
Host: %s:%d
162164
Connection: close
163165

164166
"
@@ -168,19 +170,19 @@ array(4) {
168170
[0]=>
169171
string(30) "HTTP/1.1 302 Moved Temporarily"
170172
[1]=>
171-
string(41) "Location: http://127.0.0.1:12342/foo/bar2"
173+
string(%d) "Location: http://%s:%d/foo/bar2"
172174
[2]=>
173175
string(30) "HTTP/1.1 301 Moved Permanently"
174176
[3]=>
175-
string(41) "Location: http://127.0.0.1:12342/foo/bar3"
177+
string(%d) "Location: http://%s:%d/foo/bar3"
176178
}
177179
string(0) ""
178180
string(%d) "GET /foo/bar HTTP/1.1
179-
Host: 127.0.0.1:12342
181+
Host: %s:%d
180182
Connection: close
181183

182184
GET /foo/bar2 HTTP/1.1
183-
Host: 127.0.0.1:12342
185+
Host: %s:%d
184186
Connection: close
185187

186188
"

ext/standard/tests/http/bug43510.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #43510 (stream_get_meta_data() does not return same mode as used in fopen)
33
--INI--
44
allow_url_fopen=1
55
--SKIPIF--
6-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
6+
<?php require 'server.inc'; http_server_skipif(); ?>
77
--FILE--
88
<?php
99
require 'server.inc';
@@ -13,10 +13,10 @@ $responses = array(
1313
"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
1414
);
1515

16-
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
16+
['pid' => $pid, 'uri' => $uri ] = http_server($responses, $output);
1717

1818
foreach(array('r', 'rb') as $mode) {
19-
$fd = fopen('http://127.0.0.1:12342/', $mode, false);
19+
$fd = fopen($uri, $mode, false);
2020
$meta = stream_get_meta_data($fd);
2121
var_dump($meta['mode']);
2222
fclose($fd);

ext/standard/tests/http/bug47021.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #47021 (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chu
33
--INI--
44
allow_url_fopen=1
55
--SKIPIF--
6-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
6+
<?php require 'server.inc'; http_server_skipif(); ?>
77
--FILE--
88
<?php
99
require 'server.inc';
@@ -45,11 +45,11 @@ function do_test($num_spaces, $leave_trailing_space=false) {
4545
. "Content-Length:{$spaces}5{$trailing}\r\n\r\n"
4646
. "World"
4747
];
48-
$pid = http_server('tcp://127.0.0.1:12342', $responses);
48+
['pid' => $pid, 'uri' => $uri] = http_server($responses);
4949

50-
echo file_get_contents('http://127.0.0.1:12342/', false, $ctx);
50+
echo file_get_contents($uri, false, $ctx);
5151
echo "\n";
52-
echo file_get_contents('http://127.0.0.1:12342/', false, $ctx);
52+
echo file_get_contents($uri, false, $ctx);
5353
echo "\n";
5454

5555
http_server_kill($pid);

ext/standard/tests/http/bug48929.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #48929 (duplicate \r\n sent after last header line)
33
--INI--
44
allow_url_fopen=1
55
--SKIPIF--
6-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
6+
<?php require 'server.inc'; http_server_skipif(); ?>
77
--FILE--
88
<?php
99
require 'server.inc';
@@ -16,11 +16,11 @@ function do_test($context_options) {
1616
"data://text/plain,HTTP/1.1 200 OK\r\n\r\n",
1717
);
1818

19-
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
19+
['pid' => $pid, 'uri' => $uri] = http_server($responses, $output);
2020

2121
foreach($responses as $r) {
2222

23-
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context);
23+
$fd = fopen($uri, 'rb', false, $context);
2424

2525
fseek($output, 0, SEEK_SET);
2626
var_dump(stream_get_contents($output));
@@ -42,7 +42,7 @@ do_test(array('header' => "X-Foo: bar\r\nContent-Type: text/plain", 'method' =>
4242
--EXPECTF--
4343
-- Test: requests with 'header' as array --
4444
string(%d) "POST / HTTP/1.1
45-
Host: 127.0.0.1:12342
45+
Host: %s:%d
4646
Connection: close
4747
Content-Length: 4
4848
X-Foo: bar
@@ -51,7 +51,7 @@ Content-Type: text/plain
5151
ohai"
5252
-- Test: requests with 'header' as string --
5353
string(%d) "POST / HTTP/1.1
54-
Host: 127.0.0.1:12342
54+
Host: %s:%d
5555
Connection: close
5656
Content-Length: 4
5757
X-Foo: bar

ext/standard/tests/http/bug53198.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Bug #53198 (From: header cannot be changed with ini_set)
33
--SKIPIF--
4-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
4+
<?php require 'server.inc'; http_server_skipif(); ?>
55
--INI--
66
allow_url_fopen=1
77
@@ -15,11 +15,11 @@ function do_test() {
1515
"data://text/plain,HTTP/1.1 200 OK\r\n\r\n",
1616
);
1717

18-
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
18+
['pid' => $pid, 'uri' => $uri] = http_server($responses, $output);
1919

2020
foreach($responses as $r) {
2121

22-
$fd = fopen('http://127.0.0.1:12342/', 'rb', false);
22+
$fd = fopen($uri, 'rb', false);
2323

2424
fseek($output, 0, SEEK_SET);
2525
var_dump(stream_get_contents($output));
@@ -45,14 +45,14 @@ do_test();
4545
-- Test: leave default --
4646
string(%d) "GET / HTTP/1.1
4747
48-
Host: 127.0.0.1:12342
48+
Host: %s:%d
4949
Connection: close
5050

5151
"
5252
-- Test: after ini_set --
5353
string(%d) "GET / HTTP/1.1
5454
55-
Host: 127.0.0.1:12342
55+
Host: %s:%d
5656
Connection: close
5757

5858
"

ext/standard/tests/http/bug60570.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Bug #60570 (Stream context leaks when http request fails)
33
--SKIPIF--
4-
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
4+
<?php require 'server.inc'; http_server_skipif(); ?>
55
--INI--
66
allow_url_fopen=1
77
--FILE--
@@ -16,14 +16,14 @@ function do_test() {
1616
"data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n"
1717
);
1818

19-
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
19+
['pid' => $pid, 'uri' => $uri] = http_server($responses, $output);
2020

2121
$a = $b = count(get_resources());
2222

2323
$i = 3;
2424
while ($i--) {
2525
$context = stream_context_create(array('http'=>array('timeout'=>1)));
26-
file_get_contents('http://127.0.0.1:12342/', 0, $context);
26+
file_get_contents($uri, 0, $context);
2727
unset($context);
2828

2929
$b = $a;
@@ -39,13 +39,13 @@ function do_test() {
3939
do_test();
4040
?>
4141
--EXPECTF--
42-
Warning: file_get_contents(http://127.0.0.1:12342/): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
42+
Warning: file_get_contents(http://%s:%d): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
4343
in %s on line %d
4444

45-
Warning: file_get_contents(http://127.0.0.1:12342/): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
45+
Warning: file_get_contents(http://%s:%d): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
4646
in %s on line %d
4747

48-
Warning: file_get_contents(http://127.0.0.1:12342/): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
48+
Warning: file_get_contents(http://%s:%d): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
4949
in %s on line %d
5050
leak? penultimate iteration: %d, last one: %d
5151
bool(true)

0 commit comments

Comments
 (0)