Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Configuration

private array $target;

private string $httpTimeout = '';

private bool $httpDebug = false;

public function __construct(string $name, string $description = '')
Expand Down Expand Up @@ -48,6 +50,9 @@ public function toArray(): array
if (trim($this->duration) !== '') {
$array['duration'] = $this->duration;
}
if (trim($this->httpTimeout) !== '') {
$array['http_timeout'] = $this->httpTimeout;
}

return $array;
}
Expand Down Expand Up @@ -92,6 +97,16 @@ public function setTarget(string $idleTimeout = '30s'): self
return $this;
}

public function setHttpTimeout(string $httpTimeout): self
{
if (! preg_match('/^\d+[smh]$/', $httpTimeout)) {
throw new VoltTestException('Invalid HTTP timeout format. Use <number>[s|m|h]');
}
$this->httpTimeout = $httpTimeout;

return $this;
}

public function setHttpDebug(bool $httpDebug): self
{
$this->httpDebug = $httpDebug;
Expand Down
16 changes: 16 additions & 0 deletions src/VoltTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ public function setRampUp(string $rampUp): self
return $this;
}

/**
* Set the HTTP request timeout (per-request)
* @param string $timeout e.g. "60s", "2m" — default is 30s
* @return $this
* @throws VoltTestException
*/
public function setHttpTimeout(string $timeout): self
{
if (! preg_match('/^\d+[smh]$/', $timeout)) {
throw new VoltTestException('Invalid HTTP timeout format. Use <number>[s|m|h]');
}
$this->config->setHttpTimeout($timeout);

return $this;
}

public function setHttpDebug(bool $httpDebug): self
{
$this->config->setHttpDebug($httpDebug);
Expand Down
Loading