@Test public void testMaxTransactionId() throws Exception { long sessionId = 123; int numPartitions = 3; IntegrationTestHelper helper = getIntegrationTestHelper(numPartitions); SslContext sslCtx = helper.getSslContext(); int partitionId = new Random().nextInt(helper.getNumPartitions()); Properties cfgProperties = createProperties(helper.getZkConnectString(), helper.getZnodePath(), helper.getSslSetup()); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, cfgProperties); helper.startZooKeeperServer(); WaltzStorageRunner storageRunner = helper.getWaltzStorageRunner(); UUID key = helper.getClusterKey(); try { storageRunner.startAsync(); WaltzStorage waltzStorage = storageRunner.awaitStart(); String host = helper.getHost(); int port = waltzStorage.port; int adminPort = waltzStorage.adminPort; StorageAdminClient adminClient = helper.getStorageAdminClientWithAdminPort(adminPort); adminClient.open(); for (int i = 0; i < numPartitions; i++) { adminClient.setPartitionAssignment(i, true, false).get(); } adminClient.close(); String[] args0 = { "max-transaction-id", "--storage", host + ":" + adminPort, "--storage-port", String.valueOf(port), "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath }; StorageCli.testMain(args0); String expectedCmdOutput = "Max Transaction ID: " + -1; assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); String[] args1 = { "max-transaction-id", "--storage", "badhost.local:" + adminPort, "--storage-port", String.valueOf(port), "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath }; StorageCli.testMain(args1); expectedCmdOutput = "Error: Failed to read max transaction ID for storage badhost.local:" + adminPort; assertTrue(errContent.toString("UTF-8").contains(expectedCmdOutput)); ArrayList<Record> records = ClientUtil.makeRecords(0, 10); StorageClient sourceClient = new StorageClient(host, port, sslCtx, key, numPartitions); sourceClient.open(); sourceClient.setLowWaterMark(sessionId, partitionId, -1L).get(); sourceClient.appendRecords(sessionId, partitionId, records).get(); sourceClient.setLowWaterMark(sessionId + 1, partitionId, records.size() - 1).get(); String[] args2 = { "availability", "--storage", host + ":" + adminPort, "--partition", String.valueOf(partitionId), "--online", String.valueOf(false), "--cli-config-path", configFilePath }; StorageCli.testMain(args2); String[] args3 = { "max-transaction-id", "--storage", host + ":" + adminPort, "--storage-port", String.valueOf(port), "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath, "--offline" }; StorageCli.testMain(args3); expectedCmdOutput = "Max Transaction ID: " + 9; assertTrue(outContent.toString("UTF-8").contains(expectedCmdOutput)); String[] args4 = { "max-transaction-id", "--storage", host + ":" + adminPort, "--storage-port", String.valueOf(port), "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath }; StorageCli.testMain(args4); expectedCmdOutput = "Error: Failed to read max transaction ID for storage " + host + ":" + 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);  }