-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chenby
committed
Sep 3, 2024
1 parent
bde7126
commit 401671f
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/moilioncircle/redis/rdb/cli/conf/NodeConfParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.moilioncircle.redis.rdb.cli.conf; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author Baoyi Chen | ||
*/ | ||
public class NodeConfParserTest { | ||
|
||
@Test | ||
public void test0() throws Exception { | ||
String conf = readConf("rdt/nodes.conf"); | ||
XClusterNodes nodes = NodeConfParser.parse(conf); | ||
assertEquals(nodes.getNodes().get(0).getHostAndPort().getHost(), "127.0.0.1"); | ||
assertEquals(nodes.getNodes().get(1).getHostAndPort().getHost(), "127.0.0.1"); | ||
assertEquals(nodes.getNodes().get(2).getHostAndPort().getHost(), "127.0.0.1"); | ||
assertEquals(nodes.getNodes().get(3).getHostAndPort().getHost(), "127.0.0.1"); | ||
assertEquals(nodes.getNodes().get(4).getHostAndPort().getHost(), "127.0.0.1"); | ||
assertEquals(nodes.getNodes().get(5).getHostAndPort().getHost(), "127.0.0.1"); | ||
} | ||
|
||
@Test | ||
public void test1() throws Exception { | ||
String conf = readConf("rdt/nodes-hostname.conf"); | ||
XClusterNodes nodes = NodeConfParser.parse(conf); | ||
assertEquals(nodes.getNodes().get(0).getHostAndPort().getHost(), "redis-host1"); | ||
assertEquals(nodes.getNodes().get(1).getHostAndPort().getHost(), "redis-host2"); | ||
assertEquals(nodes.getNodes().get(2).getHostAndPort().getHost(), "redis-host3"); | ||
assertEquals(nodes.getNodes().get(3).getHostAndPort().getHost(), "redis-host4"); | ||
assertEquals(nodes.getNodes().get(4).getHostAndPort().getHost(), "redis-host5"); | ||
assertEquals(nodes.getNodes().get(5).getHostAndPort().getHost(), "redis-host6"); | ||
} | ||
|
||
private static String readConf(String path) throws IOException, URISyntaxException { | ||
return new String(Files.readAllBytes(Paths.get(NodeConfParserTest.class.getClassLoader().getResource(path).toURI())), StandardCharsets.UTF_8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
126be0dd065a87eea5cb4036d1d4ee958c02078a 127.0.0.1:10002@20002,redis-host1 master - 0 1531044047088 2 connected 5461-10922 | ||
e5a488eb96774d76ccec147be93e50b29ea01801 127.0.0.1:10006@20006,redis-host2 slave 126be0dd065a87eea5cb4036d1d4ee958c02078a 0 1531044047088 6 connected | ||
34b6e1dfb871ad30398ef5edd6b9a954617e6ec1 127.0.0.1:10003@20003,redis-host3 master - 0 1531044047088 3 connected 10923-16383 | ||
115ce322ff004253556f3ac0829566edce0aeaea 127.0.0.1:10004@20004,redis-host4 slave 34b6e1dfb871ad30398ef5edd6b9a954617e6ec1 0 1531044047993 4 connected | ||
84dd95d7e10734490c94d10e9a58cd7c57021506 127.0.0.1:10005@20005,redis-host5 slave 89d020a7e727e81f003836207902ae26fe05fd51 0 1531044047000 5 connected | ||
89d020a7e727e81f003836207902ae26fe05fd51 127.0.0.1:10001@20001,redis-host6 myself,master - 0 1531044047000 1 connected 0-5460 | ||
vars currentEpoch 6 lastVoteEpoch 0 |