use of org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.ProcessInfo in project accumulo by apache.
the class GarbageCollectorIT method testInvalidDelete.
@Test
public void testInvalidDelete() throws Exception {
killMacGc();
try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
String table = getUniqueNames(1)[0];
c.tableOperations().create(table);
try (BatchWriter bw = c.createBatchWriter(table)) {
Mutation m1 = new Mutation("r1");
m1.put("cf1", "cq1", "v1");
bw.addMutation(m1);
}
c.tableOperations().flush(table, null, null, true);
// ensure an invalid delete entry does not cause GC to go berserk ACCUMULO-2520
c.securityOperations().grantTablePermission(c.whoami(), MetadataTable.NAME, TablePermission.WRITE);
try (BatchWriter bw = c.createBatchWriter(MetadataTable.NAME)) {
bw.addMutation(createDelMutation("", "", "", ""));
bw.addMutation(createDelMutation("", "testDel", "test", "valueTest"));
// path is invalid but value is expected - only way the invalid entry will come through
// processing and
// show up to produce error in output to allow while loop to end
bw.addMutation(createDelMutation("/", "", "", SkewedKeyValue.STR_NAME));
}
ProcessInfo gc = cluster.exec(SimpleGarbageCollector.class);
try {
String output = "";
while (!output.contains("Ignoring invalid deletion candidate")) {
sleepUninterruptibly(250, TimeUnit.MILLISECONDS);
try {
output = gc.readStdOut();
} catch (UncheckedIOException ioe) {
log.error("Could not read all from cluster.", ioe);
}
}
} finally {
gc.getProcess().destroy();
}
try (Scanner scanner = c.createScanner(table, Authorizations.EMPTY)) {
Iterator<Entry<Key, Value>> iter = scanner.iterator();
assertTrue(iter.hasNext());
Entry<Key, Value> entry = iter.next();
assertEquals("r1", entry.getKey().getRow().toString());
assertEquals("cf1", entry.getKey().getColumnFamily().toString());
assertEquals("cq1", entry.getKey().getColumnQualifier().toString());
assertEquals("v1", entry.getValue().toString());
assertFalse(iter.hasNext());
}
}
}
Aggregations