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  
20  package org.apache.hadoop.hbase.client;
21  
22  import java.io.IOException;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  import org.apache.hadoop.hbase.HBaseTestingUtility;
29  import org.apache.hadoop.hbase.HConstants;
30  import org.apache.hadoop.hbase.LargeTests;
31  import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
32  import org.apache.hadoop.hbase.security.access.SecureTestUtil;
33  import org.jruby.embed.PathType;
34  import org.jruby.embed.ScriptingContainer;
35  import org.junit.AfterClass;
36  import org.junit.BeforeClass;
37  import org.junit.Test;
38  import org.junit.experimental.categories.Category;
39  
40  @Category(LargeTests.class)
41  public class TestShell {
42    final Log LOG = LogFactory.getLog(getClass());
43    private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
44    private final static ScriptingContainer jruby = new ScriptingContainer();
45  
46    @BeforeClass
47    public static void setUpBeforeClass() throws Exception {
48      // Start mini cluster
49      TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
50      TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
51      TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
52      TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
53      TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
54      // Security setup configuration
55      SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
56  
57      TEST_UTIL.startMiniCluster();
58  
59      // Configure jruby runtime
60      List<String> loadPaths = new ArrayList();
61      loadPaths.add("src/main/ruby");
62      loadPaths.add("src/test/ruby");
63      jruby.getProvider().setLoadPaths(loadPaths);
64      jruby.put("$TEST_CLUSTER", TEST_UTIL);
65    }
66  
67    @AfterClass
68    public static void tearDownAfterClass() throws Exception {
69      TEST_UTIL.shutdownMiniCluster();
70    }
71  
72    @Test
73    public void testRunShellTests() throws IOException {
74      // Start all ruby tests
75      jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
76    }
77  
78  }
79