Skip to content

Commit 5464b92

Browse files
authored
Add debug code to verify the error (elastic#132709)
1 parent 751a32d commit 5464b92

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/SearchWithMinCompatibleSearchNodeIT.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.backwards;
99

1010
import org.apache.http.HttpHost;
11+
import org.apache.http.util.EntityUtils;
1112
import org.elasticsearch.Version;
1213
import org.elasticsearch.backwards.IndexingIT.Node;
1314
import org.elasticsearch.backwards.IndexingIT.Nodes;
@@ -24,6 +25,7 @@
2425
import org.junit.Before;
2526

2627
import java.io.IOException;
28+
import java.nio.charset.StandardCharsets;
2729
import java.util.ArrayList;
2830
import java.util.List;
2931
import 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

Comments
 (0)