imbajin commented on code in PR #2962:
URL: https://github.com/apache/hugegraph/pull/2962#discussion_r2930135904


##########
hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/raft/IpAuthHandlerTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.hugegraph.pd.raft;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hugegraph.pd.raft.auth.IpAuthHandler;
+import org.apache.hugegraph.testutil.Whitebox;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class IpAuthHandlerTest {
+
+    @After

Review Comment:
   ⚠️ These tests are order-dependent because the singleton is only cleared in 
`@After`. Earlier classes in `PDCoreSuiteTest` initialize `RaftEngine`, which 
creates `IpAuthHandler` before this class runs; after that, 
`IpAuthHandler.getInstance(Set)` here just returns the pre-existing singleton 
and ignores the allowlist passed by the test. That makes the assertions depend 
on suite execution order instead of the test input. Please reset the singleton 
in `@Before` as well, or isolate this class from the suite so each test starts 
from a clean handler instance.
   
   ```text
   PDCoreSuiteTest
       |
       +-- earlier test -> RaftEngine.init()
       |                   |
       |                   +-- IpAuthHandler singleton created
       |
       +-- IpAuthHandlerTest
               |
               +-- getInstance(new allowlist)
                       |
                       +-- returns old singleton
                               |
                               v
                         test input ignored
   ```



-- 
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]

Reply via email to