use of org.apache.bookkeeper.bookie.BookieShell.RecoverCmd in project bookkeeper by apache.
the class BookieShellTest method testRecoverCmdRecoverLedger.
@SuppressWarnings("unchecked")
void testRecoverCmdRecoverLedger(long ledgerId, boolean dryrun, boolean skipOpenLedgers, boolean removeCookies, String... args) throws Exception {
RecoverCmd cmd = (RecoverCmd) shell.commands.get("recover");
CommandLine cmdLine = parseCommandLine(cmd, args);
assertEquals(0, cmd.runCmd(cmdLine));
PowerMockito.verifyNew(BookKeeperAdmin.class, times(1)).withArguments(any(ClientConfiguration.class));
verify(admin, times(1)).recoverBookieData(eq(ledgerId), any(Set.class), eq(dryrun), eq(skipOpenLedgers));
verify(admin, times(1)).close();
if (removeCookies) {
PowerMockito.verifyStatic(MetadataDrivers.class);
MetadataDrivers.runFunctionWithRegistrationManager(any(ServerConfiguration.class), any(Function.class));
verify(rm, times(1)).readCookie(anyString());
verify(rm, times(1)).removeCookie(anyString(), eq(version));
} else {
verify(rm, times(0)).readCookie(anyString());
verify(rm, times(0)).removeCookie(anyString(), eq(version));
}
}
use of org.apache.bookkeeper.bookie.BookieShell.RecoverCmd in project bookkeeper by apache.
the class BookieShellTest method testRecoverCmdQuery.
@SuppressWarnings("unchecked")
@Test
public void testRecoverCmdQuery() throws Exception {
SortedMap<Long, LedgerMetadata> ledgersContainBookies = Maps.newTreeMap();
when(admin.getLedgersContainBookies(any(Set.class))).thenReturn(ledgersContainBookies);
RecoverCmd cmd = (RecoverCmd) shell.commands.get("recover");
CommandLine cmdLine = parseCommandLine(cmd, "-force", "-q", "127.0.0.1:3181");
assertEquals(0, cmd.runCmd(cmdLine));
PowerMockito.verifyNew(BookKeeperAdmin.class, times(1)).withArguments(any(ClientConfiguration.class));
verify(admin, times(1)).getLedgersContainBookies(any(Set.class));
verify(admin, times(1)).close();
}
use of org.apache.bookkeeper.bookie.BookieShell.RecoverCmd in project bookkeeper by apache.
the class BookieShellTest method testRecoverCmdMissingArgument.
@Test
public void testRecoverCmdMissingArgument() throws Exception {
RecoverCmd cmd = (RecoverCmd) shell.commands.get("recover");
CommandLine cmdLine = parseCommandLine(cmd);
try {
cmd.runCmd(cmdLine);
fail("should fail running command when the arguments are missing");
} catch (MissingArgumentException e) {
// expected
}
PowerMockito.verifyNew(BookKeeperAdmin.class, never()).withArguments(any(ClientConfiguration.class));
}
use of org.apache.bookkeeper.bookie.BookieShell.RecoverCmd in project bookkeeper by apache.
the class BookieShellTest method testRecoverCmdRecover.
@SuppressWarnings("unchecked")
void testRecoverCmdRecover(boolean dryrun, boolean skipOpenLedgers, boolean removeCookies, String... args) throws Exception {
RecoverCmd cmd = (RecoverCmd) shell.commands.get("recover");
CommandLine cmdLine = parseCommandLine(cmd, args);
assertEquals(0, cmd.runCmd(cmdLine));
PowerMockito.verifyNew(BookKeeperAdmin.class, times(1)).withArguments(any(ClientConfiguration.class));
verify(admin, times(1)).recoverBookieData(any(Set.class), eq(dryrun), eq(skipOpenLedgers));
verify(admin, times(1)).close();
if (removeCookies) {
PowerMockito.verifyStatic(MetadataDrivers.class);
MetadataDrivers.runFunctionWithRegistrationManager(any(ServerConfiguration.class), any(Function.class));
verify(rm, times(1)).readCookie(anyString());
verify(rm, times(1)).removeCookie(anyString(), eq(version));
} else {
verify(rm, times(0)).readCookie(anyString());
verify(rm, times(0)).removeCookie(anyString(), eq(version));
}
}
use of org.apache.bookkeeper.bookie.BookieShell.RecoverCmd in project bookkeeper by apache.
the class BookieShellTest method testRecoverCmdInvalidBookieAddress.
@Test
public void testRecoverCmdInvalidBookieAddress() throws Exception {
RecoverCmd cmd = (RecoverCmd) shell.commands.get("recover");
CommandLine cmdLine = parseCommandLine(cmd, "127.0.0.1");
assertEquals(-1, cmd.runCmd(cmdLine));
PowerMockito.verifyNew(BookKeeperAdmin.class, never()).withArguments(any(ClientConfiguration.class));
}
Aggregations