HBASE-21258 Add resetting of flags for RS Group pre/post hooks in TestRSGroups
This commit is contained in:
parent
8b26882fb4
commit
a8f0f1d95a
|
@ -22,7 +22,6 @@ package org.apache.hadoop.hbase.rsgroup;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
@ -43,7 +42,6 @@ import org.apache.hadoop.hbase.Waiter.Predicate;
|
|||
import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver;
|
||||
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
|
||||
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
|
||||
import org.apache.hadoop.hbase.coprocessor.MasterObserver;
|
||||
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
|
@ -67,10 +65,10 @@ import com.google.common.collect.Sets;
|
|||
@Category({MediumTests.class})
|
||||
public class TestRSGroups extends TestRSGroupsBase {
|
||||
protected static final Log LOG = LogFactory.getLog(TestRSGroups.class);
|
||||
private static HMaster master;
|
||||
static HMaster master;
|
||||
private static boolean init = false;
|
||||
private static RSGroupAdminEndpoint RSGroupAdminEndpoint;
|
||||
private static CPMasterObserver observer;
|
||||
static CPMasterObserver observer;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
|
@ -123,7 +121,7 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
init = true;
|
||||
afterMethod();
|
||||
}
|
||||
|
||||
observer.resetFlags();
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -149,7 +147,6 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
assertTrue(observer.preMoveServersCalled);
|
||||
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
|
||||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
|
@ -216,46 +213,6 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamespaceConstraint() throws Exception {
|
||||
String nsName = tablePrefix+"_foo";
|
||||
String groupName = tablePrefix+"_foo";
|
||||
LOG.info("testNamespaceConstraint");
|
||||
rsGroupAdmin.addRSGroup(groupName);
|
||||
assertTrue(observer.preAddRSGroupCalled);
|
||||
assertTrue(observer.postAddRSGroupCalled);
|
||||
|
||||
admin.createNamespace(NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName)
|
||||
.build());
|
||||
//test removing a referenced group
|
||||
try {
|
||||
rsGroupAdmin.removeRSGroup(groupName);
|
||||
fail("Expected a constraint exception");
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
//test modify group
|
||||
//changing with the same name is fine
|
||||
admin.modifyNamespace(
|
||||
NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName)
|
||||
.build());
|
||||
String anotherGroup = tablePrefix+"_anotherGroup";
|
||||
rsGroupAdmin.addRSGroup(anotherGroup);
|
||||
//test add non-existent group
|
||||
admin.deleteNamespace(nsName);
|
||||
rsGroupAdmin.removeRSGroup(groupName);
|
||||
assertTrue(observer.preRemoveRSGroupCalled);
|
||||
assertTrue(observer.postRemoveRSGroupCalled);
|
||||
try {
|
||||
admin.createNamespace(NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, "foo")
|
||||
.build());
|
||||
fail("Expected a constraint exception");
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupInfoMultiAccessing() throws Exception {
|
||||
RSGroupInfoManager manager = RSGroupAdminEndpoint.getGroupInfoManager();
|
||||
|
@ -283,6 +240,24 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
boolean preMoveServersAndTables = false;
|
||||
boolean postMoveServersAndTables = false;
|
||||
|
||||
void resetFlags() {
|
||||
LOG.debug("calling resetFlags");
|
||||
preBalanceRSGroupCalled = false;
|
||||
postBalanceRSGroupCalled = false;
|
||||
preMoveServersCalled = false;
|
||||
postMoveServersCalled = false;
|
||||
preMoveTablesCalled = false;
|
||||
postMoveTablesCalled = false;
|
||||
preAddRSGroupCalled = false;
|
||||
postAddRSGroupCalled = false;
|
||||
preRemoveRSGroupCalled = false;
|
||||
postRemoveRSGroupCalled = false;
|
||||
preRemoveServersCalled = false;
|
||||
postRemoveServersCalled = false;
|
||||
preMoveServersAndTables = false;
|
||||
postMoveServersAndTables = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preMoveServersAndTables(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
Set<Address> servers, Set<TableName> tables, String targetGroup) throws IOException {
|
||||
|
@ -318,6 +293,7 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
@Override
|
||||
public void preAddRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
String name) throws IOException {
|
||||
LOG.debug("setting preAddRSGroupCalled");
|
||||
preAddRSGroupCalled = true;
|
||||
}
|
||||
@Override
|
||||
|
@ -338,6 +314,7 @@ public class TestRSGroups extends TestRSGroupsBase {
|
|||
@Override
|
||||
public void preMoveServers(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
Set<Address> servers, String targetGroup) throws IOException {
|
||||
LOG.debug("setting preMoveServersCalled");
|
||||
preMoveServersCalled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
/**
|
||||
* Copyright The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.rsgroup;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
/*
|
||||
* The two tests in this class are separated from TestRSGroups
|
||||
* so that the observer pre/post hook called checks are stable.
|
||||
* There are some tests from TestRSGroupsBase which are empty since
|
||||
* they would be run by TestRSGroups.
|
||||
*/
|
||||
@Category({MediumTests.class})
|
||||
public class TestRSGroups1 extends TestRSGroups {
|
||||
protected static final Log LOG = LogFactory.getLog(TestRSGroups1.class);
|
||||
|
||||
@Test
|
||||
public void testNamespaceConstraint() throws Exception {
|
||||
String nsName = tablePrefix+"_foo";
|
||||
String groupName = tablePrefix+"_foo";
|
||||
LOG.info("testNamespaceConstraint");
|
||||
rsGroupAdmin.addRSGroup(groupName);
|
||||
assertTrue(observer.preAddRSGroupCalled);
|
||||
assertTrue(observer.postAddRSGroupCalled);
|
||||
|
||||
admin.createNamespace(NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName)
|
||||
.build());
|
||||
//test removing a referenced group
|
||||
try {
|
||||
rsGroupAdmin.removeRSGroup(groupName);
|
||||
fail("Expected a constraint exception");
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
//test modify group
|
||||
//changing with the same name is fine
|
||||
admin.modifyNamespace(
|
||||
NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName)
|
||||
.build());
|
||||
String anotherGroup = tablePrefix+"_anotherGroup";
|
||||
rsGroupAdmin.addRSGroup(anotherGroup);
|
||||
//test add non-existent group
|
||||
admin.deleteNamespace(nsName);
|
||||
rsGroupAdmin.removeRSGroup(groupName);
|
||||
assertTrue(observer.preRemoveRSGroupCalled);
|
||||
assertTrue(observer.postRemoveRSGroupCalled);
|
||||
try {
|
||||
admin.createNamespace(NamespaceDescriptor.create(nsName)
|
||||
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, "foo")
|
||||
.build());
|
||||
fail("Expected a constraint exception");
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveServers() throws Exception {
|
||||
super.testMoveServers();
|
||||
assertTrue(observer.preMoveServersCalled);
|
||||
assertTrue(observer.postMoveServersCalled);
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
public void testBogusArgs() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testCreateMultiRegion() throws IOException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testCreateAndDrop() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testSimpleRegionServerMove() throws IOException,
|
||||
InterruptedException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testTableMoveTruncateAndDrop() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testGroupBalance() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testRegionMove() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testFailRemoveGroup() throws IOException, InterruptedException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testKillRS() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testValidGroupNames() throws IOException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testMultiTableMove() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testMoveServersAndTables() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testDisabledTableMove() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testClearDeadServers() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testRemoveServers() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testBasicStartUp() throws IOException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testNamespaceCreateAndAssign() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testDefaultNamespaceCreateAndAssign() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testGroupInfoMultiAccessing() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testMisplacedRegions() throws Exception {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testRSGroupBalancerSwitch() throws IOException {
|
||||
}
|
||||
@Ignore @Test
|
||||
public void testCloneSnapshot() throws Exception {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue