View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.client;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  import org.apache.hadoop.hbase.HBaseTestingUtility;
24  import org.apache.hadoop.hbase.HConstants;
25  import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
26  import org.apache.hadoop.hbase.security.access.SecureTestUtil;
27  import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
28  import org.jruby.embed.ScriptingContainer;
29  import org.junit.AfterClass;
30  import org.junit.BeforeClass;
31  
32  public abstract class AbstractTestShell {
33  
34    protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
35    protected final static ScriptingContainer jruby = new ScriptingContainer();
36  
37    @BeforeClass
38    public static void setUpBeforeClass() throws Exception {
39      // Start mini cluster
40      TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
41      TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
42      TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
43      TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
44      TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
45      TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
46      TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, -1);
47      TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, -1);
48      // Security setup configuration
49      SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
50      VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());
51  
52      TEST_UTIL.startMiniCluster();
53  
54      // Configure jruby runtime
55      List<String> loadPaths = new ArrayList();
56      loadPaths.add("src/main/ruby");
57      loadPaths.add("src/test/ruby");
58      jruby.getProvider().setLoadPaths(loadPaths);
59      jruby.put("$TEST_CLUSTER", TEST_UTIL);
60      System.setProperty("jruby.jit.logging.verbose", "true");
61      System.setProperty("jruby.jit.logging", "true");
62      System.setProperty("jruby.native.verbose", "true");
63    }
64  
65    @AfterClass
66    public static void tearDownAfterClass() throws Exception {
67      TEST_UTIL.shutdownMiniCluster();
68    }
69  }