@@ -77,19 +77,19 @@ public void cleanUpIndex() throws IOException {
7777 }
7878
7979 public void testEventsWithRequestToOldNodes () throws Exception {
80- assertEventsQueryOnNodes (bwcNodes );
80+ assertEventsQueryOnNodes (bwcNodes , true );
8181 }
8282
8383 public void testEventsWithRequestToUpgradedNodes () throws Exception {
84- assertEventsQueryOnNodes (newNodes );
84+ assertEventsQueryOnNodes (newNodes , false );
8585 }
8686
8787 public void testSequencesWithRequestToOldNodes () throws Exception {
88- assertSequncesQueryOnNodes (bwcNodes );
88+ assertSequncesQueryOnNodes (bwcNodes , true );
8989 }
9090
9191 public void testSequencesWithRequestToUpgradedNodes () throws Exception {
92- assertSequncesQueryOnNodes (newNodes );
92+ assertSequncesQueryOnNodes (newNodes , false );
9393 }
9494
9595 /**
@@ -268,7 +268,7 @@ public void testMultiValueFields() throws Exception {
268268 assertTrue (testedFunctions .containsAll (availableFunctions ));
269269 }
270270
271- private void assertEventsQueryOnNodes (List <TestNode > nodesList ) throws Exception {
271+ private void assertEventsQueryOnNodes (List <TestNode > nodesList , boolean oldNodes ) throws Exception {
272272 final String event = randomEvent ();
273273 Map <String , Object > expectedResponse = prepareEventsTestData (event );
274274 try (
@@ -278,12 +278,25 @@ private void assertEventsQueryOnNodes(List<TestNode> nodesList) throws Exception
278278 String filterPath = "filter_path=hits.events._source.@timestamp,hits.events._source.event_type,hits.events._source.sequence" ;
279279
280280 Request request = new Request ("POST" , index + "/_eql/search?" + filterPath );
281- request .setJsonEntity ("{\" query\" :\" " + event + " where true\" ,\" size\" :15}" );
282- assertBusy (() -> { assertResponse (expectedResponse , runEql (client , request )); });
281+ StringBuilder payload = new StringBuilder ("{\" query\" :\" " + event + " where true\" ,\" size\" :15" );
282+ // Old versions don't support this option
283+ if (oldNodes == false ) {
284+ if (randomBoolean ()) {
285+ payload .append (", \" allow_partial_search_results\" : " + randomBoolean ());
286+ }
287+ if (randomBoolean ()) {
288+ payload .append (", \" allow_partial_sequence_results\" : " + randomBoolean ());
289+ }
290+ }
291+ payload .append ("}" );
292+ request .setJsonEntity (payload .toString ());
293+ assertBusy (() -> {
294+ assertResponse (expectedResponse , runEql (client , request ));
295+ });
283296 }
284297 }
285298
286- private void assertSequncesQueryOnNodes (List <TestNode > nodesList ) throws Exception {
299+ private void assertSequncesQueryOnNodes (List <TestNode > nodesList , boolean oldNodes ) throws Exception {
287300 Map <String , Object > expectedResponse = prepareSequencesTestData ();
288301 try (
289302 RestClient client = buildClient (restClientSettings (), nodesList .stream ().map (TestNode ::publishAddress ).toArray (HttpHost []::new ))
@@ -294,7 +307,19 @@ private void assertSequncesQueryOnNodes(List<TestNode> nodesList) throws Excepti
294307 String filter = "{\" range\" :{\" @timestamp\" :{\" gte\" :\" 1970-05-01\" }}}" ;
295308
296309 Request request = new Request ("POST" , index + "/_eql/search?" + filterPath );
297- request .setJsonEntity ("{\" query\" :\" " + query + "\" ,\" filter\" :" + filter + "}" );
310+
311+ StringBuilder payload = new StringBuilder ("{\" query\" :\" " + query + "\" ,\" filter\" :" + filter );
312+ // Old versions don't support this option
313+ if (oldNodes == false ) {
314+ if (randomBoolean ()) {
315+ payload .append (", \" allow_partial_search_results\" : " + randomBoolean ());
316+ }
317+ if (randomBoolean ()) {
318+ payload .append (", \" allow_partial_sequence_results\" : " + randomBoolean ());
319+ }
320+ }
321+ payload .append ("}" );
322+ request .setJsonEntity (payload .toString ());
298323 assertBusy (() -> { assertResponse (expectedResponse , runEql (client , request )); });
299324 }
300325 }
0 commit comments