001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.client; 019 020import java.io.IOException; 021import java.util.ArrayList; 022import java.util.List; 023import org.apache.hadoop.conf.Configuration; 024import org.apache.hadoop.hbase.HBaseTestingUtility; 025import org.apache.hadoop.hbase.HConstants; 026import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; 027import org.apache.hadoop.hbase.security.access.SecureTestUtil; 028import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil; 029import org.jruby.embed.ScriptingContainer; 030import org.junit.AfterClass; 031import org.junit.BeforeClass; 032 033public abstract class AbstractTestShell { 034 035 protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); 036 protected final static ScriptingContainer jruby = new ScriptingContainer(); 037 038 protected static void setUpConfig() throws IOException { 039 Configuration conf = TEST_UTIL.getConfiguration(); 040 conf.setInt("hbase.regionserver.msginterval", 100); 041 conf.setInt("hbase.client.pause", 250); 042 conf.setBoolean("hbase.quota.enabled", true); 043 conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6); 044 conf.setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false); 045 conf.setInt("hfile.format.version", 3); 046 047 // Below settings are necessary for task monitor test. 048 conf.setInt(HConstants.MASTER_INFO_PORT, 0); 049 conf.setInt(HConstants.REGIONSERVER_INFO_PORT, 0); 050 conf.setBoolean(HConstants.REGIONSERVER_INFO_PORT_AUTO, true); 051 // Security setup configuration 052 SecureTestUtil.enableSecurity(conf); 053 VisibilityTestUtil.enableVisiblityLabels(conf); 054 } 055 056 protected static void setUpJRubyRuntime() { 057 // Configure jruby runtime 058 List<String> loadPaths = new ArrayList<>(2); 059 loadPaths.add("src/main/ruby"); 060 loadPaths.add("src/test/ruby"); 061 jruby.setLoadPaths(loadPaths); 062 jruby.put("$TEST_CLUSTER", TEST_UTIL); 063 System.setProperty("jruby.jit.logging.verbose", "true"); 064 System.setProperty("jruby.jit.logging", "true"); 065 System.setProperty("jruby.native.verbose", "true"); 066 } 067 068 @BeforeClass 069 public static void setUpBeforeClass() throws Exception { 070 setUpConfig(); 071 072 // Start mini cluster 073 TEST_UTIL.startMiniCluster(1); 074 075 setUpJRubyRuntime(); 076 } 077 078 @AfterClass 079 public static void tearDownAfterClass() throws Exception { 080 TEST_UTIL.shutdownMiniCluster(); 081 } 082}