fix: separate shadow refresh transaction timeout
This commit is contained in:
@@ -33,6 +33,7 @@ class ShadowConfigurationTest {
|
||||
assertThat(shadow.isEnabled()).isFalse();
|
||||
assertThat(shadow.getWarehouseId()).isEmpty();
|
||||
assertThat(shadow.getTimeoutSeconds()).isEqualTo(3);
|
||||
assertThat(shadow.getRefreshTimeoutSeconds()).isEqualTo(10);
|
||||
assertThat(shadow.getSnapshotMaxAgeSeconds()).isEqualTo(60);
|
||||
assertThat(shadow.getQuietIntervalMillis()).isEqualTo(1000);
|
||||
assertThat(algorithm.getMode()).isEqualTo(SchedulingMode.SHADOW);
|
||||
|
||||
@@ -315,17 +315,23 @@ class ShadowPlanningEngineTest {
|
||||
|
||||
@Test
|
||||
void refreshClaimsInstanceAndReturnsValidatedPublishedSnapshot() {
|
||||
ShadowObservationProperties properties = properties();
|
||||
properties.setTimeoutSeconds(3);
|
||||
properties.setRefreshTimeoutSeconds(11);
|
||||
CapturingTransactionManager transactions = new CapturingTransactionManager();
|
||||
ShadowInputMapper mapper = mock(ShadowInputMapper.class);
|
||||
when(mapper.claimInstance("01", "INSTANCE-1", 120)).thenReturn(true);
|
||||
PublishedShadowSnapshot refreshedSnapshot = snapshot(43L, "01");
|
||||
when(mapper.selectPublishedSnapshot("01")).thenReturn(descriptor(refreshedSnapshot));
|
||||
ShadowPlanningEngine engine = engine(mock(SchedulingFacade.class), mapper);
|
||||
ShadowPlanningEngine engine = new ShadowPlanningEngine(
|
||||
mock(SchedulingFacade.class), mapper, properties, transactions);
|
||||
|
||||
PublishedShadowSnapshot refreshed = engine.refreshSnapshot(43L, "INSTANCE-1");
|
||||
|
||||
verify(mapper).claimInstance("01", "INSTANCE-1", 120);
|
||||
verify(mapper).refreshSnapshot("01", 43L, "INSTANCE-1");
|
||||
assertThat(refreshed).isEqualTo(refreshedSnapshot);
|
||||
assertThat(transactions.definition.getTimeout()).isEqualTo(11);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -76,6 +76,22 @@ class ShadowSafetyGuardTest {
|
||||
.hasMessageContaining("between 100 and 10000");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsRefreshTimeoutOutsideValidatedRange() {
|
||||
ShadowObservationProperties shadow = enabledShadow();
|
||||
AlgorithmProperties algorithm = new AlgorithmProperties();
|
||||
algorithm.setMode(SchedulingMode.SHADOW);
|
||||
algorithm.setDatabaseWritesEnabled(true);
|
||||
|
||||
shadow.setRefreshTimeoutSeconds(3);
|
||||
assertThatThrownBy(() -> new ShadowSafetyGuard(shadow, algorithm).validate())
|
||||
.hasMessageContaining("refresh timeout");
|
||||
|
||||
shadow.setRefreshTimeoutSeconds(61);
|
||||
assertThatThrownBy(() -> new ShadowSafetyGuard(shadow, algorithm).validate())
|
||||
.hasMessageContaining("refresh timeout");
|
||||
}
|
||||
|
||||
private ShadowObservationProperties enabledShadow() {
|
||||
ShadowObservationProperties properties = new ShadowObservationProperties();
|
||||
properties.setEnabled(true);
|
||||
|
||||
Reference in New Issue
Block a user