test(rpc): 스트림 시험 셋이 실제 1초를 자지 않게 상한 시계를 넘긴다

문제: RPC 스트림 시험 셋("cancels the physical stream exactly once after a
timeout", "refuses a second stream while the first has not confirmed
closure", "admits a second stream once waitClosed fulfils")은 시계를 넘기지
않아, 닫힘 확인이 없을 때의 1초 정리 상한을 runtime 기본 시계로 실제로
기다렸다(junit 1.03~1.06초). 같은 파일의 `cappedClock`은 다른 시험 넷에만
넘겼다.

고친 것: `cappedClock`(모든 대기를 30 ms로 자름)을 파일 위로 올리고 셋에도
넘긴다. 작업 마감 25 ms는 그 아래라 단언 뜻이 바뀌지 않는다.

검증: desktop junit에서 셋 모두 100 ms 아래. 고치기 전 파일은 같은 실행에서
1.027·1.059·1.056초.

Refs: 1101/10-07
This commit is contained in:
DongHyeonka
2026-11-13 23:29:13 +09:00
parent 7922592c07
commit f5e4e80e70
@@ -377,6 +377,19 @@ describe("RPC-RR-04 transport results and frames are exactly decoded", () => {
}); });
}); });
/**
* 1101/10-07. The system clock with every wait capped at 30 ms. Without a
* positive receipt the stream cleanup waits out its 1 s bound; capped, a test
* passes that bound instead of sleeping through it. The operations' own 25 ms
* deadlines are below the cap and unchanged. Every stream test that ends
* without a positive receipt takes it, so none sleeps a real second.
*/
const cappedClock: ClockPort = Object.freeze({
now: () => systemClock.now(),
sleep: (milliseconds: number, signal?: AbortSignal) =>
systemClock.sleep(Math.min(milliseconds, 30), signal),
});
/** /**
* RPC-RR-01. A bare `AsyncIterable` gave the runtime no way to cancel the * RPC-RR-01. A bare `AsyncIterable` gave the runtime no way to cancel the
* physical stream or to learn when it actually closed, so a timed-out call left * physical stream or to learn when it actually closed, so a timed-out call left
@@ -395,6 +408,7 @@ describe("RPC-RR-01 server stream leases and the DRAINING fence", () => {
mappers: MAPPERS, mappers: MAPPERS,
requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER }, requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER },
transports: { CONNECT_REFERENCE_STREAM: probe.transport }, transports: { CONNECT_REFERENCE_STREAM: probe.transport },
clock: cappedClock,
}); });
const results = await collect( const results = await collect(
@@ -418,6 +432,7 @@ describe("RPC-RR-01 server stream leases and the DRAINING fence", () => {
mappers: MAPPERS, mappers: MAPPERS,
requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER }, requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER },
transports: { CONNECT_REFERENCE_STREAM: probe.transport }, transports: { CONNECT_REFERENCE_STREAM: probe.transport },
clock: cappedClock,
}); });
const stream = runtime.bindServerStream( const stream = runtime.bindServerStream(
"WATCH_RPC_RESOURCES", "WATCH_RPC_RESOURCES",
@@ -541,18 +556,6 @@ describe("RPC-01 only a positive receipt confirms physical closure", () => {
{ label: "never settles", waitClosed: () => new Promise<void>(() => {}) }, { label: "never settles", waitClosed: () => new Promise<void>(() => {}) },
]; ];
/**
* 1101/10-07. The system clock with every wait capped at 30 ms. Without a
* positive receipt the stream cleanup waits out its 1 s bound; capped, the
* test passes that bound instead of sleeping through it. The operation's own
* 25 ms deadlines are below the cap and unchanged.
*/
const cappedClock: ClockPort = Object.freeze({
now: () => systemClock.now(),
sleep: (milliseconds: number, signal?: AbortSignal) =>
systemClock.sleep(Math.min(milliseconds, 30), signal),
});
for (const { label, waitClosed } of negativeReceipts) { for (const { label, waitClosed } of negativeReceipts) {
it(`keeps the operation DRAINING when waitClosed ${label}`, async () => { it(`keeps the operation DRAINING when waitClosed ${label}`, async () => {
const probe = leaseProbeWith(waitClosed); const probe = leaseProbeWith(waitClosed);
@@ -598,6 +601,7 @@ describe("RPC-01 only a positive receipt confirms physical closure", () => {
mappers: MAPPERS, mappers: MAPPERS,
requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER }, requestEncoders: { RpcResourceStreamRequestEncoder: STREAM_ENCODER },
transports: { CONNECT_REFERENCE_STREAM: probe.transport }, transports: { CONNECT_REFERENCE_STREAM: probe.transport },
clock: cappedClock,
}); });
const stream = runtime.bindServerStream( const stream = runtime.bindServerStream(
"WATCH_RPC_RESOURCES", "WATCH_RPC_RESOURCES",