Skip to content

Commit

Permalink
Spy on onProcessFileChangesException (#120421)
Browse files Browse the repository at this point in the history
  • Loading branch information
prdoyle authored Jan 17, 2025
1 parent 53cca8e commit 1e19596
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public void testInitialFileError() throws Exception {
// wait until the watcher thread has started, and it has discovered the file
assertTrue(latch.await(20, TimeUnit.SECONDS));

// Note: the name "processFileOnServiceStart" is a bit misleading because it is not
// referring to fileSettingsService.start(). Rather, it is referring to the initialization
// of the watcher thread itself, which occurs asynchronously when clusterChanged is first called.
verify(fileSettingsService, times(1)).processFileOnServiceStart();
verify(controller, times(1)).process(any(), any(XContentParser.class), eq(ReservedStateVersionCheck.HIGHER_OR_SAME_VERSION), any());
// assert we never notified any listeners of successful application of file based settings
Expand Down Expand Up @@ -312,7 +315,7 @@ public void testInvalidJSON() throws Exception {
} finally {
awaitOrBust(fileChangeBarrier);
}
}).when(fileSettingsService).processFileChanges();
}).when(fileSettingsService).onProcessFileChangesException(any());
writeTestFile(fileSettingsService.watchedFile(), "test_invalid_JSON");
awaitOrBust(fileChangeBarrier);

Expand All @@ -326,10 +329,6 @@ public void testInvalidJSON() throws Exception {
argThat(e -> unwrapException(e) instanceof XContentParseException)
);

// Note: the name "processFileOnServiceStart" is a bit misleading because it is not
// referring to fileSettingsService.start(). Rather, it is referring to the initialization
// of the watcher thread itself, which occurs asynchronously when clusterChanged is first called.

assertEquals(YELLOW, healthIndicatorService.calculate(false, null).status());
verify(healthIndicatorService, Mockito.atLeast(1)).failureOccurred(contains(XContentParseException.class.getName()));
}
Expand Down

0 comments on commit 1e19596

Please sign in to comment.