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 java.nio.file.FileSystems;
25 import java.nio.file.Files;
26 import java.nio.file.Path;
27 import java.nio.file.StandardCopyOption;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.hadoop.conf.Configuration;
32 import org.apache.hadoop.hbase.HBaseTestingUtility;
33 import org.apache.hadoop.hbase.ServerName;
34 import org.apache.hadoop.hbase.testclassification.MediumTests;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
37 import org.junit.experimental.categories.Category;
38
39 @Category({MediumTests.class})
40 public class TestUpdateConfiguration {
41 private static final Log LOG = LogFactory.getLog(TestUpdateConfiguration.class);
42 private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
43
44 @BeforeClass
45 public static void setup() throws Exception {
46 TEST_UTIL.startMiniCluster();
47 }
48
49 @Test
50 public void testOnlineConfigChange() throws IOException {
51 LOG.debug("Starting the test");
52 Admin admin = TEST_UTIL.getHBaseAdmin();
53 ServerName server = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
54 admin.updateConfiguration(server);
55 }
56
57 @Test
58 public void testMasterOnlineConfigChange() throws IOException {
59 LOG.debug("Starting the test");
60 Path cnfPath = FileSystems.getDefault().getPath("target/test-classes/hbase-site.xml");
61 Path cnf2Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site2.xml");
62 Path cnf3Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site3.xml");
63
64 Files.copy(cnfPath, cnf3Path, StandardCopyOption.REPLACE_EXISTING);
65
66 Files.copy(cnf2Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
67
68 Admin admin = TEST_UTIL.getHBaseAdmin();
69 ServerName server = TEST_UTIL.getHBaseCluster().getMaster().getServerName();
70 admin.updateConfiguration(server);
71 Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration();
72 int custom = conf.getInt("hbase.custom.config", 0);
73 assertEquals(custom, 1000);
74
75 Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
76 }
77 }