This is an automated email from the ASF dual-hosted git repository.

vgalaxies pushed a commit to branch fix-pd-test
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit ad5b5f233a462fa5ed54f38b490917e94007d972
Author: VGalaxies <[email protected]>
AuthorDate: Sat Mar 16 12:16:17 2024 +0800

    adapt some tests
---
 .../apache/hugegraph/pd/MonitorServiceTest.java    |  2 --
 .../apache/hugegraph/pd/PartitionCacheTest.java    |  5 ++--
 .../apache/hugegraph/pd/StoreNodeServiceTest.java  | 31 +++++++---------------
 .../java/org/apache/hugegraph/pd/UnitTestBase.java | 31 ----------------------
 4 files changed, 13 insertions(+), 56 deletions(-)

diff --git 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/MonitorServiceTest.java
 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/MonitorServiceTest.java
index 25272127f..39de8bda4 100644
--- 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/MonitorServiceTest.java
+++ 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/MonitorServiceTest.java
@@ -25,8 +25,6 @@ import org.apache.hugegraph.pd.grpc.Metapb;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 
-// import org.junit.Test;
-
 public class MonitorServiceTest {
     static PDConfig pdConfig;
 
diff --git 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/PartitionCacheTest.java
 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/PartitionCacheTest.java
index 71efa70ec..dc48f3f0a 100644
--- 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/PartitionCacheTest.java
+++ 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/PartitionCacheTest.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.hugegraph.pd.common.KVPair;
 import org.apache.hugegraph.pd.common.PartitionCache;
 import org.apache.hugegraph.pd.grpc.Metapb;
+import org.junit.Test;
 
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeMap;
@@ -32,7 +33,7 @@ import com.google.common.collect.TreeRangeMap;
 
 public class PartitionCacheTest {
 
-    // @Test
+    @Test
     public void test() {
         PartitionCache cache = new PartitionCache();
         for (int i = 0; i < 10; i++) {
@@ -51,7 +52,7 @@ public class PartitionCacheTest {
     }
 
 
-    // @Test
+    @Test
     public void test1() {
         Map<String, RangeMap<Long, Integer>> keyToPartIdCache = new 
HashMap<>();
         // graphName + PartitionID组成key
diff --git 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/StoreNodeServiceTest.java
 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/StoreNodeServiceTest.java
index c8f0ce39e..69826c11c 100644
--- 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/StoreNodeServiceTest.java
+++ 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/StoreNodeServiceTest.java
@@ -37,6 +37,7 @@ import org.apache.hugegraph.pd.grpc.pulse.SplitPartition;
 import org.apache.hugegraph.pd.grpc.pulse.TransferLeader;
 import org.junit.Assert;
 import org.junit.BeforeClass;
+import org.junit.Test;
 
 public class StoreNodeServiceTest {
     static PDConfig pdConfig;
@@ -87,13 +88,16 @@ public class StoreNodeServiceTest {
         }
     }
 
-    // @Test
+    @Test
     public void testStoreNodeService() throws PDException {
         Assert.assertEquals(pdConfig.getPartition().getTotalCount(),
                             (long) pdConfig.getInitialStoreMap().size() *
                             pdConfig.getPartition().getMaxShardsPerStore()
                             / pdConfig.getPartition().getShardCount());
         StoreNodeService storeService = new StoreNodeService(pdConfig);
+        PartitionService partitionService = new PartitionService(pdConfig, 
storeService);
+        storeService.init(partitionService);
+
         int count = 6;
         Metapb.Store[] stores = new Metapb.Store[count];
         for (int i = 0; i < count; i++) {
@@ -168,7 +172,7 @@ public class StoreNodeServiceTest {
 
     }
 
-    // @Test
+    @Test
     public void testSplitPartition() throws PDException {
         StoreNodeService storeService = new StoreNodeService(pdConfig);
         PartitionService partitionService = new PartitionService(pdConfig, 
storeService);
@@ -258,7 +262,7 @@ public class StoreNodeServiceTest {
         });
     }
 
-    // @Test
+    @Test
     public void testPartitionService() throws PDException, ExecutionException,
                                               InterruptedException {
         StoreNodeService storeService = new StoreNodeService(pdConfig);
@@ -267,7 +271,7 @@ public class StoreNodeServiceTest {
         for (int i = 0; i < count; i++) {
             Metapb.Store store = Metapb.Store.newBuilder()
                                              .setId(0)
-                                             .setAddress(String.valueOf(i))
+                                             .setAddress("127.0.0.1:850" + i)
                                              .setDeployPath("/data")
                                              
.addLabels(Metapb.StoreLabel.newBuilder()
                                                                          
.setKey("namespace")
@@ -281,6 +285,7 @@ public class StoreNodeServiceTest {
 
 
         PartitionService partitionService = new PartitionService(pdConfig, 
storeService);
+        storeService.init(partitionService);
 
         Metapb.Graph graph = Metapb.Graph.newBuilder()
                                          .setGraphName("defaultGH")
@@ -420,7 +425,7 @@ public class StoreNodeServiceTest {
 
     }
 
-    // @Test
+    @Test
     public void testMergeGraphParams() throws PDException {
         StoreNodeService storeService = new StoreNodeService(pdConfig);
         PartitionService partitionService = new PartitionService(pdConfig, 
storeService);
@@ -466,20 +471,4 @@ public class StoreNodeServiceTest {
         Assert.assertEquals(dfGraph.getPartitionCount(), 
graph.getPartitionCount());
 
     }
-
-    // @Test
-    public void test() {
-        int[] n = new int[3];
-
-
-        if (++n[2] > 1) {
-            System.out.println(n[2]);
-        }
-        if (++n[2] > 1) {
-            System.out.println(n[2]);
-        }
-        if (++n[2] > 1) {
-            System.out.println(n[2]);
-        }
-    }
 }
diff --git 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/UnitTestBase.java
 
b/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/UnitTestBase.java
deleted file mode 100644
index 35ada8416..000000000
--- 
a/hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/UnitTestBase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-
-public class UnitTestBase {
-    public static boolean deleteDir(File dir) {
-        if (dir.isDirectory()) {
-            for (File file : dir.listFiles()) {
-                deleteDir(file);
-            }
-        }
-        return dir.delete();
-    }
-}

Reply via email to