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.util.ArrayList; 021import java.util.List; 022 023import org.apache.hadoop.hbase.HBaseTestingUtility; 024import org.apache.hadoop.hbase.HConstants; 025import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; 026import org.apache.hadoop.hbase.security.access.SecureTestUtil; 027import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil; 028import org.jruby.embed.ScriptingContainer; 029import org.junit.AfterClass; 030import org.junit.BeforeClass; 031 032public abstract class AbstractTestShell { 033 034 protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); 035 protected final static ScriptingContainer jruby = new ScriptingContainer(); 036 037 @BeforeClass 038 public static void setUpBeforeClass() throws Exception { 039 // Start mini cluster 040 TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100); 041 TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250); 042 TEST_UTIL.getConfiguration().setBoolean("hbase.quota.enabled", true); 043 TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6); 044 TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false); 045 TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3); 046 047 // Below settings are necessary for task monitor test. 048 TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, 0); 049 TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, 0); 050 TEST_UTIL.getConfiguration().setBoolean(HConstants.REGIONSERVER_INFO_PORT_AUTO, true); 051 // Security setup configuration 052 SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration()); 053 VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration()); 054 055 TEST_UTIL.startMiniCluster(); 056 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 @AfterClass 069 public static void tearDownAfterClass() throws Exception { 070 TEST_UTIL.shutdownMiniCluster(); 071 } 072}