dsmiley commented on code in PR #5314:
URL: https://github.com/apache/solr/pull/5314#discussion_r4567558152


##########
solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/ZkClientClusterStateProviderTest.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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.client.solrj.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.cloud.ZkTestServer;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.Utils;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.data.Stat;
+import org.junit.Test;
+
+public class ZkClientClusterStateProviderTest extends SolrTestCaseJ4 {
+
+  private record ReadAttempt(String path, String failure) {}
+
+  private static class RecordingSolrZkClient extends SolrZkClient {
+    private final List<ReadAttempt> readAttempts = new 
CopyOnWriteArrayList<>();
+
+    RecordingSolrZkClient(Builder builder) {
+      super(builder);
+    }
+
+    @Override
+    public byte[] getData(String path, Watcher watcher, Stat stat)
+        throws KeeperException, InterruptedException {
+      try {
+        byte[] data = super.getData(path, watcher, stat);
+        readAttempts.add(new ReadAttempt(path, null));
+        return data;
+      } catch (KeeperException | InterruptedException e) {
+        readAttempts.add(new ReadAttempt(path, e.getClass().getSimpleName()));
+        throw e;
+      }
+    }
+
+    List<ReadAttempt> getReadAttempts() {
+      return List.copyOf(readAttempts);
+    }
+
+    void clearReadAttempts() {
+      readAttempts.clear();
+    }
+  }
+
+  @Test
+  public void testKnownAliasDoesNotReadAliasCollectionState() throws Exception 
{

Review Comment:
   while this is nice, testing this component in isolation doesn't tell me if 
CloudSolrClient isn't using this to do multiple resolutions.  This speaks to my 
desire to move state caching / alias lookup out of CloudSolrClient into the 
state provider so that CSC is simpler and then this test is something I have 
more faith in.  Still... I don't want to let seeking perfection get in the way 
of progress.  You've already demonstrated/tested this should not introduce a 
regression.
   
   Q: RE the "recording" client above; did my suggestion to use metrics not 
work out?



##########
solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/ZkClientClusterStateProviderTest.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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.client.solrj.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.cloud.ZkTestServer;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.Utils;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.data.Stat;
+import org.junit.Test;
+
+public class ZkClientClusterStateProviderTest extends SolrTestCaseJ4 {

Review Comment:
   please use SolrTestCase for new tests



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to