fix: observe legacy failures in shadow worker
This commit is contained in:
@@ -255,6 +255,51 @@ class ShadowObservationGatewayTest {
|
||||
assertThat(coordinator.activeLegacyCount()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void inboundLegacyFailureIsRecordedAtLegacyWaitStage() throws Exception {
|
||||
ShadowPlanningEngine engine = mock(ShadowPlanningEngine.class);
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
ShadowSnapshotCoordinator coordinator = coordinatorWithSnapshot();
|
||||
when(engine.planInbound(SNAPSHOT, "TASK-FAIL", "TRAY-FAIL")).thenReturn(inboundObservation());
|
||||
CountDownLatch waitMetric = metricLatch(mapper, "ERROR_LEGACY_WAIT");
|
||||
stubSuccessfulRecovery(engine, mapper, 43L);
|
||||
ShadowObservationGateway gateway = gateway(engine, mapper, coordinator,
|
||||
new ShadowRuntimeMetrics(), Clock.fixed(NOW, ZoneOffset.UTC), delay -> { });
|
||||
|
||||
InboundShadowCompletion completion = gateway.observeInbound("TASK-FAIL", "TRAY-FAIL");
|
||||
completion.fail(new IllegalStateException("business payload must not be logged"));
|
||||
|
||||
assertThat(waitMetric.await(1, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(coordinator.activeLegacyCount()).isZero();
|
||||
completion.fail(new IllegalStateException("duplicate"));
|
||||
completion.complete("10", "SPACE-FAIL");
|
||||
assertThat(coordinator.activeLegacyCount()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void outboundLegacyFailureIsRecordedAtLegacyWaitStage() throws Exception {
|
||||
ShadowPlanningEngine engine = mock(ShadowPlanningEngine.class);
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
ShadowSnapshotCoordinator coordinator = coordinatorWithSnapshot();
|
||||
OutboundShadowObservation observation = new OutboundShadowObservation(
|
||||
true, 42L, "01", NOW, "ABC123", "DETAIL-FAIL", "READY",
|
||||
"STOCK-FAIL", "SPACE-FAIL", "diagnostic");
|
||||
when(engine.planProjectOutbound(SNAPSHOT, "DETAIL-FAIL")).thenReturn(observation);
|
||||
CountDownLatch waitMetric = metricLatch(mapper, "ERROR_LEGACY_WAIT");
|
||||
stubSuccessfulRecovery(engine, mapper, 43L);
|
||||
ShadowObservationGateway gateway = gateway(engine, mapper, coordinator,
|
||||
new ShadowRuntimeMetrics(), Clock.fixed(NOW, ZoneOffset.UTC), delay -> { });
|
||||
|
||||
OutboundShadowCompletion completion = gateway.observeProjectOutbound("DETAIL-FAIL");
|
||||
completion.fail(new IllegalStateException("business payload must not be logged"));
|
||||
|
||||
assertThat(waitMetric.await(1, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(coordinator.activeLegacyCount()).isZero();
|
||||
completion.fail(new IllegalStateException("duplicate"));
|
||||
completion.complete("10");
|
||||
assertThat(coordinator.activeLegacyCount()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectAndExactStockOutboundUseTheLeasedGeneration() throws Exception {
|
||||
assertOutboundUsesLease(false);
|
||||
|
||||
Reference in New Issue
Block a user