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.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  }