Skip to content

Commit 1a239f2

Browse files
committed
add test for multiple stores failling at same time
1 parent 940a562 commit 1a239f2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/com/uid2/operator/OperatorShutdownHandlerTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,29 @@ void multipleStoresOneStaleTriggers(VertxTestContext testContext) {
271271
}
272272
}
273273

274+
@Test
275+
void multipleStoresFailSimultaneouslyTriggersShutdown(VertxTestContext testContext) {
276+
ListAppender<ILoggingEvent> logWatcher = new ListAppender<>();
277+
logWatcher.start();
278+
((Logger) LoggerFactory.getLogger(OperatorShutdownHandler.class)).addAppender(logWatcher);
279+
280+
this.operatorShutdownHandler.handleStoreRefresh("keyset");
281+
this.operatorShutdownHandler.handleStoreRefresh("keysetkey");
282+
this.operatorShutdownHandler.handleStoreRefresh("salt");
283+
this.operatorShutdownHandler.handleStoreRefresh("auth");
284+
285+
when(clock.instant()).thenAnswer(i -> Instant.now().plus(12, ChronoUnit.HOURS).plusSeconds(1));
286+
287+
try {
288+
this.operatorShutdownHandler.checkStoreRefreshStaleness();
289+
} catch (RuntimeException e) {
290+
verify(shutdownService).Shutdown(1);
291+
Assertions.assertTrue(logWatcher.list.stream().anyMatch(log ->
292+
log.getFormattedMessage().contains("has not refreshed successfully")));
293+
testContext.completeNow();
294+
}
295+
}
296+
274297
@Test
275298
void noShutdownWhenStoreNeverInitialized(VertxTestContext testContext) {
276299

0 commit comments

Comments
 (0)