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

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


The following commit(s) were added to refs/heads/branch_9x by this push:
     new c81cfe46153 SOLR-17093: Collection restore API returns requestid when 
executed asynchronously (#2111)
c81cfe46153 is described below

commit c81cfe46153507ea4bcccb775cab4e40896a71ef
Author: Tomas Eduardo Fernandez Lobbe <[email protected]>
AuthorDate: Fri Dec 1 14:00:11 2023 -0800

    SOLR-17093: Collection restore API returns requestid when executed 
asynchronously (#2111)
---
 solr/CHANGES.txt                                            |  3 +++
 .../apache/solr/handler/admin/api/RestoreCollectionAPI.java |  6 +++++-
 .../api/collections/AbstractCloudBackupRestoreTestCase.java | 13 +++++++++----
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 08df35fc0ce..98aeb4d79f1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -62,6 +62,9 @@ Bug Fixes
 * SOLR-10653: When there's a UUIDField in the schema and atomic update touches 
another field
   the error occurs when leader updates replica (Mikhail Khludnev)
 
+* SOLR-17093: Collection restore API command now returns "requestid" when 
executed asynchronously like other APIs
+  (Tomás Fernández Löbbe)
+
 Dependency Upgrades
 ---------------------
 * SOLR-17012: Update Apache Hadoop to 3.3.6 and Apache Curator to 5.5.0 (Kevin 
Risden)
diff --git 
a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollectionAPI.java
 
b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollectionAPI.java
index b950abf44ec..b603d8d13f7 100644
--- 
a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollectionAPI.java
+++ 
b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCollectionAPI.java
@@ -144,10 +144,14 @@ public class RestoreCollectionAPI extends BackupAPIBase {
       throw remoteResponse.getException();
     }
 
+    if (requestBody.async != null) {
+      response.requestId = requestBody.async;
+      return response;
+    }
+
     // Values fetched from remoteResponse may be null
     response.successfulSubResponsesByNodeName = 
remoteResponse.getResponse().get("success");
     response.failedSubResponsesByNodeName = 
remoteResponse.getResponse().get("failure");
-
     return response;
   }
 
diff --git 
a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java
 
b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java
index d058a1b1641..e27d7bdcc5d 100644
--- 
a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java
+++ 
b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCloudBackupRestoreTestCase.java
@@ -172,7 +172,7 @@ public abstract class AbstractCloudBackupRestoreTestCase 
extends SolrCloudTestCa
       solrClient.commit(getCollectionName());
     }
 
-    testBackupAndRestore(getCollectionName(), backupReplFactor);
+    testBackupAndRestore(getCollectionName());
     testConfigBackupOnly("conf1", getCollectionName());
     testInvalidPath(getCollectionName());
   }
@@ -326,7 +326,7 @@ public abstract class AbstractCloudBackupRestoreTestCase 
extends SolrCloudTestCa
     return numDocs;
   }
 
-  private void testBackupAndRestore(String collectionName, int 
backupReplFactor) throws Exception {
+  private void testBackupAndRestore(String collectionName) throws Exception {
     String backupLocation = getBackupLocation();
     String backupName = BACKUPNAME_PREFIX + testSuffix;
 
@@ -347,7 +347,9 @@ public abstract class AbstractCloudBackupRestoreTestCase 
extends SolrCloudTestCa
       if (random().nextBoolean()) {
         assertEquals(0, backup.process(client).getStatus());
       } else {
-        assertEquals(RequestStatusState.COMPLETED, 
backup.processAndWait(client, 30)); // async
+        String asyncId = backup.processAsync(client);
+        assertNotNull(asyncId);
+        CollectionAdminRequest.waitForAsyncRequest(asyncId, client, 30);
       }
     }
 
@@ -395,10 +397,13 @@ public abstract class AbstractCloudBackupRestoreTestCase 
extends SolrCloudTestCa
     if (sameConfig == false) {
       restore.setConfigName("customConfigName");
     }
+
     if (random().nextBoolean()) {
       assertEquals(0, restore.process(client).getStatus());
     } else {
-      assertEquals(RequestStatusState.COMPLETED, 
restore.processAndWait(client, 60)); // async
+      String asyncId = restore.processAsync(client);
+      assertNotNull(asyncId);
+      CollectionAdminRequest.waitForAsyncRequest(asyncId, client, 60);
     }
     AbstractDistribZkTestBase.waitForRecoveriesToFinish(
         restoreCollectionName, ZkStateReader.from(client), 
log.isDebugEnabled(), true, 30);

Reply via email to