HBASE-10543 Two rare test failures with TestLogsCleaner and TestSplitLogWorker

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1569496 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2014-02-18 19:27:54 +00:00
parent ac00a60db2
commit fc59a1f66e
2 changed files with 10 additions and 5 deletions

View File

@ -70,13 +70,12 @@ public class TestLogsCleaner {
ReplicationQueues repQueues = ReplicationQueues repQueues =
ReplicationFactory.getReplicationQueues(server.getZooKeeper(), conf, server); ReplicationFactory.getReplicationQueues(server.getZooKeeper(), conf, server);
repQueues.init(server.getServerName().toString()); repQueues.init(server.getServerName().toString());
Path oldLogDir = new Path(TEST_UTIL.getDataTestDir(), final Path oldLogDir = new Path(TEST_UTIL.getDataTestDir(),
HConstants.HREGION_OLDLOGDIR_NAME); HConstants.HREGION_OLDLOGDIR_NAME);
String fakeMachineName = String fakeMachineName =
URLEncoder.encode(server.getServerName().toString(), "UTF8"); URLEncoder.encode(server.getServerName().toString(), "UTF8");
FileSystem fs = FileSystem.get(conf); final FileSystem fs = FileSystem.get(conf);
LogCleaner cleaner = new LogCleaner(1000, server, conf, fs, oldLogDir);
// Create 2 invalid files, 1 "recent" file, 1 very new file and 30 old files // Create 2 invalid files, 1 "recent" file, 1 very new file and 30 old files
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@ -117,11 +116,17 @@ public class TestLogsCleaner {
assertEquals(34, fs.listStatus(oldLogDir).length); assertEquals(34, fs.listStatus(oldLogDir).length);
LogCleaner cleaner = new LogCleaner(1000, server, conf, fs, oldLogDir);
cleaner.chore(); cleaner.chore();
// We end up with the current log file, a newer one and the 3 old log // We end up with the current log file, a newer one and the 3 old log
// files which are scheduled for replication // files which are scheduled for replication
assertEquals(5, fs.listStatus(oldLogDir).length); TEST_UTIL.waitFor(1000, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
return 5 == fs.listStatus(oldLogDir).length;
}
});
for (FileStatus file : fs.listStatus(oldLogDir)) { for (FileStatus file : fs.listStatus(oldLogDir)) {
System.out.println("Kept log files: " + file.getPath().getName()); System.out.println("Kept log files: " + file.getPath().getName());

View File

@ -235,7 +235,7 @@ public class TestSplitLogWorker {
byte [] bytes = ZKUtil.getData(zkw, PATH); byte [] bytes = ZKUtil.getData(zkw, PATH);
SplitLogTask slt = SplitLogTask.parseFrom(bytes); SplitLogTask slt = SplitLogTask.parseFrom(bytes);
assertTrue(slt.isOwned(SRV)); assertTrue(slt.isOwned(SRV));
slt = new SplitLogTask.Unassigned(MANAGER); slt = new SplitLogTask.Owned(MANAGER);
ZKUtil.setData(zkw, PATH, slt.toByteArray()); ZKUtil.setData(zkw, PATH, slt.toByteArray());
waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME); waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);
} finally { } finally {