From 9ff259c260ba976f9687d73e07b458aa0a274384 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 17 Jul 2017 18:49:50 +0200 Subject: [PATCH] Use concrete version for BWC checks in SearchTransportService (#25748) We used to compare agaisnt the min compatible version which is misleading since it might move over time and since we backported the `can_match` API entirely it's better to compare against a version constant. --- .../action/search/SearchTransportService.java | 5 ++--- .../action/search/CanMatchPreFilterSearchPhaseTests.java | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index 3bd1b125c9f..d9c60438efc 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -105,7 +105,7 @@ public class SearchTransportService extends AbstractComponent { public void sendCanMatch(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task, final ActionListener listener) { - if (connection.getNode().getVersion().onOrAfter(Version.CURRENT.minimumCompatibilityVersion())) { + if (connection.getNode().getVersion().onOrAfter(Version.V_5_6_0)) { transportService.sendChildRequest(connection, QUERY_CAN_MATCH_NAME, request, task, TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(listener, CanMatchResponse::new)); } else { @@ -114,8 +114,7 @@ public class SearchTransportService extends AbstractComponent { // instead of sending the request we shortcut it here and let the caller deal with this -- see #25704 // also failing the request instead of returning a fake answer might trigger a retry on a replica which might be on a // compatible node - throw new IllegalArgumentException("can_match is not supported on pre "+ Version.CURRENT.minimumCompatibilityVersion() + - " nodes"); + throw new IllegalArgumentException("can_match is not supported on pre 5.6 nodes"); } } diff --git a/core/src/test/java/org/elasticsearch/action/search/CanMatchPreFilterSearchPhaseTests.java b/core/src/test/java/org/elasticsearch/action/search/CanMatchPreFilterSearchPhaseTests.java index 8d2ef87fcbf..9993d8af57c 100644 --- a/core/src/test/java/org/elasticsearch/action/search/CanMatchPreFilterSearchPhaseTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/CanMatchPreFilterSearchPhaseTests.java @@ -106,13 +106,12 @@ public class CanMatchPreFilterSearchPhaseTests extends ESTestCase { public void testOldNodesTriggerException() { SearchTransportService searchTransportService = new SearchTransportService( Settings.builder().put("search.remote.connect", false).build(), null); - DiscoveryNode node = new DiscoveryNode("node_1", buildNewFakeTransportAddress(), VersionUtils.getPreviousVersion(Version - .CURRENT.minimumCompatibilityVersion())); + DiscoveryNode node = new DiscoveryNode("node_1", buildNewFakeTransportAddress(), VersionUtils.randomVersionBetween(random(), + VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_5_6_0))); SearchAsyncActionTests.MockConnection mockConnection = new SearchAsyncActionTests.MockConnection(node); IllegalArgumentException illegalArgumentException = expectThrows(IllegalArgumentException.class, () -> searchTransportService.sendCanMatch(mockConnection, null, null, null)); - assertEquals("can_match is not supported on pre " + Version - .CURRENT.minimumCompatibilityVersion() + " nodes", illegalArgumentException.getMessage()); + assertEquals("can_match is not supported on pre 5.6 nodes", illegalArgumentException.getMessage()); } public void testFilterWithFailure() throws InterruptedException {