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

Commit

Permalink
add test for stream not restarting if store doesn't tell it to
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly committed Apr 15, 2020
1 parent 785e1aa commit 9dbefe3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/java/com/launchdarkly/sdk/server/StreamProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,36 @@ public void restartsStreamIfStoreNeedsRefresh() throws Exception {
}
}

@Test
public void doesNotRestartStreamIfStoreHadOutageButDoesNotNeedRefresh() throws Exception {
TestComponents.DataStoreWithStatusUpdates storeWithStatus = new TestComponents.DataStoreWithStatusUpdates(dataStore);

SettableFuture<Void> restarted = SettableFuture.create();
mockEventSource.start();
expectLastCall();
mockEventSource.restart();
expectLastCall().andAnswer(() -> {
restarted.set(null);
return null;
});
mockEventSource.close();
expectLastCall();
mockRequestor.close();
expectLastCall();

replayAll();

try (StreamProcessor sp = createStreamProcessorWithStore(storeWithStatus)) {
sp.start();

storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(false, false));
storeWithStatus.broadcastStatusChange(new DataStoreStatusProvider.Status(true, false));

Thread.sleep(500);
assertFalse(restarted.isDone());
}
}

@Test
public void storeFailureOnPutCausesStreamRestart() throws Exception {
DataStore badStore = dataStoreThatThrowsException(new RuntimeException("sorry"));
Expand Down

0 comments on commit 9dbefe3

Please sign in to comment.