Skip to content

Commit e1569c7

Browse files
authored
Stop Sharding test configs from spinning the runner-sync loop (#11279)
1 parent 75c31f2 commit e1569c7

5 files changed

Lines changed: 29 additions & 34 deletions

File tree

‎packages/effect/test/cluster/MessageRetention.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const RetentionSharding = Sharding.layer.pipe(
2727
entityMailboxCapacity: 10,
2828
entityTerminationTimeout: 0,
2929
entityMessagePollInterval: 5000,
30-
sendRetryInterval: 100,
31-
refreshAssignmentsInterval: 0
30+
sendRetryInterval: 100
3231
}))
3332
)
3433

‎packages/effect/test/cluster/RunnerServer.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ const makeHandlers = (
7272
entityMailboxCapacity: 10,
7373
entityTerminationTimeout: 0,
7474
entityMessagePollInterval: 5000,
75-
sendRetryInterval: 100,
76-
refreshAssignmentsInterval: 0
75+
sendRetryInterval: 100
7776
}))
7877
)
7978

‎packages/effect/test/cluster/Runners.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ const TestShardingConfig = ShardingConfig.layer({
5353
entityMailboxCapacity: 10,
5454
entityTerminationTimeout: 0,
5555
entityMessagePollInterval: 5000,
56-
sendRetryInterval: 100,
57-
refreshAssignmentsInterval: 0
56+
sendRetryInterval: 100
5857
})
5958

6059
const layerServerProtocol = (codecFor: RpcSerialization.CodecFor) =>

‎packages/effect/test/cluster/Sharding.test.ts‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,7 @@ describe.concurrent("Sharding", () => {
15771577
entityRegistrationTimeout: 600,
15781578
entityTerminationTimeout: 0,
15791579
entityMessagePollInterval: 100,
1580-
sendRetryInterval: 100,
1581-
refreshAssignmentsInterval: 0
1580+
sendRetryInterval: 100
15821581
})
15831582
const env = TestEntityNoState.pipe(
15841583
Layer.provideMerge(Sharding.layer),
@@ -1633,7 +1632,7 @@ describe.concurrent("Sharding", () => {
16331632
}).pipe(Effect.provide(MessageStorage.layerMemory.pipe(
16341633
Layer.provide(ShardingConfig.layer({})),
16351634
Layer.merge(TestEntityState.layer)
1636-
))), 20_000)
1635+
))))
16371636

16381637
it.effect("reads durable messages from storage when a late entity registers", () =>
16391638
Effect.gen(function*() {
@@ -1642,8 +1641,7 @@ describe.concurrent("Sharding", () => {
16421641
entityRegistrationTimeout: 600,
16431642
entityTerminationTimeout: 0,
16441643
entityMessagePollInterval: "1 hour",
1645-
sendRetryInterval: 100,
1646-
refreshAssignmentsInterval: 0
1644+
sendRetryInterval: 100
16471645
})
16481646
const env = TestEntityNoState.pipe(
16491647
Layer.provideMerge(Sharding.layer),
@@ -1693,14 +1691,12 @@ describe.concurrent("Sharding", () => {
16931691
Effect.forkChild({ startImmediately: true })
16941692
)
16951693

1696-
// the startup storage read sees the message before the entity registers,
1697-
// and the entity registers while the claim reset is still pending
1694+
// Register the entity while the startup claim reset is pending.
16981695
yield* TestClock.adjust(999)
16991696
assert.isTrue(yield* Deferred.isDone(resetStarted))
17001697
yield* TestClock.adjust(1)
17011698

1702-
// the reset must complete before the read woken by registration, without
1703-
// waiting for the poll interval or new client traffic
1699+
// Registration must trigger a read after the reset, without waiting for a poll or client traffic.
17041700
yield* Deferred.succeed(releaseReset, void 0)
17051701
yield* Queue.offer(state.messages, void 0)
17061702
yield* TestClock.adjust(100)
@@ -1711,7 +1707,7 @@ describe.concurrent("Sharding", () => {
17111707
}).pipe(Effect.provide(MessageStorage.layerMemory.pipe(
17121708
Layer.provide(ShardingConfig.layer({})),
17131709
Layer.merge(TestEntityState.layer)
1714-
))), 20_000)
1710+
))))
17151711

17161712
it.effect("defects durable messages when no entity ever registers", () =>
17171713
Effect.gen(function*() {
@@ -1720,8 +1716,7 @@ describe.concurrent("Sharding", () => {
17201716
entityRegistrationTimeout: 1000,
17211717
entityTerminationTimeout: 0,
17221718
entityMessagePollInterval: 100,
1723-
sendRetryInterval: 100,
1724-
refreshAssignmentsInterval: 0
1719+
sendRetryInterval: 100
17251720
})
17261721
const registeredEnv = TestEntityNoState.pipe(
17271722
Layer.provideMerge(Sharding.layer),
@@ -1772,7 +1767,7 @@ describe.concurrent("Sharding", () => {
17721767
}).pipe(Effect.provide(MessageStorage.layerMemory.pipe(
17731768
Layer.provide(ShardingConfig.layer({})),
17741769
Layer.merge(TestEntityState.layer)
1775-
))), 20_000)
1770+
))))
17761771

