kezhuw commented on code in PR #2200:
URL: https://github.com/apache/zookeeper/pull/2200#discussion_r1801233489


##########
zookeeper-server/src/test/java/org/apache/zookeeper/test/ReadOnlyModeWithSSLTest.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.zookeeper.test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.ByteArrayOutputStream;
+import java.io.LineNumberReader;
+import java.io.StringReader;
+import java.util.regex.Pattern;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.ZKTestCase;
+import org.apache.zookeeper.ZooDefs;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.client.ZKClientConfig;
+import org.apache.zookeeper.common.ClientX509Util;
+import org.apache.zookeeper.common.StringUtils;
+import org.apache.zookeeper.server.NettyServerCnxnFactory;
+import org.apache.zookeeper.server.ServerCnxnFactory;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.LoggerFactory;
+
+public class ReadOnlyModeWithSSLTest extends ZKTestCase {
+
+    private static final org.slf4j.Logger LOG = 
LoggerFactory.getLogger(ReadOnlyModeWithSSLTest.class);
+    private static int CONNECTION_TIMEOUT = QuorumBase.CONNECTION_TIMEOUT;
+    private QuorumUtil qu = new QuorumUtil(1);
+    private ClientX509Util clientX509Util;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        System.setProperty("readonlymode.enabled", "true");
+        System.setProperty(NettyServerCnxnFactory.PORT_UNIFICATION_KEY, 
Boolean.TRUE.toString());
+        clientX509Util = new ClientX509Util();
+        String testDataPath = System.getProperty("test.data.dir", 
"src/test/resources/data");
+        System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, 
"org.apache.zookeeper.server.NettyServerCnxnFactory");
+        System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, 
"org.apache.zookeeper.ClientCnxnSocketNetty");
+        System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
+        System.setProperty(clientX509Util.getSslKeystoreLocationProperty(), 
testDataPath + "/ssl/testKeyStore.jks");

Review Comment:
   > Is it preferable to prioritize the use of ClientConfig over system 
properties?
   
   Client should use `ZKClientConfig` instead system properties after 
constructed. If not, it is a bug. So, 
https://github.com/apache/zookeeper/commit/33c19e370d78a7bc0ab4a9e8b085b4cf8191123d#diff-9657d4a14708c9ec1df56fd01581a442e10ef70cae39c7223d4f979b0ae54263R1307
 is buggy as it does not use the one in constructor but the `new ZkConfig()`. 
These two are necessary to have same properties. It should use 
`ClientCnxn.clientConfig` which means 
https://github.com/apache/zookeeper/commit/b13e1966efc8006f7b5be813329751939a83c26b#diff-9657d4a14708c9ec1df56fd01581a442e10ef70cae39c7223d4f979b0ae54263R1359
 is correct.
   
   
https://github.com/apache/zookeeper/blob/b99714543db86ca081a5d648c565f0d9cb4c82c2/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java#L1099
   
   > If the properties are not already set in the ClientConfig, then we can 
retrieve them from the system properties.
   
   This is already done in construction of a `ZKConfig`.



-- 
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: notifications-unsubscr...@zookeeper.apache.org

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

Reply via email to