From 53b1213b9b71d121792a15ea198cea9dbc2a666a Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Fri, 7 Jun 2024 22:04:34 +0200 Subject: [PATCH] I just want to know what's going on. Really. --- .../SynonymsManagementAPIServiceIT.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java index 8a138d93687dd..2dcff3caaf712 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java @@ -37,7 +37,7 @@ public void setUp() throws Exception { synonymsManagementAPIService = new SynonymsManagementAPIService(client()); } - public void testCreateManySynonyms() throws InterruptedException { + public void testCreateManySynonyms() throws Exception { CountDownLatch putLatch = new CountDownLatch(1); String synonymSetId = randomIdentifier(); int rulesNumber = randomIntBetween( @@ -64,27 +64,29 @@ public void onFailure(Exception e) { CountDownLatch getLatch = new CountDownLatch(1); // Also retrieve them - synonymsManagementAPIService.getSynonymSetRules( - synonymSetId, - 0, - SynonymsManagementAPIService.MAX_SYNONYMS_SETS, - new ActionListener<>() { - @Override - public void onResponse(PagedResult synonymRulePagedResult) { - // TODO This fails in CI but passes locally. Why? - // assertEquals(rulesNumber, synonymRulePagedResult.totalResults()); - // assertEquals(rulesNumber, synonymRulePagedResult.pageResults().length); - getLatch.countDown(); - } + assertBusy(() -> { + synonymsManagementAPIService.getSynonymSetRules( + synonymSetId, + 0, + SynonymsManagementAPIService.MAX_SYNONYMS_SETS, + new ActionListener<>() { + @Override + public void onResponse(PagedResult synonymRulePagedResult) { + // TODO This fails in CI but passes locally. Why? + assertEquals(rulesNumber, synonymRulePagedResult.totalResults()); + assertEquals(rulesNumber, synonymRulePagedResult.pageResults().length); + getLatch.countDown(); + } - @Override - public void onFailure(Exception e) { - fail(e); + @Override + public void onFailure(Exception e) { + fail(e); + } } - } - ); + ); + }, 5, TimeUnit.SECONDS); - getLatch.await(5, TimeUnit.SECONDS); + getLatch.await(10, TimeUnit.SECONDS); } public void testCreateTooManySynonymsAtOnce() throws InterruptedException { @@ -132,7 +134,7 @@ public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonym @Override public void onFailure(Exception e) { - fail("Shouldn't have failed to update a rule"); + fail(e); } }); }