From fd14e80174654374a1c91fe71083bd72aa789d33 Mon Sep 17 00:00:00 2001 From: Michael Froh Date: Thu, 19 Dec 2024 11:58:55 -0800 Subject: [PATCH] Prevent cascading test failures in SearchServiceTests I'm not really fixing the failing tests, but ensuring that the two tests that fail don't cause a bunch of other tests to fail by leaving transient settings around. (Clean up the transient settings even if those tests fail.) Signed-off-by: Michael Froh --- .../opensearch/search/SearchServiceTests.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/server/src/test/java/org/opensearch/search/SearchServiceTests.java b/server/src/test/java/org/opensearch/search/SearchServiceTests.java index 852f84601fba2..133509af2467c 100644 --- a/server/src/test/java/org/opensearch/search/SearchServiceTests.java +++ b/server/src/test/java/org/opensearch/search/SearchServiceTests.java @@ -1585,15 +1585,15 @@ public void testConcurrentSegmentSearchWithRandomizedModeSettings() throws IOExc } else { assertNull(searchContext.searcher().getTaskExecutor()); } - } - - // Cleanup - client().admin() - .cluster() - .prepareUpdateSettings() - .setTransientSettings(Settings.builder().putNull(SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_MODE.getKey())) - .get(); + } finally { + // Cleanup + client().admin() + .cluster() + .prepareUpdateSettings() + .setTransientSettings(Settings.builder().putNull(SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_MODE.getKey())) + .get(); + } } /** @@ -1749,15 +1749,15 @@ public void testConcurrentSegmentSearchIsSetOnceDuringContextCreation() throws I // verify that concurrent segment search is still set to same expected value for the context assertEquals(concurrentSearchSetting, searchContext.shouldUseConcurrentSearch()); + } finally { + // Cleanup + client().admin() + .cluster() + .prepareUpdateSettings() + .setTransientSettings(Settings.builder().putNull(SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey())) + .get(); } } - - // Cleanup - client().admin() - .cluster() - .prepareUpdateSettings() - .setTransientSettings(Settings.builder().putNull(SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey())) - .get(); } /**