← 输入框|github.com|刷新
Skip to content

Commit fbdb2cc

Browse files
committed
test(exec): make memory regression check allocator-independent
Measure live allocations around polling, excluding PHPUnit assertions and allocator page growth. Clarify that socket I/O timeouts do not impose a total deadline on synchronous HTTP setup or status calls.
1 parent 0ffd32a commit fbdb2cc

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎docs/guides/interactive-exec.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ ticks must return promptly. Their exceptions close the local session and propaga
103103

104104
## Deadlines and completion
105105

106-
The factory's `timeout` bounds synchronous HTTP setup requests. The third argument
107-
to `execStartInteractive()` is a separate total streaming deadline in milliseconds,
106+
The factory's `timeout` controls connection and socket I/O timeouts for synchronous
107+
HTTP setup/status calls. It is not a total request deadline: a response that keeps
108+
arriving can extend a request, and application heartbeats cannot run during it.
109+
The third argument to `execStartInteractive()` is a total streaming deadline in milliseconds,
108110
starting after the HTTP upgrade. It is not reset when output arrives. Expiry throws
109111
`Docker\Exception\InteractiveExecTimeoutException` and closes local I/O.
110112

‎tests/Stream/InteractiveExecStreamTest.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ public function testInvalidOrTruncatedFramesFail(string $wire): void
147147
public function testHugeFrameDoesNotAllocateItsDeclaredSize(): void
148148
{
149149
$stream = $this->open();
150-
$before = memory_get_usage(true);
150+
// Measure used bytes, not allocator pages (which grow in 2 MiB steps),
151+
// and exclude PHPUnit's own assertion/autoload allocations.
152+
$before = memory_get_usage();
151153
fwrite($this->sockets[1], pack('CxxxN', 1, 4294967295).'x');
152-
self::assertTrue($stream->poll());
153-
self::assertLessThan(1048576, memory_get_usage(true) - $before);
154+
$open = $stream->poll();
155+
$used = memory_get_usage() - $before;
156+
self::assertTrue($open);
157+
self::assertLessThan(1048576, $used);
154158
}
155159

156160
public function testCallbackFailureClosesConnection(): void

0 commit comments

Comments
 (0)