View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
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.HTableDescriptor;
25  import org.apache.hadoop.hbase.testclassification.MediumTests;
26  import org.apache.hadoop.hbase.MiniHBaseCluster;
27  import org.apache.hadoop.hbase.TableName;
28  import org.junit.Test;
29  import org.junit.experimental.categories.Category;
30  
31  @Category(MediumTests.class)
32  public class TestProcedureConf {
33    private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
34  
35    @Test
36    public void testProcedureConfEnable() throws Exception {
37      TableName tableName = TableName.valueOf("testProcedureConfEnable");
38      HTableDescriptor htd = new HTableDescriptor(tableName);
39      MiniHBaseCluster cluster = null;
40  
41      try {
42        TEST_UTIL.startMiniCluster();
43        cluster = TEST_UTIL.getHBaseCluster();
44        HMaster m = cluster.getMaster();
45        long procid = m.createTable(htd, null);
46        assertTrue(procid > 0);
47      } finally {
48        if (cluster != null) {
49          TEST_UTIL.shutdownMiniCluster();
50        }
51      }
52    }
53  
54    @Test
55    public void testProcedureConfDisable() throws Exception {
56      TableName tableName = TableName.valueOf("testProcedureConfDisable");
57      HTableDescriptor htd = new HTableDescriptor(tableName);
58      MiniHBaseCluster cluster = null;
59  
60      try {
61        TEST_UTIL.getConfiguration().set("hbase.master.procedure.tableddl", "disabled");
62        TEST_UTIL.startMiniCluster();
63        cluster = TEST_UTIL.getHBaseCluster();
64        HMaster m = cluster.getMaster();
65        long procid = m.createTable(htd, null);
66        assertTrue(procid < 0);
67      } finally {
68        if (cluster != null) {
69          TEST_UTIL.shutdownMiniCluster();
70        }
71      }
72    }
73  
74    @Test
75    public void testProcedureConfUnused() throws Exception {
76      TableName tableName = TableName.valueOf("testProcedureConfUnused");
77      HTableDescriptor htd = new HTableDescriptor(tableName);
78      MiniHBaseCluster cluster = null;
79  
80      try {
81        TEST_UTIL.getConfiguration().set("hbase.master.procedure.tableddl", "unused");
82        TEST_UTIL.startMiniCluster();
83        cluster = TEST_UTIL.getHBaseCluster();
84        HMaster m = cluster.getMaster();
85        long procid = m.createTable(htd, null);
86        assertTrue(procid < 0);
87      } finally {
88        if (cluster != null) {
89          TEST_UTIL.shutdownMiniCluster();
90        }
91      }
92    }
93  }