@Test public void testCheckConnectivity() throws Exception { int numPartitions = 3; int numStorageNodes = 3; Properties properties = new Properties(); properties.setProperty(IntegrationTestHelper.Config.ZNODE_PATH, "/cluster/cli/test"); properties.setProperty(IntegrationTestHelper.Config.NUM_PARTITIONS, String.valueOf(numPartitions)); properties.setProperty(IntegrationTestHelper.Config.ZK_SESSION_TIMEOUT, "30000"); properties.setProperty(IntegrationTestHelper.Config.NUM_STORAGES, String.valueOf(numStorageNodes)); IntegrationTestHelper helper = new IntegrationTestHelper(properties); Properties configProperties = createProperties(helper.getZkConnectString(), helper.getZnodePath(), helper.getZkSessionTimeout(), helper.getSslSetup()); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, configProperties); Map<String, Boolean> expectedStorageConnectivity = new HashMap<>(); try { helper.startZooKeeperServer(); for (int i = 0; i < numStorageNodes; i++) { WaltzStorageRunner storageRunner = helper.getWaltzStorageRunner(i); storageRunner.startAsync(); storageRunner.awaitStart(); expectedStorageConnectivity.put(helper.getStorageConnectString(i), true); } helper.startWaltzServer(true); String[] args1 = { "check-connectivity", "--cli-config-path", configFilePath }; ClusterCli.testMain(args1); String expectedCmdOutput = "Connectivity status of " + helper.getHost() + ":" + helper.getServerPort() + " is: " + expectedStorageConnectivity.toString(); assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); Random rand = new Random(); int storageNodeId = rand.nextInt(numStorageNodes); WaltzStorageRunner storageRunner = helper.getWaltzStorageRunner(storageNodeId); storageRunner.stop(); expectedStorageConnectivity.put(helper.getStorageConnectString(storageNodeId), false); String[] args2 = { "check-connectivity", "--cli-config-path", configFilePath }; ClusterCli.testMain(args2); expectedCmdOutput = "Connectivity status of " + helper.getHost() + ":" + helper.getServerPort() + " is: " + expectedStorageConnectivity.toString(); assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); WaltzServerRunner waltzServerRunner = helper.getWaltzServerRunner(helper.getServerPort(), helper.getServerJettyPort()); waltzServerRunner.closeNetworkServer(); String[] args3 = { "check-connectivity", "--cli-config-path", configFilePath }; ClusterCli.testMain(args3); expectedCmdOutput = "Connectivity status of " + helper.getHost() + ":" + helper.getServerPort() + " is: UNREACHABLE"; assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); } finally { helper.closeAll(); } }
public static void testMain(String[] args) { new ClusterCli(args, true).processCmd(); }
ClusterCli extends SubcommandCli { public static void testMain(String[] args) { new ClusterCli(args, true).processCmd(); } }
ClusterCli extends SubcommandCli { public static void testMain(String[] args) { new ClusterCli(args, true).processCmd(); } private  ClusterCli(String[] args, boolean useByTest); }
ClusterCli extends SubcommandCli { public static void testMain(String[] args) { new ClusterCli(args, true).processCmd(); } private  ClusterCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args); }
ClusterCli extends SubcommandCli { public static void testMain(String[] args) { new ClusterCli(args, true).processCmd(); } private  ClusterCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args);  }