private void toggleQuotaCheckAndRestartMiniCluster(boolean enable) throws Exception { TEST_UTIL.shutdownMiniCluster(); TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, enable); TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE - 1); TEST_UTIL.getConfiguration().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, NUM_SLAVES_BASE - 1); TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true); initialize(); } }
@Before public void beforeMethod() throws Exception { setUpBeforeMethod(); }
@BeforeClass public static void setUp() throws Exception { setUpTestBeforeClass(); }
@Test public void testDisabledTableMove() throws Exception { final byte[] familyNameBytes = Bytes.toBytes("f"); String newGroupName = getGroupName(name.getMethodName()); final RSGroupInfo newGroup = addGroup(newGroupName, 2); TEST_UTIL.createMultiRegionTable(tableName, familyNameBytes, 5); TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { List<String> regions = getTableRegionMap().get(tableName); if (regions == null) { return false; } return getTableRegionMap().get(tableName).size() >= 5; } }); RSGroupInfo tableGrp = rsGroupAdmin.getRSGroupInfoOfTable(tableName); assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP)); // test disable table admin.disableTable(tableName); // change table's group LOG.info("Moving table " + tableName + " to " + newGroup.getName()); rsGroupAdmin.moveTables(Sets.newHashSet(tableName), newGroup.getName()); // verify group change Assert.assertEquals(newGroup.getName(), rsGroupAdmin.getRSGroupInfoOfTable(tableName).getName()); }
@After public void afterMethod() throws Exception { tearDownAfterMethod(); }
@AfterClass public static void tearDown() throws Exception { tearDownAfterClass(); }
@Test public void testRSGroupListDoesNotContainFailedTableCreation() throws Exception { toggleQuotaCheckAndRestartMiniCluster(true); String nsp = "np1"; NamespaceDescriptor nspDesc = toggleQuotaCheckAndRestartMiniCluster(false);
@Test public void testFailRemoveGroup() throws IOException, InterruptedException { int initNumGroups = rsGroupAdmin.listRSGroups().size(); addGroup("bar", 3); TEST_UTIL.createTable(tableName, Bytes.toBytes("f")); rsGroupAdmin.moveTables(Sets.newHashSet(tableName), "bar"); RSGroupInfo barGroup = rsGroupAdmin.getRSGroupInfo("bar"); // group is not empty therefore it should fail try { rsGroupAdmin.removeRSGroup(barGroup.getName()); fail("Expected remove group to fail"); } catch (IOException e) { } // group cannot lose all it's servers therefore it should fail try { rsGroupAdmin.moveServers(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP); fail("Expected move servers to fail"); } catch (IOException e) { } rsGroupAdmin.moveTables(barGroup.getTables(), RSGroupInfo.DEFAULT_GROUP); try { rsGroupAdmin.removeRSGroup(barGroup.getName()); fail("Expected move servers to fail"); } catch (IOException e) { } rsGroupAdmin.moveServers(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP); rsGroupAdmin.removeRSGroup(barGroup.getName()); Assert.assertEquals(initNumGroups, rsGroupAdmin.listRSGroups().size()); }
final TableName tableNameB = TableName.valueOf(tablePrefix + name.getMethodName() + "B"); final byte[] familyNameBytes = Bytes.toBytes("f"); String newGroupName = getGroupName(name.getMethodName()); final RSGroupInfo newGroup = addGroup(newGroupName, 1);
@Test public void testTableMoveTruncateAndDrop() throws Exception { final byte[] familyNameBytes = Bytes.toBytes("f"); String newGroupName = getGroupName(name.getMethodName()); final RSGroupInfo newGroup = addGroup(newGroupName, 2);