Skip to content

Commit b85e649

Browse files
authored
Relax assertion - remove unnecessary times(1) (#118497)
1 parent f4dc716 commit b85e649

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,6 @@ tests:
314314
issue: https://github.com/elastic/elasticsearch/issues/118220
315315
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
316316
issue: https://github.com/elastic/elasticsearch/issues/118238
317-
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceTests
318-
method: testInvalidJSON
319-
issue: https://github.com/elastic/elasticsearch/issues/116521
320317

321318
# Examples:
322319
#

server/src/test/java/org/elasticsearch/reservedstate/service/FileSettingsServiceTests.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.xcontent.XContentParser;
4444
import org.junit.After;
4545
import org.junit.Before;
46+
import org.mockito.Mockito;
4647
import org.mockito.stubbing.Answer;
4748

4849
import java.io.IOException;
@@ -315,7 +316,13 @@ public void testInvalidJSON() throws Exception {
315316
writeTestFile(fileSettingsService.watchedFile(), "test_invalid_JSON");
316317
awaitOrBust(fileChangeBarrier);
317318

318-
verify(fileSettingsService, times(1)).onProcessFileChangesException(
319+
// These checks use atLeast(1) because the initial JSON is also invalid,
320+
// and so we sometimes get two calls to these error-reporting methods
321+
// depending on timing. Rather than trace down the root cause and fix
322+
// it, we tolerate this for now because, hey, invalid JSON is invalid JSON
323+
// and this is still testing what we want to test.
324+
325+
verify(fileSettingsService, Mockito.atLeast(1)).onProcessFileChangesException(
319326
argThat(e -> unwrapException(e) instanceof XContentParseException)
320327
);
321328

@@ -324,7 +331,7 @@ public void testInvalidJSON() throws Exception {
324331
// of the watcher thread itself, which occurs asynchronously when clusterChanged is first called.
325332

326333
assertEquals(YELLOW, healthIndicatorService.calculate(false, null).status());
327-
verify(healthIndicatorService).failureOccurred(contains(XContentParseException.class.getName()));
334+
verify(healthIndicatorService, Mockito.atLeast(1)).failureOccurred(contains(XContentParseException.class.getName()));
328335
}
329336

330337
/**

0 commit comments

Comments
 (0)