001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.rsgroup;
019
020import static org.junit.Assert.assertTrue;
021
022import org.apache.hadoop.hbase.HBaseClassTestRule;
023import org.apache.hadoop.hbase.ServerName;
024import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
025import org.apache.hadoop.hbase.TableName;
026import org.apache.hadoop.hbase.testclassification.MediumTests;
027import org.apache.hadoop.hbase.testclassification.RSGroupTests;
028import org.junit.After;
029import org.junit.AfterClass;
030import org.junit.Before;
031import org.junit.BeforeClass;
032import org.junit.ClassRule;
033import org.junit.Test;
034import org.junit.experimental.categories.Category;
035
036@Category({ RSGroupTests.class, MediumTests.class })
037public class TestRSGroupsCPHookCalled extends TestRSGroupsBase {
038
039  @ClassRule
040  public static final HBaseClassTestRule CLASS_RULE =
041    HBaseClassTestRule.forClass(TestRSGroupsCPHookCalled.class);
042
043  @BeforeClass
044  public static void setUp() throws Exception {
045    setUpTestBeforeClass();
046  }
047
048  @AfterClass
049  public static void tearDown() throws Exception {
050    tearDownAfterClass();
051  }
052
053  @Before
054  public void beforeMethod() throws Exception {
055    setUpBeforeMethod();
056  }
057
058  @After
059  public void afterMethod() throws Exception {
060    tearDownAfterMethod();
061  }
062
063  @Test
064  public void testGetRSGroupInfoCPHookCalled() throws Exception {
065    ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
066    assertTrue(OBSERVER.preGetRSGroupInfoCalled);
067    assertTrue(OBSERVER.postGetRSGroupInfoCalled);
068  }
069
070  @Test
071  public void testGetRSGroupInfoOfTableCPHookCalled() throws Exception {
072    ADMIN.getRSGroup(TableName.META_TABLE_NAME);
073    assertTrue(OBSERVER.preGetRSGroupInfoOfTableCalled);
074    assertTrue(OBSERVER.postGetRSGroupInfoOfTableCalled);
075  }
076
077  @Test
078  public void testListRSGroupsCPHookCalled() throws Exception {
079    ADMIN.listRSGroups();
080    assertTrue(OBSERVER.preListRSGroupsCalled);
081    assertTrue(OBSERVER.postListRSGroupsCalled);
082  }
083
084  @Test
085  public void testGetRSGroupInfoOfServerCPHookCalled() throws Exception {
086    ServerName masterServerName = ((SingleProcessHBaseCluster) CLUSTER).getMaster().getServerName();
087    ADMIN.getRSGroup(masterServerName.getAddress());
088    assertTrue(OBSERVER.preGetRSGroupInfoOfServerCalled);
089    assertTrue(OBSERVER.postGetRSGroupInfoOfServerCalled);
090  }
091}