Skip to content

Commit

Permalink
adapt some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VGalaxies committed Mar 16, 2024
1 parent 66122a6 commit ad5b5f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.junit.Assert;
import org.junit.BeforeClass;

// import org.junit.Test;

public class MonitorServiceTest {
static PDConfig pdConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
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;
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++) {
Expand All @@ -51,7 +52,7 @@ public void test() {
}


// @Test
@Test
public void test1() {
Map<String, RangeMap<Long, Integer>> keyToPartIdCache = new HashMap<>();
// graphName + PartitionID组成key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -258,7 +262,7 @@ public void changePartitionKeyRange(Metapb.Partition partition,
});
}

// @Test
@Test
public void testPartitionService() throws PDException, ExecutionException,
InterruptedException {
StoreNodeService storeService = new StoreNodeService(pdConfig);
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
}
}
}

This file was deleted.

0 comments on commit ad5b5f2

Please sign in to comment.