private void runMultiGroupTest(int[] idIndex, int chosen) throws Exception { printThreadCount(null, "init"); runMultiGroupTest(getCluster(0), idIndex, chosen, NOOP); }
public MiniRaftCluster getCluster(int peerNum) throws IOException { return getClusterFactory().newCluster(peerNum, prop); }
@Test public void testMultiGroup5Nodes() throws Exception { final int[] idIndex = {3, 4, 5}; runMultiGroupTest(idIndex, 0); }
@Test public void testSingleGroupRestart() throws Exception { final MiniRaftCluster cluster = getCluster(0); LOG.info("Start testMultiGroup" + cluster.printServers());
checker.accept(cluster, groups[i]); printThreadCount(type, "start groups"); LOG.info("start groups: " + cluster.printServers()); printThreadCount(type, "close groups"); LOG.info("close groups: " + cluster.printServers()); checker.accept(cluster, groups[chosen]); LOG.info("update groups: " + cluster.printServers()); printThreadCount(type, "update groups"); printThreadCount(type, "shutdown");
@Test public void testMultiGroup9Nodes() throws Exception { final int[] idIndex = {5, 8, 9}; runMultiGroupTest(idIndex, 2); }
@Test public void testMultiGroup7Nodes() throws Exception { final int[] idIndex = {1, 6, 7}; runMultiGroupTest(idIndex, 1); }
private void runTestMultiRaftGroup(int[] idIndex, int chosen) throws Exception { final CheckedBiConsumer<MiniRaftCluster, RaftGroup, IOException> checker = (cluster, group) -> { try (final RaftClient client = cluster.createClient(group)) { TestArithmetic.runTestPythagorean(client, start.getAndAdd(2*count), count); } }; GroupManagementBaseTest.runMultiGroupTest( cluster, idIndex, chosen, checker); } }