88package org .elasticsearch .backwards ;
99
1010import org .apache .http .HttpHost ;
11+ import org .apache .http .util .EntityUtils ;
1112import org .elasticsearch .Version ;
1213import org .elasticsearch .backwards .IndexingIT .Node ;
1314import org .elasticsearch .backwards .IndexingIT .Nodes ;
2425import org .junit .Before ;
2526
2627import java .io .IOException ;
28+ import java .nio .charset .StandardCharsets ;
2729import java .util .ArrayList ;
2830import java .util .List ;
2931import java .util .Map ;
@@ -45,8 +47,23 @@ public class SearchWithMinCompatibleSearchNodeIT extends ESRestTestCase {
4547 private static Version newVersion ;
4648
4749 @ Before
48- public void prepareTestData () throws IOException {
50+ public void prepareTestData () throws Exception {
4951 nodes = IndexingIT .buildNodeAndVersions (client ());
52+
53+ debugClusterVersions ();
54+
55+ assertBusy (() -> {
56+ Nodes n = IndexingIT .buildNodeAndVersions (client ());
57+ if (n .getNewNodes ().isEmpty () || n .getBWCNodes ().isEmpty ()) {
58+ debugClusterVersions ();
59+ throw new AssertionError ("cluster not mixed yet" );
60+ }
61+ nodes = n ; // update when mixed
62+ }, 6 , java .util .concurrent .TimeUnit .SECONDS );
63+
64+ assumeTrue ("requires >=1 NEW node" , nodes .getNewNodes ().isEmpty () == false );
65+ assumeTrue ("requires >=1 BWC node" , nodes .getBWCNodes ().isEmpty () == false );
66+
5067 numShards = nodes .size ();
5168 numDocs = randomIntBetween (numShards , 16 );
5269 bwcNodes = new ArrayList <>();
@@ -73,6 +90,14 @@ public void prepareTestData() throws IOException {
7390 }
7491 }
7592
93+ private void debugClusterVersions () throws IOException {
94+ Request r = new Request ("GET" , "/_cat/nodes?v&h=name,ip,version,roles" );
95+ r .addParameter ("format" , "json" );
96+ Response resp = client ().performRequest (r );
97+ String body = EntityUtils .toString (resp .getEntity (), StandardCharsets .UTF_8 );
98+ logger .info ("Available Nodes: {}" , body );
99+ }
100+
76101 public void testMinVersionAsNewVersion () throws Exception {
77102 Request newVersionRequest = new Request (
78103 "POST" ,
0 commit comments