From da6555f82a894cd1c46eac3626a0c45ddc74108d Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Sun, 16 Mar 2025 07:47:49 -0700 Subject: [PATCH] Guard checking master node watching for file settings In tests for file settings the master node is started async. The assertion that the master node's file setting service is watching for changes must then wait until the async thread has started. Some tests already do that. This PR adjusts the remaining tests to similarly wait for the master node's watcher thread to start. closes #124279 --- .../reservedstate/service/FileSettingsServiceIT.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java index 85f0e2cf7e3ff..afbc9df1098aa 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java @@ -253,7 +253,7 @@ public void testSettingsApplied() throws Exception { FileSettingsService masterFileSettingsService = internalCluster().getInstance(FileSettingsService.class, masterNode); - assertTrue(masterFileSettingsService.watching()); + assertBusy(() -> assertTrue(masterFileSettingsService.watching())); assertFalse(dataFileSettingsService.watching()); writeJSONFile(masterNode, testJSON, logger, versionCounter.incrementAndGet()); @@ -279,7 +279,7 @@ public void testSettingsAppliedOnStart() throws Exception { FileSettingsService masterFileSettingsService = internalCluster().getInstance(FileSettingsService.class, masterNode); - assertTrue(masterFileSettingsService.watching()); + assertBusy(() -> assertTrue(masterFileSettingsService.watching())); assertFalse(dataFileSettingsService.watching()); assertClusterStateSaveOK(savedClusterState.v1(), savedClusterState.v2(), "50mb"); @@ -374,7 +374,7 @@ public void testErrorSaved() throws Exception { FileSettingsService masterFileSettingsService = internalCluster().getInstance(FileSettingsService.class, masterNode); - assertTrue(masterFileSettingsService.watching()); + assertBusy(() -> assertTrue(masterFileSettingsService.watching())); assertFalse(dataFileSettingsService.watching()); writeJSONFile(masterNode, testErrorJSON, logger, versionCounter.incrementAndGet()); @@ -470,7 +470,7 @@ public void testSettingsAppliedOnMasterReElection() throws Exception { var savedClusterState = setupClusterStateListener(masterNode); FileSettingsService masterFileSettingsService = internalCluster().getInstance(FileSettingsService.class, masterNode); - assertTrue(masterFileSettingsService.watching()); + assertBusy(() -> assertTrue(masterFileSettingsService.watching())); writeJSONFile(masterNode, testJSON, logger, versionCounter.incrementAndGet()); assertClusterStateSaveOK(savedClusterState.v1(), savedClusterState.v2(), "50mb");