@Test public void testListPartition() throws Exception { int numPartitions = 4; int numStorages = 2; assertEquals(0, numPartitions % numStorages); IntegrationTestHelper helper = getIntegrationTestHelper(numPartitions, numStorages); int partitionId = 0; Properties cfgProperties = createProperties(helper.getZkConnectString(), helper.getZnodePath(), helper.getSslSetup()); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, cfgProperties); helper.startZooKeeperServer(); String[] adminConnectStrings = new String[numStorages]; int adminPort = 0; for (int s = 0; s < numStorages; s++) { WaltzStorageRunner storageRunner = helper.getWaltzStorageRunner(s); storageRunner.startAsync(); WaltzStorage storage = storageRunner.awaitStart(); adminPort = storage.adminPort; adminConnectStrings[s] = helper.getHost() + ":" + adminPort; } Thread.sleep(1000); String expectedCmdOutput; try { int index = 0; int partitionsPerStorage = numPartitions / numStorages; for (int s = 0; s < numStorages; s++) { for (int p = 0; p < partitionsPerStorage; p++) { String[] addPartitionArgs = { "add-partition", "--storage", adminConnectStrings[s], "--partition", String.valueOf(index++), "--cli-config-path", configFilePath }; StorageCli.testMain(addPartitionArgs); } } for (int s = 0; s < numStorages; s++) { String[] args2 = { "list", "--storage", adminConnectStrings[s], "--cli-config-path", configFilePath }; ByteArrayOutputStream successfulPathOut = new ByteArrayOutputStream(); ByteArrayOutputStream successfulPathErr = new ByteArrayOutputStream(); setUpStreams(successfulPathOut, successfulPathErr); StorageCli.testMain(args2); expectedCmdOutput = "Partition Info for id: " + partitionId; assertTrue(successfulPathOut.toString("UTF-8").contains(expectedCmdOutput)); } setUpStreams(); String[] argsNoPath = { "list", "--cli-config-path", configFilePath }; ByteArrayOutputStream noPathOut = new ByteArrayOutputStream(); ByteArrayOutputStream noPathErr = new ByteArrayOutputStream(); setUpStreams(noPathOut, noPathErr); StorageCli.testMain(argsNoPath); for (int s = 0; s < numStorages; s++) { expectedCmdOutput = "Partition Info for id: " + partitionId + " at " + adminConnectStrings[s]; assertTrue(noPathOut.toString("UTF-8").contains(expectedCmdOutput)); } setUpStreams(); String[] args3 = { "list", "--storage", "badhost.local:" + adminPort, "--cli-config-path", configFilePath }; StorageCli.testMain(args3); expectedCmdOutput = "Error: Cannot fetch partition ownership for badhost.local:" + adminPort; assertTrue(errContent.toString("UTF-8").contains(expectedCmdOutput)); } finally { helper.closeAll(); } }
public static void testMain(String[] args) { new StorageCli(args, true).processCmd(); }
StorageCli extends SubcommandCli { public static void testMain(String[] args) { new StorageCli(args, true).processCmd(); } }
StorageCli extends SubcommandCli { public static void testMain(String[] args) { new StorageCli(args, true).processCmd(); } private  StorageCli(String[] args, boolean useByTest); }
StorageCli extends SubcommandCli { public static void testMain(String[] args) { new StorageCli(args, true).processCmd(); } private  StorageCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args); }
StorageCli extends SubcommandCli { public static void testMain(String[] args) { new StorageCli(args, true).processCmd(); } private  StorageCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args);  }