Skip to content

Commit

Permalink
Revert "Add FPM prod idle timeout test"
Browse files Browse the repository at this point in the history
This reverts commit 08f52b1.

The newly added test fails.
  • Loading branch information
nikic committed Oct 4, 2021
1 parent 02778cd commit 69514e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 149 deletions.
53 changes: 0 additions & 53 deletions sapi/fpm/tests/proc-idle-timeout.phpt

This file was deleted.

4 changes: 2 additions & 2 deletions sapi/fpm/tests/status.inc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Status
if ($startTimeTimestamp && $fields['start time'][0] === '\\') {
$fields['start time'] = '\d+';
}
$pattern = '(' . $header;
$pattern = '|' . $header;
foreach ($fields as $name => $value) {
if ($nameTransformer) {
$name = call_user_func($nameTransformer, $name);
Expand All @@ -102,7 +102,7 @@ class Status
}
}
$pattern = rtrim($pattern, $rowPattern[strlen($rowPattern) - 1]);
$pattern .= $footer . ')';
$pattern .= $footer . '|';

if (!preg_match($pattern, $body)) {
echo "ERROR: Expected body does not match pattern\n";
Expand Down
106 changes: 12 additions & 94 deletions sapi/fpm/tests/tester.inc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class Tester
}

/**
* Get request params array.
* Execute request.
*
* @param string $query
* @param array $headers
Expand All @@ -531,13 +531,20 @@ class Tester
* @param string|null $successMessage
* @param string|null $errorMessage
* @param bool $connKeepAlive
* @return array
* @return Response
*/
private function getRequestParams(
public function request(
string $query = '',
array $headers = [],
string $uri = null
string $uri = null,
string $address = null,
string $successMessage = null,
string $errorMessage = null,
bool $connKeepAlive = false
) {
if ($this->hasError()) {
return new Response(null, true);
}
if (is_null($uri)) {
$uri = $this->makeSourceFile();
}
Expand All @@ -564,38 +571,9 @@ class Tester
],
$headers
);

return array_filter($params, function($value) {
$params = array_filter($params, function($value) {
return !is_null($value);
});
}

/**
* Execute request.
*
* @param string $query
* @param array $headers
* @param string|null $uri
* @param string|null $address
* @param string|null $successMessage
* @param string|null $errorMessage
* @param bool $connKeepAlive
* @return Response
*/
public function request(
string $query = '',
array $headers = [],
string $uri = null,
string $address = null,
string $successMessage = null,
string $errorMessage = null,
bool $connKeepAlive = false
) {
if ($this->hasError()) {
return new Response(null, true);
}

$params = $this->getRequestParams($query, $headers, $uri);

try {
$this->response = new Response(
Expand All @@ -616,66 +594,6 @@ class Tester
return $this->response;
}

/**
* Execute multiple requests in parallel.
*
* @param array|int $requests
* @param string|null $address
* @param string|null $successMessage
* @param string|null $errorMessage
* @param bool $connKeepAlive
* @return Response[]
* @throws \Exception
*/
public function multiRequest(
$requests,
string $address = null,
string $successMessage = null,
string $errorMessage = null,
bool $connKeepAlive = false
) {
if ($this->hasError()) {
return new Response(null, true);
}

if (is_numeric($requests)) {
$requests = array_fill(0, $requests, []);
} elseif (!is_array($requests)) {
throw new \Exception('Requests can be either numeric or array');
}

try {
$connections = array_map(function ($requestData) use ($address, $connKeepAlive) {
$client = $this->getClient($address, $connKeepAlive);
$params = $this->getRequestParams(
$requestData['query'] ?? '',
$requestData['headers'] ?? [],
$requestData['uri'] ?? null
);
return [
'client' => $client,
'requestId' => $client->async_request($params, false),
];
}, $requests);

$responses = array_map(function ($conn) {
$response = new Response($conn['client']->wait_for_response_data($conn['requestId']));
if ($this->debug) {
$response->debugOutput();
}
return $response;
}, $connections);
$this->message($successMessage);
return $responses;
} catch (\Exception $exception) {
if ($errorMessage === null) {
$this->error("Request failed", $exception);
} else {
$this->message($errorMessage);
}
}
}

/**
* Get client.
*
Expand Down

0 comments on commit 69514e6

Please sign in to comment.