Skip to content

Commit

Permalink
Improve VerifySerialRecoveryITgst
Browse files Browse the repository at this point in the history
  • Loading branch information
DomGarguilo committed Dec 13, 2024
1 parent be9fa22 commit aeaa2d5
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@
import org.apache.hadoop.fs.RawLocalFileSystem;
import org.apache.hadoop.io.Text;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class VerifySerialRecoveryIT extends ConfigurableMacBase {

private static final Logger log = LoggerFactory.getLogger(VerifySerialRecoveryIT.class);

private static final byte[] HEXCHARS = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66};

Expand Down Expand Up @@ -114,32 +118,31 @@ public void testSerializedRecovery() throws Exception {
assertEquals(0, cluster.exec(Admin.class, "stopAll").getProcess().waitFor());
ts.getProcess().waitFor();
String result = ts.readStdOut();
for (String line : result.split("\n")) {
System.out.println(line);
}
log.info(result);

// walk through the output, verifying that only a single normal recovery was running at one
// time
boolean started = false;
boolean ongoingRecovery = false;
int recoveries = 0;
var pattern =
Pattern.compile(".*recovered \\d+ mutations creating \\d+ entries from \\d+ walogs.*");
for (String line : result.split("\n")) {
// ignore metadata tables
// ignore metadata and root tables
if (line.contains("!0") || line.contains("+r")) {
continue;
}
if (line.contains("recovering data from walogs")) {
assertFalse(started);
started = true;
assertFalse(ongoingRecovery, "Saw recovery start before previous recovery finished");
ongoingRecovery = true;
recoveries++;
}
if (pattern.matcher(line).matches()) {
assertTrue(started);
started = false;
assertTrue(ongoingRecovery, "Saw recovery end without recovery start");
ongoingRecovery = false;
}
}
assertFalse(started);
assertTrue(recoveries > 0);
assertFalse(ongoingRecovery, "Expected no ongoing recovery at end of test");
assertTrue(recoveries > 0, "Expected at least one recovery to have occurred");
}
}
}

0 comments on commit aeaa2d5

Please sign in to comment.