HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-shell / src / test / ruby / tests_runner.rb
blob147d68103f5e5bad791a75538663446d015ec2fa
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'
24 puts "Ruby description: #{RUBY_DESCRIPTION}"
26 unless defined?($TEST_CLUSTER)
27   include Java
29   # Set logging level to avoid verboseness
30   org.apache.log4j.Logger.getRootLogger.setLevel(org.apache.log4j.Level::OFF)
31   org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(org.apache.log4j.Level::OFF)
32   org.apache.log4j.Logger.getLogger("org.apache.hadoop.hdfs").setLevel(org.apache.log4j.Level::OFF)
33   org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(org.apache.log4j.Level::OFF)
34   org.apache.log4j.Logger.getLogger("org.apache.hadoop.ipc.HBaseServer").setLevel(org.apache.log4j.Level::OFF)
36   java_import org.apache.hadoop.hbase.HBaseTestingUtility
38   $TEST_CLUSTER = HBaseTestingUtility.new
39   $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100)
40   $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250)
41   $TEST_CLUSTER.configuration.set("hbase.quota.enabled", "true")
42   $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.period', 5000)
43   $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.delay', 5000)
44   $TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER, 6)
45   $TEST_CLUSTER.startMiniCluster
46   @own_cluster = true
47 end
49 require 'test_helper'
51 puts "Running tests..."
53 if java.lang.System.get_property('shell.test.include')
54   includes = Set.new(java.lang.System.get_property('shell.test.include').split(','))
55 end
57 if java.lang.System.get_property('shell.test.exclude')
58   excludes = Set.new(java.lang.System.get_property('shell.test.exclude').split(','))
59 end
61 files = Dir[ File.dirname(__FILE__) + "/**/*_test.rb" ]
62 files.each do |file|
63   filename = File.basename(file)
64   if includes != nil && !includes.include?(filename)
65     puts "Skip #{filename} because of not included"
66     next
67   end
68   if excludes != nil && excludes.include?(filename)
69     puts "Skip #{filename} because of excluded"
70     next
71   end
72   begin
73     puts "loading test file '#{filename}'."
74     load(file)
75   rescue => e
76     puts "ERROR: #{e}"
77     raise
78   end
79 end
81 # If this system property is set, we'll use it to filter the test cases.
82 runner_args = []
83 if java.lang.System.get_property('shell.test')
84   shell_test_pattern = java.lang.System.get_property('shell.test')
85   puts "Only running tests that match #{shell_test_pattern}"
86   runner_args << "--testcase=#{shell_test_pattern}"
87 end
88 begin
89   # first couple of args are to match the defaults, so we can pass options to limit the tests run
90   unless Test::Unit::AutoRunner.run(false, nil, runner_args)
91     raise 'Shell unit tests failed. Check output file for details.'
92   end
93 rescue SystemExit => e
94   # Unit tests should not raise uncaught SystemExit exceptions. This could cause tests to be ignored.
95   raise 'Caught SystemExit during unit test execution! Check output file for details.'
96 end
98 puts "Done with tests! Shutting down the cluster..."
99 if @own_cluster
100   $TEST_CLUSTER.shutdownMiniCluster
101   java.lang.System.exit(0)