HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-shell / src / test / ruby / no_cluster_tests_runner.rb
blob77b16df02e7cbc50c5137d2035404dff2fb8d94b
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
11 #     http://www.apache.org/licenses/LICENSE-2.0
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.
20 require 'rubygems'
21 require 'rake'
22 require 'set'
25 # This runner will only launch shell tests that don't require a HBase cluster running.
27 unless defined?($TEST_CLUSTER)
28   include Java
30   # Set logging level to avoid verboseness
31   org.apache.log4j.Logger.getRootLogger.setLevel(org.apache.log4j.Level::OFF)
32   org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(org.apache.log4j.Level::OFF)
33   org.apache.log4j.Logger.getLogger("org.apache.hadoop.hdfs").setLevel(org.apache.log4j.Level::OFF)
34   org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(org.apache.log4j.Level::OFF)
35   org.apache.log4j.Logger.getLogger("org.apache.hadoop.ipc.HBaseServer").setLevel(org.apache.log4j.Level::OFF)
37   java_import org.apache.hadoop.hbase.HBaseTestingUtility
39   $TEST_CLUSTER = HBaseTestingUtility.new
40   $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100)
41   $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250)
42   $TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER, 6)
43 end
45 require 'test_helper'
47 puts "Running tests without a cluster..."
49 if java.lang.System.get_property('shell.test.include')
50   includes = Set.new(java.lang.System.get_property('shell.test.include').split(','))
51 end
53 if java.lang.System.get_property('shell.test.exclude')
54   excludes = Set.new(java.lang.System.get_property('shell.test.exclude').split(','))
55 end
57 files = Dir[ File.dirname(__FILE__) + "/**/*_no_cluster.rb" ]
58 files.each do |file|
59   filename = File.basename(file)
60   if includes != nil && !includes.include?(filename)
61     puts "Skip #{filename} because of not included"
62     next
63   end
64   if excludes != nil && excludes.include?(filename)
65     puts "Skip #{filename} because of excluded"
66     next
67   end
68   begin
69     load(file)
70   rescue => e
71     puts "ERROR: #{e}"
72     raise
73   end
74 end
76 # If this system property is set, we'll use it to filter the test cases.
77 runner_args = []
78 if java.lang.System.get_property('shell.test')
79   shell_test_pattern = java.lang.System.get_property('shell.test')
80   puts "Only running tests that match #{shell_test_pattern}"
81   runner_args << "--testcase=#{shell_test_pattern}"
82 end
83 # first couple of args are to match the defaults, so we can pass options to limit the tests run
84 if !(Test::Unit::AutoRunner.run(false, nil, runner_args))
85   raise "Shell unit tests failed. Check output file for details."
86 end
88 puts "Done with tests! Shutting down the cluster..."
89 if @own_cluster
90   $TEST_CLUSTER.shutdownMiniCluster
91   java.lang.System.exit(0)
92 end