HBASE-23723 Ensure MOB compaction works in optimized mode after snapshot clone (...
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / TestUpdateConfiguration.java
blobe8036fc4e9afb42b5558804539e0db25e9338827
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import static org.junit.Assert.assertEquals;
22 import java.io.IOException;
23 import org.apache.hadoop.conf.Configuration;
24 import org.apache.hadoop.hbase.HBaseClassTestRule;
25 import org.apache.hadoop.hbase.HBaseTestingUtility;
26 import org.apache.hadoop.hbase.ServerName;
27 import org.apache.hadoop.hbase.StartMiniClusterOption;
28 import org.apache.hadoop.hbase.testclassification.MediumTests;
29 import org.junit.BeforeClass;
30 import org.junit.ClassRule;
31 import org.junit.Rule;
32 import org.junit.Test;
33 import org.junit.experimental.categories.Category;
34 import org.junit.rules.TestName;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 @Category({MediumTests.class})
39 public class TestUpdateConfiguration extends AbstractTestUpdateConfiguration {
41 @ClassRule
42 public static final HBaseClassTestRule CLASS_RULE =
43 HBaseClassTestRule.forClass(TestUpdateConfiguration.class);
45 private static final Logger LOG = LoggerFactory.getLogger(TestUpdateConfiguration.class);
46 private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
48 @BeforeClass
49 public static void setup() throws Exception {
50 setUpConfigurationFiles(TEST_UTIL);
51 StartMiniClusterOption option = StartMiniClusterOption.builder().numMasters(2).build();
52 TEST_UTIL.startMiniCluster(option);
53 addResourceToRegionServerConfiguration(TEST_UTIL);
56 @Rule
57 public TestName name = new TestName();
59 @Test
60 public void testOnlineConfigChange() throws IOException {
61 LOG.debug("Starting the test {}", name.getMethodName());
62 Admin admin = TEST_UTIL.getAdmin();
63 ServerName server = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
64 admin.updateConfiguration(server);
67 @Test
68 public void testMasterOnlineConfigChange() throws IOException {
69 LOG.debug("Starting the test {}", name.getMethodName());
70 replaceHBaseSiteXML();
71 Admin admin = TEST_UTIL.getAdmin();
72 ServerName server = TEST_UTIL.getHBaseCluster().getMaster().getServerName();
73 admin.updateConfiguration(server);
74 Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration();
75 int custom = conf.getInt("hbase.custom.config", 0);
76 assertEquals(1000, custom);
77 restoreHBaseSiteXML();
80 @Test
81 public void testAllOnlineConfigChange() throws IOException {
82 LOG.debug("Starting the test {} ", name.getMethodName());
83 Admin admin = TEST_UTIL.getAdmin();
84 admin.updateConfiguration();
87 @Test
88 public void testAllCustomOnlineConfigChange() throws IOException {
89 LOG.debug("Starting the test {}", name.getMethodName());
90 replaceHBaseSiteXML();
92 Admin admin = TEST_UTIL.getAdmin();
93 admin.updateConfiguration();
95 // Check the configuration of the Masters
96 Configuration masterConfiguration =
97 TEST_UTIL.getMiniHBaseCluster().getMaster(0).getConfiguration();
98 int custom = masterConfiguration.getInt("hbase.custom.config", 0);
99 assertEquals(1000, custom);
100 Configuration backupMasterConfiguration =
101 TEST_UTIL.getMiniHBaseCluster().getMaster(1).getConfiguration();
102 custom = backupMasterConfiguration.getInt("hbase.custom.config", 0);
103 assertEquals(1000, custom);
105 // Check the configuration of the RegionServer
106 Configuration regionServerConfiguration =
107 TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getConfiguration();
108 custom = regionServerConfiguration.getInt("hbase.custom.config", 0);
109 assertEquals(1000, custom);
111 restoreHBaseSiteXML();