HBASE-7418 HFileLink flaky test (Matteo Bertozzi)

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-7290@1445803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2013-02-13 18:26:28 +00:00
parent 98cc234a18
commit 4005c5f48c
2 changed files with 10 additions and 10 deletions

View File

@ -56,9 +56,7 @@ public class TestHFileLinkCleaner {
public void testHFileLinkCleaning() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDataTestDir().toString());
conf.set(HFileCleaner.MASTER_HFILE_CLEANER_PLUGINS,
"org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner," +
"org.apache.hadoop.hbase.master.cleaner.HFileLinkCleaner");
conf.set(HFileCleaner.MASTER_HFILE_CLEANER_PLUGINS, HFileLinkCleaner.class.getName());
Path rootDir = FSUtils.getRootDir(conf);
FileSystem fs = FileSystem.get(conf);
@ -100,14 +98,12 @@ public class TestHFileLinkCleaner {
HFileCleaner cleaner = new HFileCleaner(1000, server, conf, fs, archiveDir);
// Link backref cannot be removed
Thread.sleep(ttl * 2);
cleaner.chore();
assertTrue(fs.exists(linkBackRef));
assertTrue(fs.exists(hfilePath));
// Link backref can be removed
fs.rename(new Path(rootDir, tableLinkName), new Path(archiveDir, tableLinkName));
Thread.sleep(ttl * 2);
cleaner.chore();
assertFalse("Link should be deleted", fs.exists(linkBackRef));

View File

@ -171,12 +171,16 @@ public class TestStoreFile extends HBaseTestCase {
public void testHFileLink() throws IOException {
final String columnFamily = "f";
Configuration testConf = new Configuration(this.conf);
FSUtils.setRootDir(testConf, this.testDir);
HRegionInfo hri = new HRegionInfo(Bytes.toBytes("table-link"));
Path storedir = new Path(new Path(FSUtils.getRootDir(conf),
Path storedir = new Path(new Path(this.testDir,
new Path(hri.getTableNameAsString(), hri.getEncodedName())), columnFamily);
// Make a store file and write data to it.
StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf,
StoreFile.Writer writer = new StoreFile.WriterBuilder(testConf, cacheConf,
this.fs, 8 * 1024)
.withOutputDir(storedir)
.build();
@ -184,13 +188,13 @@ public class TestStoreFile extends HBaseTestCase {
writeStoreFile(writer);
writer.close();
Path dstPath = new Path(FSUtils.getRootDir(conf), new Path("test-region", columnFamily));
HFileLink.create(conf, this.fs, dstPath, hri, storeFilePath.getName());
Path dstPath = new Path(this.testDir, new Path("test-region", columnFamily));
HFileLink.create(testConf, this.fs, dstPath, hri, storeFilePath.getName());
Path linkFilePath = new Path(dstPath,
HFileLink.createHFileLinkName(hri, storeFilePath.getName()));
// Try to open store file from link
StoreFile hsf = new StoreFile(this.fs, linkFilePath, conf, cacheConf,
StoreFile hsf = new StoreFile(this.fs, linkFilePath, testConf, cacheConf,
StoreFile.BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
assertTrue(hsf.isLink());