1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.master;
20
21 import static org.junit.Assert.assertTrue;
22
23 import org.apache.hadoop.hbase.HBaseTestingUtility;
24 import org.apache.hadoop.hbase.HConstants;
25 import org.apache.hadoop.hbase.HTableDescriptor;
26 import org.apache.hadoop.hbase.testclassification.MediumTests;
27 import org.apache.hadoop.hbase.MiniHBaseCluster;
28 import org.apache.hadoop.hbase.TableName;
29 import org.junit.Test;
30 import org.junit.experimental.categories.Category;
31
32 @Category(MediumTests.class)
33 public class TestProcedureConf {
34 private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
35
36 @Test
37 public void testProcedureConfEnable() throws Exception {
38 TableName tableName = TableName.valueOf("testProcedureConfEnable");
39 HTableDescriptor htd = new HTableDescriptor(tableName);
40 MiniHBaseCluster cluster = null;
41
42 try {
43 TEST_UTIL.startMiniCluster();
44 cluster = TEST_UTIL.getHBaseCluster();
45 HMaster m = cluster.getMaster();
46 long procid = m.createTable(htd, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
47 assertTrue(procid > 0);
48 } finally {
49 if (cluster != null) {
50 TEST_UTIL.shutdownMiniCluster();
51 }
52 }
53 }
54
55 @Test
56 public void testProcedureConfDisable() throws Exception {
57 TableName tableName = TableName.valueOf("testProcedureConfDisable");
58 HTableDescriptor htd = new HTableDescriptor(tableName);
59 MiniHBaseCluster cluster = null;
60
61 try {
62 TEST_UTIL.getConfiguration().set("hbase.master.procedure.tableddl", "disabled");
63 TEST_UTIL.startMiniCluster();
64 cluster = TEST_UTIL.getHBaseCluster();
65 HMaster m = cluster.getMaster();
66 long procid = m.createTable(htd, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
67 assertTrue(procid < 0);
68 } finally {
69 if (cluster != null) {
70 TEST_UTIL.shutdownMiniCluster();
71 }
72 }
73 }
74
75 @Test
76 public void testProcedureConfUnused() throws Exception {
77 TableName tableName = TableName.valueOf("testProcedureConfUnused");
78 HTableDescriptor htd = new HTableDescriptor(tableName);
79 MiniHBaseCluster cluster = null;
80
81 try {
82 TEST_UTIL.getConfiguration().set("hbase.master.procedure.tableddl", "unused");
83 TEST_UTIL.startMiniCluster();
84 cluster = TEST_UTIL.getHBaseCluster();
85 HMaster m = cluster.getMaster();
86 long procid = m.createTable(htd, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
87 assertTrue(procid < 0);
88 } finally {
89 if (cluster != null) {
90 TEST_UTIL.shutdownMiniCluster();
91 }
92 }
93 }
94 }