Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -35,7 +35,7 @@ public abstract class MasterFailoverWithProceduresTestBase {

protected static final HBaseTestingUtil UTIL = new HBaseTestingUtil();

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
StartTestingClusterOption option = StartTestingClusterOption.builder().numMasters(2).build();
Expand All @@ -46,7 +46,7 @@ public static void setUp() throws Exception {
ProcedureTestingUtility.setKillBeforeStoreUpdate(procExec, false);
}

@AfterClass
@AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package org.apache.hadoop.hbase.master.procedure;

import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACKER_IMPL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -201,13 +201,13 @@ public static void validateTableCreation(final HMaster master, final TableName t
List<Path> unwantedRegionDirs = FSUtils.getRegionDirs(fs, tableDir);
for (int i = 0; i < regions.length; ++i) {
Path regionDir = new Path(tableDir, regions[i].getEncodedName());
assertTrue(regions[i] + " region dir does not exist", fs.exists(regionDir));
assertTrue(fs.exists(regionDir), regions[i] + " region dir does not exist");
assertTrue(unwantedRegionDirs.remove(regionDir));
List<Path> allFamilyDirs = FSUtils.getFamilyDirs(fs, regionDir);
for (int j = 0; j < family.length; ++j) {
final Path familyDir = new Path(regionDir, family[j]);
if (hasFamilyDirs) {
assertTrue(family[j] + " family dir does not exist", fs.exists(familyDir));
assertTrue(fs.exists(familyDir), family[j] + " family dir does not exist");
assertTrue(allFamilyDirs.remove(familyDir));
} else {
// TODO: WARN: Modify Table/Families does not create a family dir
Expand All @@ -217,9 +217,9 @@ public static void validateTableCreation(final HMaster master, final TableName t
allFamilyDirs.remove(familyDir);
}
}
assertTrue("found extraneous families: " + allFamilyDirs, allFamilyDirs.isEmpty());
assertTrue(allFamilyDirs.isEmpty(), "found extraneous families: " + allFamilyDirs);
}
assertTrue("found extraneous regions: " + unwantedRegionDirs, unwantedRegionDirs.isEmpty());
assertTrue(unwantedRegionDirs.isEmpty(), "found extraneous regions: " + unwantedRegionDirs);
LOG.debug("Table directory layout is as expected.");

// check meta
Expand All @@ -228,10 +228,10 @@ public static void validateTableCreation(final HMaster master, final TableName t

// check htd
TableDescriptor htd = master.getTableDescriptors().get(tableName);
assertTrue("table descriptor not found", htd != null);
assertTrue(htd != null, "table descriptor not found");
for (int i = 0; i < family.length; ++i) {
assertTrue("family not found " + family[i],
htd.getColumnFamily(Bytes.toBytes(family[i])) != null);
assertTrue(htd.getColumnFamily(Bytes.toBytes(family[i])) != null,
"family not found " + family[i]);
}
assertEquals(family.length, htd.getColumnFamilyCount());

Expand All @@ -254,7 +254,7 @@ public static void validateTableDeletion(final HMaster master, final TableName t
assertEquals(0, countMetaRegions(master, tableName));

// check htd
assertTrue("found htd of deleted table", master.getTableDescriptors().get(tableName) == null);
assertTrue(master.getTableDescriptors().get(tableName) == null, "found htd of deleted table");
}

private static int countMetaRegions(final HMaster master, final TableName tableName)
Expand Down Expand Up @@ -328,7 +328,7 @@ public static void validateColumnFamilyDeletion(final HMaster master, final Tabl
CommonFSUtils.getTableDir(master.getMasterFileSystem().getRootDir(), tableName);
for (Path regionDir : FSUtils.getRegionDirs(fs, tableDir)) {
final Path familyDir = new Path(regionDir, family);
assertFalse(family + " family dir should not exist", fs.exists(familyDir));
assertFalse(fs.exists(familyDir), family + " family dir should not exist");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.master.procedure;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
import java.util.stream.Stream;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
Expand All @@ -39,30 +38,38 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;

@Category({ MasterTests.class, MediumTests.class })
@Tag(MasterTests.TAG)
@Tag(MediumTests.TAG)
public class TestCloneSnapshotProcedure extends TestTableDDLProcedureBase {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCloneSnapshotProcedure.class);

private static final Logger LOG = LoggerFactory.getLogger(TestCloneSnapshotProcedure.class);

protected final byte[] CF = Bytes.toBytes("cf1");

private static SnapshotProtos.SnapshotDescription snapshot = null;

@After
@BeforeAll
public static void setupCluster() throws Exception {
TestTableDDLProcedureBase.setupCluster();
}

@AfterAll
public static void cleanupTest() throws Exception {
TestTableDDLProcedureBase.cleanupTest();
}

@AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@
import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.TRACKER_IMPL;
import static org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory.Trackers.FILE;

import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;

@Category({ MasterTests.class, MediumTests.class })
@Tag(MasterTests.TAG)
@Tag(MediumTests.TAG)
public class TestCloneSnapshotProcedureFileBasedSFT extends TestCloneSnapshotProcedure {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCloneSnapshotProcedureFileBasedSFT.class);

@BeforeClass
public static void setupCluster() throws Exception {
static {
UTIL.getConfiguration().set(TRACKER_IMPL, FILE.name());
UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
UTIL.startMiniCluster(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
*/
package org.apache.hadoop.hbase.master.procedure;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
Expand All @@ -31,18 +33,14 @@
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.ModifyRegionUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category({ MasterTests.class, MediumTests.class })
@Tag(MasterTests.TAG)
@Tag(MediumTests.TAG)
public class TestCreateDeleteTableProcedureWithRetry {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCreateDeleteTableProcedureWithRetry.class);

private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();

Expand All @@ -51,15 +49,15 @@ public class TestCreateDeleteTableProcedureWithRetry {

private static final String CF = "cf";

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
Configuration conf = UTIL.getConfiguration();
conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
BadMasterObserverForCreateDeleteTable.class.getName());
UTIL.startMiniCluster(1);
}

@AfterClass
@AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
Expand All @@ -73,15 +71,15 @@ public void testCreateDeleteTableRetry() throws IOException {
CreateTableProcedure createProc =
new CreateTableProcedure(procExec.getEnvironment(), htd, regions);
ProcedureTestingUtility.submitAndWait(procExec, createProc);
Assert.assertTrue(UTIL.getAdmin().tableExists(TABLE_NAME));
assertTrue(UTIL.getAdmin().tableExists(TABLE_NAME));
MasterProcedureTestingUtility.validateTableCreation(UTIL.getMiniHBaseCluster().getMaster(),
TABLE_NAME, regions, CF);

UTIL.getAdmin().disableTable(TABLE_NAME);
DeleteTableProcedure deleteProc =
new DeleteTableProcedure(procExec.getEnvironment(), TABLE_NAME);
ProcedureTestingUtility.submitAndWait(procExec, deleteProc);
Assert.assertFalse(UTIL.getAdmin().tableExists(TABLE_NAME));
assertFalse(UTIL.getAdmin().tableExists(TABLE_NAME));
MasterProcedureTestingUtility.validateTableDeletion(UTIL.getMiniHBaseCluster().getMaster(),
TABLE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.master.procedure;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceExistException;
Expand All @@ -34,23 +33,19 @@
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Category({ MasterTests.class, MediumTests.class })
@Tag(MasterTests.TAG)
@Tag(MediumTests.TAG)
public class TestCreateNamespaceProcedure {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCreateNamespaceProcedure.class);

private static final Logger LOG = LoggerFactory.getLogger(TestCreateNamespaceProcedure.class);

protected static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
Expand All @@ -59,13 +54,13 @@ private static void setupConf(Configuration conf) {
conf.setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 1);
}

@BeforeClass
@BeforeAll
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
UTIL.startMiniCluster(1);
}

@AfterClass
@AfterAll
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
Expand All @@ -74,12 +69,12 @@ public static void cleanupTest() throws Exception {
}
}

@Before
@BeforeEach
public void setup() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
}

@After
@AfterEach
public void tearDown() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false);
}
Expand Down
Loading