ソースを参照

Add more debug info to SnapshotBasedRecoveryIT (#91745)

Relates #91383
Francisco Fernández Castaño 2 年 前
コミット
1203750520

+ 20 - 1
qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SnapshotBasedRecoveryIT.java

@@ -102,7 +102,12 @@ public class SnapshotBasedRecoveryIT extends AbstractRollingTestCase {
                 // Drop replicas
                 updateIndexSettings(indexName, Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0));
                 updateIndexSettings(indexName, Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1));
-                ensureGreen(indexName);
+                try {
+                    ensureGreen(indexName);
+                } catch (AssertionError e) {
+                    logAllocationExplain();
+                    throw e;
+                }
                 assertMatchAllReturnsAllDocuments(indexName, numDocs);
                 assertMatchQueryReturnsAllDocuments(indexName, numDocs);
             }
@@ -110,6 +115,20 @@ public class SnapshotBasedRecoveryIT extends AbstractRollingTestCase {
         }
     }
 
+    private void logAllocationExplain() throws Exception {
+        // Used to debug #91383
+        var request = new Request(HttpGet.METHOD_NAME, "_cluster/allocation/explain?include_disk_info=true&include_yes_decisions=true");
+        request.setJsonEntity("""
+                    {
+                      "index": "snapshot_based_recovery",
+                      "shard": 0,
+                      "primary": false
+                    }
+            """);
+        var response = client().performRequest(request);
+        logger.info("--> allocation explain {}", EntityUtils.toString(response.getEntity()));
+    }
+
     private List<String> getUpgradedNodeIds() throws IOException {
         Request request = new Request(HttpGet.METHOD_NAME, "_nodes/_all");
         Response response = client().performRequest(request);