gerlowskija commented on code in PR #3023:
URL: https://github.com/apache/solr/pull/3023#discussion_r2027395629


##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?

Review Comment:
   We're still pretty "early days" in our adoption of Jackson for deserializing 
response types, so I wouldn't say we have an established pattern around this.
   
   We generate SolrRequest/SolrResponse client objects, which use Jackson to 
deserialize responses internally.  But if you're looking to invoke the APIs 
directly, then using an ObjectMapper as you're doing here is probably the best 
bet.
   
   One tweak though - you could reuse an existing ObjectMapper rather than 
creating your own. `JacksonContentWriter.DEFAULT_MAPPER` should be good - 
that's the one that we use in SolrJ.  



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """
+                {
+                  "name": "testCollection",
+                  "numShards": 1,
+                  "nrtReplicas": 2
+                }
+                """);
+
+        final String collectionPath = "/collections/testCollection";
+        canGet(collectionPath);
+//        canGet(collectionPath+"-not-a-collection"); // TODO returns 500, 
should be 404

Review Comment:
   [0] Thanks for flagging this here!  Eventually we can create JIRA tickets 
for this and similar bugs you've found, and then we can update the comment to 
reference the ticket, e.g.:
   
   > // TODO Uncomment when SOLR-##### is fixed.



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """

Review Comment:
   [0] I don't follow Java language developments all that closely and only 
learned about the multi-line String support earlier this week.  But I love it - 
very cool to see you using them here 👍 



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """
+                {
+                  "name": "testCollection",
+                  "numShards": 1,
+                  "nrtReplicas": 2
+                }
+                """);
+
+        final String collectionPath = "/collections/testCollection";
+        canGet(collectionPath);
+//        canGet(collectionPath+"-not-a-collection"); // TODO returns 500, 
should be 404
+
+        canPut(collectionPath + "/properties/foo", """
+                {
+                  "value": "bar"
+                }
+                """);
+        canDelete(collectionPath + "/properties/foo");
+
+        canPost(collectionPath + "/balance-shard-unique", """
+                {
+                  "property": "preferredLeader"
+                }
+                """);
+
+        Path v2apiBackupPath = createTempDir("v2apiBackup");
+        canPost(collectionPath + "/backups/testBackup/versions", 
String.format(Locale.ROOT, """
+                {
+                    "location": "file:///%s"
+                }
+                """, v2apiBackupPath.toString().replace("\\", "/")));
+
+        canPost(collectionPath + "/reload", "{}");
+
+        // TODO: is there a better API to GET the list of shards for a 
collection rather than the cluster status?
+        // Or use implict and create / delete
+        String shardName = canGet("/cluster", 
TestClusterResponseStub.class).cluster.collections.get("testCollection").shards.keySet().stream().findAny().get();

Review Comment:
   [-0] If you switch to `/collections/collName` you can avoid 
TestClusterResponseStub.  (At least in this case..)



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """
+                {
+                  "name": "testCollection",
+                  "numShards": 1,
+                  "nrtReplicas": 2
+                }
+                """);
+
+        final String collectionPath = "/collections/testCollection";
+        canGet(collectionPath);
+//        canGet(collectionPath+"-not-a-collection"); // TODO returns 500, 
should be 404
+
+        canPut(collectionPath + "/properties/foo", """
+                {
+                  "value": "bar"
+                }
+                """);
+        canDelete(collectionPath + "/properties/foo");
+
+        canPost(collectionPath + "/balance-shard-unique", """
+                {
+                  "property": "preferredLeader"
+                }
+                """);
+
+        Path v2apiBackupPath = createTempDir("v2apiBackup");
+        canPost(collectionPath + "/backups/testBackup/versions", 
String.format(Locale.ROOT, """
+                {
+                    "location": "file:///%s"
+                }
+                """, v2apiBackupPath.toString().replace("\\", "/")));
+
+        canPost(collectionPath + "/reload", "{}");
+
+        // TODO: is there a better API to GET the list of shards for a 
collection rather than the cluster status?
+        // Or use implict and create / delete
+        String shardName = canGet("/cluster", 
TestClusterResponseStub.class).cluster.collections.get("testCollection").shards.keySet().stream().findAny().get();
+
+//        canPost(collectionPath + "/shards", """
+//                {
+//                    "name": "s1"
+//                }
+//                """);
+        String shardPath = collectionPath + "/shards/" + shardName;
+//        canPost(shardPath + "/force-leader", "{}"); // TODO: 500 - The shard 
already has an active leader. Force leader is not applicable.
+        canPost(shardPath + "/replicas", "{}");
+//        canDelete(shardPath + "/replicas/{replicaName}");
+//        canDelete(shardPath + "/replicas");
+//        canPost(shardPath + "/sync", "{}"); // TODO: 500 - Sync Failed
+//        canPost(shardPath + "/install", """
+//                {
+//                    "location": "TODO"
+//                }
+//                """);
+//        canPut(shardPath + "/replicas/{replicaName}/properties/{propName}");
+//        canDelete(shardPath + 
"/replicas/{replicaName}/properties/{propName}");
+//        canDelete(shardPath);
+
+        canGet(collectionPath + "/snapshots");
+        //canPost(collectionPath + "/snapshots/snap123", "{}"); // TODO 
expected:<200> but was:<405>
+        canDelete(collectionPath + "/snapshots/snap123");
+
+        testCollectionsAndCoresApi("collections", "testCollection");
+
+        canPut(collectionPath + "/scale", """
+                {
+                    "count" : 1
+                }
+                """);
+        // TODO: This randomly fails, need to wait for something I guess...
+        // java.lang.NullPointerException: Cannot invoke 
"org.apache.solr.request.SolrQueryRequest.getRequestTimer()" because 
"solrQueryRequest" is null
+        //     at 
org.apache.solr.jersey.PostRequestDecorationFilter.filter(PostRequestDecorationFilter.java:65)
+        //     at 
org.glassfish.jersey.server.ContainerFilteringStage$ResponseFilterStage.apply(ContainerFilteringStage.java:172)
+        canPost(collectionPath + "/rename", """
+                {
+                  "to": "test123"
+                }
+                """);
+        canDelete("/aliases/test123");
+        canDelete(collectionPath);
+    }
+
+    @Test
+    public void testAliasesApi() throws Exception {
+        canPost("/collections", """
+                {
+                  "name": "aCollection",
+                  "numShards": 1
+                }
+                """);
+
+        canGet("/aliases");
+        canPost("/aliases", """
+                {
+                  "name": "foo",
+                  "collections": ["aCollection"]
+                }
+                """);
+        //canGet("/aliases/foo"); // TODO@ BUG = 405 - GET is hidden by 
overloaded @Path...

Review Comment:
   [0] Gah - that's a pretty serious bug!  Really puts egg on my face, and 
shows the value in having these tests 👍 



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {

Review Comment:
   [-0] You can get rid of this.  SolrCloudTestCase and other base classes have 
a test `@Rule` that clears out any unwanted sysprops after each run, so this 
*should* happen automatically 👍 



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """
+                {
+                  "name": "testCollection",
+                  "numShards": 1,
+                  "nrtReplicas": 2
+                }
+                """);
+
+        final String collectionPath = "/collections/testCollection";
+        canGet(collectionPath);
+//        canGet(collectionPath+"-not-a-collection"); // TODO returns 500, 
should be 404
+
+        canPut(collectionPath + "/properties/foo", """
+                {
+                  "value": "bar"
+                }
+                """);
+        canDelete(collectionPath + "/properties/foo");
+
+        canPost(collectionPath + "/balance-shard-unique", """
+                {
+                  "property": "preferredLeader"
+                }
+                """);
+
+        Path v2apiBackupPath = createTempDir("v2apiBackup");
+        canPost(collectionPath + "/backups/testBackup/versions", 
String.format(Locale.ROOT, """
+                {
+                    "location": "file:///%s"
+                }
+                """, v2apiBackupPath.toString().replace("\\", "/")));
+
+        canPost(collectionPath + "/reload", "{}");
+
+        // TODO: is there a better API to GET the list of shards for a 
collection rather than the cluster status?

Review Comment:
   [-0] There is, yep!  You can get the status for a single collection with 
`GET /collections/collName`, and it will return you a 
[CollectionStatusResponse](https://github.com/apache/solr/blob/main/solr/api/src/java/org/apache/solr/client/api/model/CollectionStatusResponse.java)



##########
solr/core/src/test/org/apache/solr/handler/admin/api/V2APISmokeTest.java:
##########
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class V2APISmokeTest extends SolrCloudTestCase {
+
+    // TODO: How is this normally done in these tests?
+    private final ObjectMapper objectMapper = new ObjectMapper()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+    private URL baseUrl;
+    private String baseUrlV2;
+
+    @BeforeClass
+    public static void setupCluster() throws Exception {
+        System.setProperty("enable.packages", "true"); // for file upload
+        System.setProperty("solr.allowPaths", "*"); // for backups
+        configureCluster(2).addConfig("conf", 
configset("cloud-minimal")).configure();
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
+        baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
+    }
+
+    @AfterClass
+    public static void teardownClass() {
+        System.clearProperty("enable.packages");
+        System.clearProperty("solr.allowPaths");
+    }
+
+    @Test
+    public void testCollectionsApi() throws Exception {
+        canGet("/collections");
+        canPost("/collections", """
+                {
+                  "name": "testCollection",
+                  "numShards": 1,
+                  "nrtReplicas": 2
+                }
+                """);
+
+        final String collectionPath = "/collections/testCollection";
+        canGet(collectionPath);
+//        canGet(collectionPath+"-not-a-collection"); // TODO returns 500, 
should be 404
+
+        canPut(collectionPath + "/properties/foo", """
+                {
+                  "value": "bar"
+                }
+                """);
+        canDelete(collectionPath + "/properties/foo");
+
+        canPost(collectionPath + "/balance-shard-unique", """
+                {
+                  "property": "preferredLeader"
+                }
+                """);
+
+        Path v2apiBackupPath = createTempDir("v2apiBackup");

Review Comment:
   [-0] IMO backups are worth splitting into a different test case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to