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 25272127fd..39de8bda4e 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.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 71efa70ecd..dc48f3f0ad 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 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 @@ public class PartitionCacheTest { - // @Test + @Test public void test() { PartitionCache cache = new PartitionCache(); for (int i = 0; i < 10; i++) { @@ -51,7 +52,7 @@ public void test() { } - // @Test + @Test public void test1() { Map> 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 c8f0ce39e5..69826c11cc 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.TransferLeader; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Test; public class StoreNodeServiceTest { static PDConfig pdConfig; @@ -87,13 +88,16 @@ public static void deleteDirectory(File dir) { } } - // @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 void testStoreNodeService() throws PDException { } - // @Test + @Test public void testSplitPartition() throws PDException { StoreNodeService storeService = new StoreNodeService(pdConfig); PartitionService partitionService = new PartitionService(pdConfig, storeService); @@ -258,7 +262,7 @@ public void changePartitionKeyRange(Metapb.Partition partition, }); } - // @Test + @Test public void testPartitionService() throws PDException, ExecutionException, InterruptedException { StoreNodeService storeService = new StoreNodeService(pdConfig); @@ -267,7 +271,7 @@ public void testPartitionService() throws PDException, ExecutionException, 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 void testPartitionService() throws PDException, ExecutionException, PartitionService partitionService = new PartitionService(pdConfig, storeService); + storeService.init(partitionService); Metapb.Graph graph = Metapb.Graph.newBuilder() .setGraphName("defaultGH") @@ -420,7 +425,7 @@ public void onPartitionRemoved(Metapb.Partition partition) { } - // @Test + @Test public void testMergeGraphParams() throws PDException { StoreNodeService storeService = new StoreNodeService(pdConfig); PartitionService partitionService = new PartitionService(pdConfig, storeService); @@ -466,20 +471,4 @@ public void testMergeGraphParams() throws PDException { 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 35ada84167..0000000000 --- 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(); - } -}