// Try to recover with bad password in conf
// if the digest type is MAC
// for CRC32, the password is only checked
// when adding new entries, which recovery will
// never do
ClientConfiguration adminConf;
BookKeeperAdmin bka;
if (digestCorrect == DigestType.MAC) {
adminConf = new ClientConfiguration();
adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
adminConf.setLedgerManagerFactoryClassName(ledgerManagerFactory);
adminConf.setBookieRecoveryDigestType(digestCorrect);
adminConf.setBookieRecoveryPasswd(passwdBad);
bka = new BookKeeperAdmin(adminConf);
try {
bka.recoverBookieData(bookieSrc, null);
fail("Shouldn't be able to recover with wrong password");
} catch (BKException bke) {
// correct behaviour
} finally {
bka.close();
}
}
// Try to recover with bad digest in conf
adminConf = new ClientConfiguration();
adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
adminConf.setLedgerManagerFactoryClassName(ledgerManagerFactory);
adminConf.setBookieRecoveryDigestType(digestBad);
adminConf.setBookieRecoveryPasswd(passwdCorrect);
bka = new BookKeeperAdmin(adminConf);
try {
bka.recoverBookieData(bookieSrc, null);
fail("Shouldn't be able to recover with wrong digest");
} catch (BKException bke) {
// correct behaviour
} finally {
bka.close();
}
// Check that entries are still missing
lh = bkc.openLedgerNoRecovery(ledgerId, digestCorrect, passwdCorrect);
assertFalse("Should be entries missing", verifyFullyReplicated(lh, 100));
lh.close();
adminConf.setBookieRecoveryDigestType(digestCorrect);
adminConf.setBookieRecoveryPasswd(passwdCorrect);
bka = new BookKeeperAdmin(adminConf);
bka.recoverBookieData(bookieSrc, null);
bka.close();