HBASE-13309 Some tests do not reset EnvironmentEdgeManager

This commit is contained in:
Matteo Bertozzi 2015-03-22 10:40:49 +00:00
parent a9b73b600e
commit 845f5de121
2 changed files with 17 additions and 8 deletions

View File

@ -330,16 +330,19 @@ public class TestFSUtils {
ManualEnvironmentEdge mockEnv = new ManualEnvironmentEdge(); ManualEnvironmentEdge mockEnv = new ManualEnvironmentEdge();
mockEnv.setValue(expect); mockEnv.setValue(expect);
EnvironmentEdgeManager.injectEdge(mockEnv); EnvironmentEdgeManager.injectEdge(mockEnv);
try {
String dstFile = UUID.randomUUID().toString();
Path dst = new Path(testDir , dstFile);
String dstFile = UUID.randomUUID().toString(); assertTrue(FSUtils.renameAndSetModifyTime(fs, p, dst));
Path dst = new Path(testDir , dstFile); assertFalse("The moved file should not be present", FSUtils.isExists(fs, p));
assertTrue("The dst file should be present", FSUtils.isExists(fs, dst));
assertTrue(FSUtils.renameAndSetModifyTime(fs, p, dst)); assertEquals(expect, fs.getFileStatus(dst).getModificationTime());
assertFalse("The moved file should not be present", FSUtils.isExists(fs, p)); cluster.shutdown();
assertTrue("The dst file should be present", FSUtils.isExists(fs, dst)); } finally {
EnvironmentEdgeManager.reset();
assertEquals(expect, fs.getFileStatus(dst).getModificationTime()); }
cluster.shutdown();
} }
/** /**

View File

@ -111,6 +111,7 @@ import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -182,6 +183,11 @@ public class TestHBaseFsck {
TEST_UTIL.shutdownMiniCluster(); TEST_UTIL.shutdownMiniCluster();
} }
@Before
public void setUp() {
EnvironmentEdgeManager.reset();
}
@Test (timeout=180000) @Test (timeout=180000)
public void testHBaseFsck() throws Exception { public void testHBaseFsck() throws Exception {
assertNoErrors(doFsck(conf, false)); assertNoErrors(doFsck(conf, false));