diff --git a/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java index d53a057634e51..8e0f07ea09473 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/synonyms/SynonymsManagementAPIServiceIT.java @@ -38,17 +38,19 @@ public void setUp() throws Exception { } public void testCreateManySynonyms() throws InterruptedException { - CountDownLatch latch = new CountDownLatch(1); + CountDownLatch putLatch = new CountDownLatch(1); + String synonymSetId = randomIdentifier(); + int rulesNumber = randomIntBetween( + SynonymsManagementAPIService.MAX_SYNONYMS_SETS / 2, + SynonymsManagementAPIService.MAX_SYNONYMS_SETS + ); synonymsManagementAPIService.putSynonymsSet( - randomIdentifier(), - randomSynonymsSet( - randomIntBetween(SynonymsManagementAPIService.MAX_SYNONYMS_SETS / 2, SynonymsManagementAPIService.MAX_SYNONYMS_SETS), - SynonymsManagementAPIService.MAX_SYNONYMS_SETS - ), + synonymSetId, + randomSynonymsSet(rulesNumber, rulesNumber), new ActionListener() { @Override public void onResponse(SynonymsManagementAPIService.SynonymsReloadResult synonymsReloadResult) { - latch.countDown(); + putLatch.countDown(); } @Override @@ -58,7 +60,30 @@ public void onFailure(Exception e) { } ); - latch.await(5, TimeUnit.SECONDS); + putLatch.await(5, TimeUnit.SECONDS); + + CountDownLatch getLatch = new CountDownLatch(1); + // Also retrieve them + synonymsManagementAPIService.getSynonymSetRules( + synonymSetId, + 0, + SynonymsManagementAPIService.MAX_SYNONYMS_SETS, + new ActionListener>() { + @Override + public void onResponse(PagedResult synonymRulePagedResult) { + assertEquals(rulesNumber, synonymRulePagedResult.totalResults()); + assertEquals(rulesNumber, synonymRulePagedResult.pageResults().length); + getLatch.countDown(); + } + + @Override + public void onFailure(Exception e) { + fail(e); + } + } + ); + + getLatch.await(5, TimeUnit.SECONDS); } public void testCreateTooManySynonymsAtOnce() throws InterruptedException {