@Test public void testRemovePartitionWithDeleteFilesOption() throws Exception { int numPartitions = 5; IntegrationTestHelper helper = getIntegrationTestHelper(numPartitions); 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(); storageRunner.startAsync(); WaltzStorage storage = storageRunner.awaitStart(); int adminPort = storage.adminPort; String adminConnectString = helper.getHost() + ":" + adminPort; helper.startWaltzServer(true); Thread.sleep(1000); PartitionInfoSnapshot info = storage .getPartitionInfos() .stream() .filter(pis -> pis.partitionId == partitionId) .findFirst() .get(); assertFalse(info.isAssigned); try { String[] args1 = { "add-partition", "--storage", adminConnectString, "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath }; StorageCli.testMain(args1); info = storage .getPartitionInfos() .stream() .filter(pis -> pis.partitionId == partitionId) .findFirst() .get(); assertTrue(info.isAssigned); String[] args2 = { "remove-partition", "--storage", adminConnectString, "--partition", String.valueOf(partitionId), "--cli-config-path", configFilePath, "--delete-storage-files" }; StorageCli.testMain(args2); info = storage .getPartitionInfos() .stream() .filter(pis -> pis.partitionId == partitionId) .findFirst() .get(); assertFalse(info.isAssigned); String fileNameFormat = "%019d.%s"; Path partitionDir = storageRunner.directory().resolve(Integer.toString(partitionId)); Path segPath = partitionDir.resolve(String.format(fileNameFormat, 0L, "seg")); Path idxPath = partitionDir.resolve(String.format(fileNameFormat, 0L, "idx")); assertFalse(segPath.toFile().exists()); assertFalse(idxPath.toFile().exists()); } 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);  }