You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/11/30 17:55:00 UTC

[GitHub] [solr] gerlowskija commented on a diff in pull request #1196: SOLR-11029 Create a v2 API equivalent for DELETENODE API

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


##########
solr/core/src/test/org/apache/solr/handler/admin/api/DeleteNodeAPITest.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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 static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Map;
+import java.util.Optional;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.cloud.OverseerSolrResponse;
+import org.apache.solr.cloud.api.collections.DistributedCollectionConfigSetCommandRunner;
+import org.apache.solr.common.cloud.ZkNodeProps;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+/** Unit tests for {@link DeleteNodeAPI} */
+public class DeleteNodeAPITest extends SolrTestCaseJ4 {

Review Comment:
   [-1] These tests look great to me, and are in line with many tests I've written for v2 work I've done up to this point.
   
   But...I have gotten some pushback recently from other committers (namely, David Smiley) about the pros and cons of using mocks for this sort of testing.  We had an extended back and forth, which is best summed up in the comment [here](https://github.com/apache/solr/pull/1053#discussion_r1016747436).
   
   The main takeaway I think is that we don't have to avoid mocks altogether, but since there's ambivalence about them in the community we should avoid them where we can.
   
   Specifically as it relates to this PR: we can validate the remote-message-creation logic without using mocks as long as we first refactor the message-creation logic, either into its own class, or into a `public static` method on DeleteNodeAPI, etc. The DELETEREPLICAPROPERTY API does this, you can look at the logic [here](https://github.com/apache/solr/pull/1053/files#diff-b4b71c67538ee9d3a8d34009f897e769879415fdb72b5decd7d63b7969dd8163R112) and the test code [here](https://github.com/apache/solr/pull/1053/files#diff-dc9ca75519c56fbe39d31e41e65506360ecba2d3488267b717c4127ae0cceef1R137) as examples.
   
   Would you be willing to make that change?



-- 
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-unsubscribe@solr.apache.org

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


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