Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 9dbefe3

Browse files
committed
add test for stream not restarting if store doesn't tell it to
1 parent 785e1aa commit 9dbefe3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,36 @@ public void restartsStreamIfStoreNeedsRefresh() throws Exception {
554554
}
555555
}
556556

557+
@Test
558+
public void doesNotRestartStreamIfStoreHadOutageButDoesNotNeedRefresh() throws Exception {
559+
TestComponents.DataStoreWithStatusUpdates storeWithStatus = new TestComponents.DataStoreWithStatusUpdates(dataStore);
560+
561+
SettableFuture<Void> restarted = SettableFuture.create();
562+
mockEventSource.start();
563+
expectLastCall();
564+
mockEventSource.restart();
565+
expectLastCall().andAnswer(() -> {
566+
restarted.set(null);
567+
return null;
568+
});
569+
mockEventSource.close();
570+
expectLastCall();
571+
mockRequestor.close();
572+
expectLastCall();
573+
574+
replayAll();
575+
576+
try (StreamProcessor sp = createStreamProcessorWithStore(storeWithStatus)) {
577+
sp.start();
578+
579+
storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(false, false));
580+
storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(true, false));
581+
582+
Thread.sleep(500);
583+
assertFalse(restarted.isDone());
584+
}
585+
}
586+
557587
@Test
558588
public void storeFailureOnPutCausesStreamRestart() throws Exception {
559589
DataStore badStore = dataStoreThatThrowsException(new RuntimeException("sorry"));

0 commit comments

Comments
 (0)