### Question:
PerformanceCli extends SubcommandCli { public static void testMain(String[] args) { new PerformanceCli(args, true).processCmd(); } private  PerformanceCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args);  }### Answer:
@Test public void testRunProducer() throws Exception { Properties properties = new Properties(); properties.setProperty(IntegrationTestHelper.Config.ZNODE_PATH, "/producer/perf/cli/test"); properties.setProperty(IntegrationTestHelper.Config.NUM_PARTITIONS, "3"); properties.setProperty(IntegrationTestHelper.Config.ZK_SESSION_TIMEOUT, "30000"); IntegrationTestHelper helper = new IntegrationTestHelper(properties); Properties cfgProperties = createProperties(helper.getZkConnectString(), helper.getZnodePath(), helper.getZkSessionTimeout(), helper.getSslSetup()); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, cfgProperties); String[] args = { "test-producers", "--txn-size", "128", "--txn-per-thread", "10", "--num-thread", "2", "--interval", "10", "--cli-config-path", configFilePath, "--lock-pool-size", "2", "--num-active-partitions", "1" }; try { helper.startZooKeeperServer(); helper.startWaltzStorage(true); helper.setWaltzStorageAssignment(true); helper.startWaltzServer(true); PerformanceCli.testMain(args); String expectedCmdOutput = "Appended 20 transactions"; assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); } finally { helper.closeAll(); } }
@Test public void testRunConsumer() throws Exception { Properties properties = new Properties(); properties.setProperty(IntegrationTestHelper.Config.ZNODE_PATH, "/consumer/perf/cli/test"); properties.setProperty(IntegrationTestHelper.Config.NUM_PARTITIONS, "3"); properties.setProperty(IntegrationTestHelper.Config.ZK_SESSION_TIMEOUT, "30000"); IntegrationTestHelper helper = new IntegrationTestHelper(properties); Properties cfgProperties = createProperties(helper.getZkConnectString(), helper.getZnodePath(), helper.getZkSessionTimeout(), helper.getSslSetup()); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, cfgProperties); String[] args = { "test-consumers", "--txn-size", "128", "--num-txn", "10", "--cli-config-path", configFilePath, "--num-active-partitions", "1" }; try { helper.startZooKeeperServer(); helper.startWaltzStorage(true); helper.setWaltzStorageAssignment(true); helper.startWaltzServer(true); PerformanceCli.testMain(args); String expectedCmdOutput = "Read 10 transactions"; assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); outContent.reset(); String[] argsMountLatest = { "test-consumers", "--txn-size", "128", "--num-txn", "10", "--cli-config-path", configFilePath, "--num-active-partitions", "1", "--mount_from_latest" }; PerformanceCli.testMain(argsMountLatest); assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); } finally { helper.closeAll(); } }