Skip to content

Fix test: set up mocks before starting the service #126719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Change testInvalidJSON to set up mocks before starting the service
  • Loading branch information
prdoyle committed Apr 11, 2025
commit dd0664432e8f0f39d107236f01fdb98461c8154f
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ tests:
- class: org.elasticsearch.xpack.ccr.FollowIndexSecurityIT
method: testCleanShardFollowTaskAfterDeleteFollower
issue: https://github.com/elastic/elasticsearch/issues/120339
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceTests
method: testInvalidJSON
issue: https://github.com/elastic/elasticsearch/issues/120482
- class: org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeToCharProcessorTests
issue: https://github.com/elastic/elasticsearch/issues/120575
- class: org.elasticsearch.xpack.inference.DefaultEndPointsIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,8 @@ public void testInvalidJSON() throws Exception {
// Don't really care about the initial state
Files.createDirectories(fileSettingsService.watchedFileDir());
doNothing().when(fileSettingsService).processInitialFilesMissing();
fileSettingsService.start();
fileSettingsService.clusterChanged(new ClusterChangedEvent("test", clusterService.state(), ClusterState.EMPTY_STATE));

// Now break the JSON and wait
// Prepare to await on a barrier when the file changes so we can sync up
CyclicBarrier fileChangeBarrier = new CyclicBarrier(2);
doAnswer((Answer<?>) invocation -> {
try {
Expand All @@ -340,6 +338,12 @@ public void testInvalidJSON() throws Exception {
awaitOrBust(fileChangeBarrier);
}
}).when(fileSettingsService).onProcessFileChangesException(eq(watchedFile), any());

// Kick off the service
fileSettingsService.start();
fileSettingsService.clusterChanged(new ClusterChangedEvent("test", clusterService.state(), ClusterState.EMPTY_STATE));

// Now break the JSON and wait
writeTestFile(watchedFile, "test_invalid_JSON");
awaitOrBust(fileChangeBarrier);

Expand Down