17771772
it.effect("bounds local sends while entity registration is missing", () =>
17781773
Effect.gen(function*() {
@@ -2041,8 +2036,7 @@ describe.concurrent("Sharding", () => {
20412036
entityMailboxCapacity: 10,
20422037
entityTerminationTimeout: 0,
20432038
entityMessagePollInterval: 5000,
2044-
sendRetryInterval: 100,
2045-
refreshAssignmentsInterval: 0
2039+
sendRetryInterval: 100
20462040
}))
20472041
))
20482042
)
@@ -2853,15 +2847,15 @@ describe.concurrent("Sharding defect recovery", () => {
28532847
)
28542848
yield* Effect.gen(function*() {
28552849
yield* Layer.buildWithScope(ClosingTargetLayer(state), targetScope)
2856-
// The target entity is resident while the caller waits on its queued request.
2850+
// Keep the target resident while the caller waits.
28572851
yield* advanceUntil((yield* ClosingTarget.client)("1").Warm())
28582852
yield* (yield* ClosingTargetCaller.client)("1").Call({ id: "call" }, { discard: true })
28592853
yield* queued.await
28602854
}).pipe(Effect.provide(runner))
28612855
yield* advanceUntil(Scope.close(targetScope, Exit.void))
28622856
// A caller left parked waits out `entityTerminationTimeout`.
28632857
const closing = yield* Effect.forkChild(Scope.close(runnerScope, Exit.void), { startImmediately: true })
2864-
for (let i = 0; i < 100 && closing.pollUnsafe() === undefined; i++) yield* TestClock.adjust(1000)
2858+
yield* TestClock.adjust(100_000)
28652859
yield* Fiber.join(closing)
28662860
assert.deepStrictEqual(state, { children: 0, continued: [] })
28672861

@@ -2981,8 +2975,6 @@ describe.concurrent("Sharding active teardowns", () => {
29812975
assert.strictEqual(journalInterrupts(driver), 0)
29822976
}).pipe(Effect.provide(ActiveTeardownSharding({ entityMaxIdleTime: 1 }))))
29832977

2984-
// TestClock-driven reassignment can exhaust the wall-clock timeout when
2985-
// this test competes with the rest of this file in CI.
29862978
it.effect("swallows persisted interrupts when the caller's shard is released", () =>
29872979
Effect.gen(function*() {
29882980
const storageState = makeFailoverStorageState()
@@ -3214,7 +3206,7 @@ const sendAsReaperWakes = Effect.fnUntraced(function*(budget: number) {
32143206
})
32153207

32163208
describe.concurrent("Sharding residency cap", () => {
3217-
// Repeated TestClock adjustments need wall-clock headroom under concurrent Deno CI load.
3209+
// Allow extra wall-clock time for repeated clock advances under CPU contention.
32183210
it.effect("bounds resident entities to maxResidentEntities", () =>
32193211
Effect.gen(function*() {
32203212
yield* TestClock.adjust(1)
@@ -3986,7 +3978,12 @@ describe("Sharding shard lock failover", { concurrent: false }, () => {
39863978
yield* TestClock.adjust(10_000)
39873979
assert.deepStrictEqual(releases, [ShardId.make("default", 1)])
39883980
}).pipe(
3989-
Effect.provide(TerminationSharding(entityLayer, storageState, { entityTerminationTimeout: 10_000 })),
3981+
Effect.provide(TerminationSharding(entityLayer, storageState, {
3982+
entityTerminationTimeout: 10_000,
3983+
entityMessagePollInterval: 100,
3984+
entityReplyPollInterval: 100,
3985+
refreshAssignmentsInterval: 100
3986+
})),
39903987
Effect.scoped
39913988
)
39923989
}))
@@ -4616,8 +4613,9 @@ describe("Sharding shard handoff", { concurrent: false }, () => {
46164613
shardsPerGroup: 1,
46174614
shardLockExpiration: 300,
46184615
shardLockRefreshInterval: 1000,
4619-
// Keep 30 seconds of polling cheap
4620-
entityMessagePollInterval: 100
4616+
// Reduce timer wakes during the 30-second warning window.
4617+
entityMessagePollInterval: 100,
4618+
refreshAssignmentsInterval: 100
46214619
}).pipe(Effect.provide(Logger.layer([logger])), Effect.provideService(Metric.MetricRegistry, registry))
46224620
// These finalizers run before either scope closes, even on assertion failure.
46234621
const entityGate = yield* makeGate
@@ -4751,7 +4749,9 @@ describe("Sharding shard handoff", { concurrent: false }, () => {
47514749
})
47524750
const { sharding } = yield* buildSharding(storageState, {
47534751
shardsPerGroup: 1,
4754-
shardLockRefreshInterval: 100
4752+
shardLockRefreshInterval: 100,
4753+
entityMessagePollInterval: 100,
4754+
refreshAssignmentsInterval: 100
47554755
}).pipe(Effect.provide(Logger.layer([logger])))
47564756
yield* Effect.addFinalizer(() =>
47574757
Effect.sync(() => {
@@ -5568,8 +5568,7 @@ const testConfigDefaults: Partial<ShardingConfig.ShardingConfig["Service"]> = {
55685568
entityMailboxCapacity: 10,
55695569
entityTerminationTimeout: 0,
55705570
entityMessagePollInterval: 5000,
5571-
sendRetryInterval: 100,
5572-
refreshAssignmentsInterval: 0
5571+
sendRetryInterval: 100
55735572
}
55745573

55755574
const TestShardingConfig = ShardingConfig.layer(testConfigDefaults)

‎packages/platform/node/test/cluster/SqlMessageStorage.integration.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,7 @@ describe("SqlMessageStorage", () => {
13701370
const config = ShardingConfig.layer({
13711371
entityRegistrationTimeout: 6000,
13721372
entityTerminationTimeout: 0,
1373-
entityMessagePollInterval: 100,
1374-
refreshAssignmentsInterval: 0
1373+
entityMessagePollInterval: 100
13751374
})
13761375
const delayedEnv = TestEntityLayer.pipe(
13771376
Layer.provide(Layer.effectDiscard(Effect.sleep(10_000))),

0 commit comments

Comments
 (0)