HBASE-23792 [Flakey Test] TestExportSnapshotNoCluster.testSnapshotWithRefsExportFileSystemState (#1124)

1. Survive flakey rerunning by converting the static BeforeClass stuff
   into instance-level Before.
2. Break the test method into two, one for running over each of the
   snapshot manifest versions.

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Nick Dimiduk 2020-02-04 16:04:14 -08:00 committed by GitHub
parent 299b6bebc5
commit 6ba1df3b39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 23 deletions

View File

@ -18,9 +18,7 @@
package org.apache.hadoop.hbase.snapshot; package org.apache.hadoop.hbase.snapshot;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.net.URI; import java.net.URI;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem; import org.apache.hadoop.fs.LocalFileSystem;
@ -33,7 +31,7 @@ import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.SnapshotMock; import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.SnapshotMock;
import org.apache.hadoop.hbase.testclassification.MapReduceTests; import org.apache.hadoop.hbase.testclassification.MapReduceTests;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.BeforeClass; import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -52,12 +50,11 @@ public class TestExportSnapshotNoCluster {
private static final Logger LOG = LoggerFactory.getLogger(TestExportSnapshotNoCluster.class); private static final Logger LOG = LoggerFactory.getLogger(TestExportSnapshotNoCluster.class);
protected final static HBaseCommonTestingUtility TEST_UTIL = new HBaseCommonTestingUtility(); private final HBaseCommonTestingUtility testUtil = new HBaseCommonTestingUtility();
private FileSystem fs;
private Path testDir;
private static FileSystem fs; public void setUpBaseConf(Configuration conf) {
private static Path testDir;
public static void setUpBaseConf(Configuration conf) {
conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true); conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
conf.setInt("hbase.regionserver.msginterval", 100); conf.setInt("hbase.regionserver.msginterval", 100);
conf.setInt("hbase.client.pause", 250); conf.setInt("hbase.client.pause", 250);
@ -67,29 +64,29 @@ public class TestExportSnapshotNoCluster {
conf.set(HConstants.HBASE_DIR, testDir.toString()); conf.set(HConstants.HBASE_DIR, testDir.toString());
} }
@BeforeClass @Before
public static void setUpBeforeClass() throws Exception { public void setUpBefore() throws Exception {
// Make sure testDir is on LocalFileSystem // Make sure testDir is on LocalFileSystem
testDir = TEST_UTIL.getDataTestDir().makeQualified(URI.create("file:///"), new Path("/")); testDir = testUtil.getDataTestDir().makeQualified(URI.create("file:///"), new Path("/"));
fs = testDir.getFileSystem(TEST_UTIL.getConfiguration()); fs = testDir.getFileSystem(testUtil.getConfiguration());
assertTrue("FileSystem '" + fs + "' is not local", fs instanceof LocalFileSystem); assertTrue("FileSystem '" + fs + "' is not local", fs instanceof LocalFileSystem);
setUpBaseConf(TEST_UTIL.getConfiguration()); setUpBaseConf(testUtil.getConfiguration());
} }
/**
* Mock a snapshot with files in the archive dir,
* two regions, and one reference file.
*/
@Test @Test
public void testSnapshotWithRefsExportFileSystemState() throws Exception { public void testSnapshotV1WithRefsExportFileSystemState() throws Exception {
SnapshotMock snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, testDir); final SnapshotMock snapshotMock = new SnapshotMock(testUtil.getConfiguration(), fs, testDir);
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV1", final SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV1("tableWithRefsV1",
"tableWithRefsV1"); "tableWithRefsV1");
testSnapshotWithRefsExportFileSystemState(builder); testSnapshotWithRefsExportFileSystemState(builder);
}
snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, testDir); @Test
builder = snapshotMock.createSnapshotV2("tableWithRefsV2", "tableWithRefsV2"); public void testSnapshotV2WithRefsExportFileSystemState() throws Exception {
final SnapshotMock snapshotMock = new SnapshotMock(testUtil.getConfiguration(), fs, testDir);
final SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV2",
"tableWithRefsV2");
testSnapshotWithRefsExportFileSystemState(builder); testSnapshotWithRefsExportFileSystemState(builder);
} }
@ -106,7 +103,7 @@ public class TestExportSnapshotNoCluster {
String snapshotName = builder.getSnapshotDescription().getName(); String snapshotName = builder.getSnapshotDescription().getName();
TableName tableName = builder.getTableDescriptor().getTableName(); TableName tableName = builder.getTableDescriptor().getTableName();
TestExportSnapshot.testExportFileSystemState(TEST_UTIL.getConfiguration(), TestExportSnapshot.testExportFileSystemState(testUtil.getConfiguration(),
tableName, snapshotName, snapshotName, snapshotFilesCount, tableName, snapshotName, snapshotName, snapshotFilesCount,
testDir, getDestinationDir(), false, null, true); testDir, getDestinationDir(), false, null, true);
} }