1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.client;
20
21 import static org.junit.Assert.assertEquals;
22
23 import java.io.IOException;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.hadoop.conf.Configuration;
27 import org.apache.hadoop.hbase.HBaseTestingUtility;
28 import org.apache.hadoop.hbase.ServerName;
29 import org.apache.hadoop.hbase.testclassification.MediumTests;
30 import org.junit.BeforeClass;
31 import org.junit.Rule;
32 import org.junit.Test;
33 import org.junit.experimental.categories.Category;
34 import org.junit.rules.TestName;
35
36 @Category({MediumTests.class})
37 public class TestUpdateConfiguration extends AbstractTestUpdateConfiguration {
38 private static final Log LOG = LogFactory.getLog(TestUpdateConfiguration.class);
39 private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
40
41 @BeforeClass
42 public static void setup() throws Exception {
43 setUpConfigurationFiles(TEST_UTIL);
44 TEST_UTIL.startMiniCluster(2, 1);
45 addResourceToRegionServerConfiguration(TEST_UTIL);
46 }
47
48 @Rule
49 public TestName name = new TestName();
50
51 @Test
52 public void testOnlineConfigChange() throws IOException {
53 LOG.debug("Starting the test " + name.getMethodName());
54 Admin admin = TEST_UTIL.getHBaseAdmin();
55 ServerName server = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
56 admin.updateConfiguration(server);
57 }
58
59 @Test
60 public void testMasterOnlineConfigChange() throws IOException {
61 LOG.debug("Starting the test " + name.getMethodName());
62 replaceHBaseSiteXML();
63 Admin admin = TEST_UTIL.getHBaseAdmin();
64
65 ServerName server = TEST_UTIL.getHBaseCluster().getMaster().getServerName();
66 admin.updateConfiguration(server);
67 Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration();
68 int custom = conf.getInt("hbase.custom.config", 0);
69 assertEquals(1000, custom);
70 restoreHBaseSiteXML();
71 }
72
73 @Test
74 public void testAllOnlineConfigChange() throws IOException {
75 LOG.debug("Starting the test " + name.getMethodName());
76 Admin admin = TEST_UTIL.getHBaseAdmin();
77 admin.updateConfiguration();
78 }
79
80 @Test
81 public void testAllCustomOnlineConfigChange() throws IOException {
82 LOG.debug("Starting the test " + name.getMethodName());
83 replaceHBaseSiteXML();
84
85 Admin admin = TEST_UTIL.getHBaseAdmin();
86 admin.updateConfiguration();
87
88
89 Configuration masterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(0).getConfiguration();
90 int custom = masterConfiguration.getInt("hbase.custom.config", 0);
91 assertEquals(custom, 1000);
92 Configuration backupMasterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(1).getConfiguration();
93 custom = backupMasterConfiguration.getInt("hbase.custom.config", 0);
94 assertEquals(custom, 1000);
95
96
97 Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getConfiguration();
98 custom = regionServerConfiguration.getInt("hbase.custom.config", 0);
99 assertEquals(custom, 1000);
100
101 restoreHBaseSiteXML();
102 }
103 }