You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ge...@apache.org on 2023/03/06 16:47:18 UTC

[solr] branch main updated: SOLR-16462: Fix TestSolrCloudSnapshot failures

This is an automated email from the ASF dual-hosted git repository.

gerlowskija pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new c759083ec6e SOLR-16462: Fix TestSolrCloudSnapshot failures
c759083ec6e is described below

commit c759083ec6ebc692e7e05dec8e3e02ff3a6fff2e
Author: Jason Gerlowski <ge...@apache.org>
AuthorDate: Mon Mar 6 11:38:37 2023 -0500

    SOLR-16462: Fix TestSolrCloudSnapshot failures
    
    Test runs on the previous fix for SOLR-16462 failed to catch issues
    with a nightly test, TestSolrCloudSnapshots.  This commit fixes the
    nightly test, hopefully resolving the 100% test failure.
---
 .../core/snapshots/TestSolrCloudSnapshots.java     | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
index ee248178e21..ecff729bf78 100644
--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java
@@ -342,25 +342,23 @@ public class TestSolrCloudSnapshots extends SolrCloudTestCase {
     return result;
   }
 
+  @SuppressWarnings("unchecked")
   private Collection<SnapshotMetaData> listCoreSnapshots(SolrClient adminClient, String coreName)
       throws Exception {
     ListSnapshots req = new ListSnapshots();
     req.setCoreName(coreName);
     NamedList<?> resp = adminClient.request(req);
-    assertTrue(resp.get(SolrSnapshotManager.SNAPSHOTS_INFO) instanceof NamedList);
-    NamedList<?> apiResult = (NamedList<?>) resp.get(SolrSnapshotManager.SNAPSHOTS_INFO);
+    assertTrue(resp.get(SolrSnapshotManager.SNAPSHOTS_INFO) instanceof Map);
+    Map<String, Object> apiResult =
+        (Map<String, Object>) resp.get(SolrSnapshotManager.SNAPSHOTS_INFO);
 
     List<SnapshotMetaData> result = new ArrayList<>(apiResult.size());
-    for (int i = 0; i < apiResult.size(); i++) {
-      String commitName = apiResult.getName(i);
-      String indexDirPath =
-          (String)
-              ((NamedList<?>) apiResult.get(commitName)).get(SolrSnapshotManager.INDEX_DIR_PATH);
-      long genNumber =
-          Long.parseLong(
-              (String)
-                  ((NamedList<?>) apiResult.get(commitName))
-                      .get(SolrSnapshotManager.GENERATION_NUM));
+    for (Map.Entry<String, Object> entry : apiResult.entrySet()) {
+      final String commitName = entry.getKey();
+      final String indexDirPath =
+          (String) ((Map<String, Object>) entry.getValue()).get(SolrSnapshotManager.INDEX_DIR_PATH);
+      final long genNumber =
+          (Long) ((Map<String, Object>) entry.getValue()).get(SolrSnapshotManager.GENERATION_NUM);
       result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber));
     }
     return result;