This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.6 by this push:
new a22473aeb2a HBASE-29558: Fix for TestShellNoCluster along with code
refactoring and cleanup (#7256) (#7274)
a22473aeb2a is described below
commit a22473aeb2aab2e50be2e9d3e64d978e3d790f65
Author: Hari Krishna Dara <[email protected]>
AuthorDate: Fri Sep 5 09:34:15 2025 +0530
HBASE-29558: Fix for TestShellNoCluster along with code refactoring and
cleanup (#7256) (#7274)
Signed-off-by: Nihal Jain <[email protected]>
---
.../hadoop/hbase/client/AbstractTestShell.java | 115 +++++++--------------
.../{AbstractTestShell.java => RubyShellTest.java} | 85 +++++++--------
.../apache/hadoop/hbase/client/TestAdminShell.java | 16 +--
.../hadoop/hbase/client/TestAdminShell2.java | 37 -------
.../hadoop/hbase/client/TestChangeSftShell.java | 46 ---------
.../hadoop/hbase/client/TestListTablesShell.java | 12 +--
.../hadoop/hbase/client/TestQuotasShell.java | 3 +-
.../hadoop/hbase/client/TestRSGroupShell.java | 14 +--
.../hadoop/hbase/client/TestReplicationShell.java | 3 +-
.../org/apache/hadoop/hbase/client/TestShell.java | 6 +-
.../hadoop/hbase/client/TestShellNoCluster.java | 41 +++-----
.../apache/hadoop/hbase/client/TestTableShell.java | 3 +-
.../{admin2_test.rb => admin2_test_cluster.rb} | 0
...tils_test.rb => balancer_utils_test_cluster.rb} | 0
...no_cluster.rb => connection_test_no_cluster.rb} | 0
.../hbase/{hbase_test.rb => hbase_test_cluster.rb} | 0
...dmin_test.rb => security_admin_test_cluster.rb} | 0
...monitor_test.rb => taskmonitor_test_cluster.rb} | 0
....rb => visibility_labels_admin_test_cluster.rb} | 0
.../src/test/ruby/no_cluster_tests_runner.rb | 94 -----------------
.../{commands_test.rb => commands_test_cluster.rb} | 0
...converter_test.rb => converter_test_cluster.rb} | 0
...formatter_test.rb => formatter_test_cluster.rb} | 0
.../{shell_test.rb => general_test_cluster.rb} | 0
...st_locks_test.rb => list_locks_test_cluster.rb} | 0
...res_test.rb => list_procedures_test_cluster.rb} | 0
...tive_test.rb => noninteractive_test_cluster.rb} | 0
...nge_shell_test.rb => sftchange_test_cluster.rb} | 0
hbase-shell/src/test/ruby/tests_runner.rb | 37 +------
29 files changed, 115 insertions(+), 397 deletions(-)
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
index 63f651ddf43..ecd1ea6c597 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
@@ -18,103 +18,62 @@
package org.apache.hadoop.hbase.client;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
-import org.apache.hadoop.hbase.security.access.SecureTestUtil;
-import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
-import org.jruby.embed.PathType;
+import org.apache.hadoop.hbase.fs.ErasureCodingUtils;
import org.jruby.embed.ScriptingContainer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public abstract class AbstractTestShell {
+public abstract class AbstractTestShell implements RubyShellTest {
+ protected final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ protected final ScriptingContainer jruby = new ScriptingContainer();
- private static final Logger LOG =
LoggerFactory.getLogger(AbstractTestShell.class);
+ protected boolean erasureCodingSupported = false;
- protected final static HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
- protected final static ScriptingContainer jruby = new ScriptingContainer();
-
- protected static void setUpConfig() throws IOException {
- Configuration conf = TEST_UTIL.getConfiguration();
- conf.setInt("hbase.regionserver.msginterval", 100);
- conf.setInt("hbase.client.pause", 250);
- conf.setBoolean("hbase.quota.enabled", true);
- conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
- conf.setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
- conf.setInt("hfile.format.version", 3);
-
- // Below settings are necessary for task monitor test.
- conf.setInt(HConstants.MASTER_INFO_PORT, 0);
- conf.setInt(HConstants.REGIONSERVER_INFO_PORT, 0);
- conf.setBoolean(HConstants.REGIONSERVER_INFO_PORT_AUTO, true);
- // Security setup configuration
- SecureTestUtil.enableSecurity(conf);
- VisibilityTestUtil.enableVisiblityLabels(conf);
+ public HBaseTestingUtility getTEST_UTIL() {
+ return TEST_UTIL;
}
- protected static void setUpJRubyRuntime() {
- setUpJRubyRuntime(Collections.emptyMap());
+ public ScriptingContainer getJRuby() {
+ return jruby;
}
- protected static void setUpJRubyRuntime(Map<String, Object> extraVars) {
- LOG.debug("Configure jruby runtime, cluster set to {}", TEST_UTIL);
- List<String> loadPaths = new ArrayList<>(2);
- loadPaths.add("src/test/ruby");
- jruby.setLoadPaths(loadPaths);
- jruby.put("$TEST_CLUSTER", TEST_UTIL);
- for (Map.Entry<String, Object> entry : extraVars.entrySet()) {
- jruby.put(entry.getKey(), entry.getValue());
- }
- System.setProperty("jruby.jit.logging.verbose", "true");
- System.setProperty("jruby.jit.logging", "true");
- System.setProperty("jruby.native.verbose", "true");
+ public String getSuitePattern() {
+ return "**/*_test.rb";
}
- /** Returns comma separated list of ruby script names for tests */
- protected String getIncludeList() {
- return "";
- }
+ @Before
+ public void setUp() throws Exception {
+ RubyShellTest.setUpConfig(this);
+
+ // Start mini cluster
+ TEST_UTIL.startMiniCluster(1);
+
+ RubyShellTest.setUpJRubyRuntime(this);
- /** Returns comma separated list of ruby script names for tests to skip */
- protected String getExcludeList() {
- return "";
+ RubyShellTest.doTestSetup(this);
}
- @Test
- public void testRunShellTests() throws IOException {
- final String tests = getIncludeList();
- final String excludes = getExcludeList();
- if (!tests.isEmpty()) {
- System.setProperty("shell.test.include", tests);
+ protected void setupDFS() throws IOException {
+ try {
+
ErasureCodingUtils.enablePolicy(FileSystem.get(TEST_UTIL.getConfiguration()),
+ "XOR-2-1-1024k");
+ erasureCodingSupported = true;
+ } catch (UnsupportedOperationException e) {
+ LOG.info(
+ "Current hadoop version does not support erasure coding, only
validation tests will run.");
}
- if (!excludes.isEmpty()) {
- System.setProperty("shell.test.exclude", excludes);
- }
- LOG.info("Starting ruby tests. includes: {} excludes: {}", tests,
excludes);
- jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
-
- // Start mini cluster
- TEST_UTIL.startMiniCluster(1);
-
- setUpJRubyRuntime();
+ @After
+ public void tearDown() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TEST_UTIL.shutdownMiniCluster();
+ @Test
+ public void testRunShellTests() throws IOException {
+ RubyShellTest.testRunShellTests(this);
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/RubyShellTest.java
similarity index 61%
copy from
hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
copy to
hbase-shell/src/test/java/org/apache/hadoop/hbase/client/RubyShellTest.java
index 63f651ddf43..770acb66a9d 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/AbstractTestShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/RubyShellTest.java
@@ -30,21 +30,30 @@ import
org.apache.hadoop.hbase.security.access.SecureTestUtil;
import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
import org.jruby.embed.PathType;
import org.jruby.embed.ScriptingContainer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractTestShell {
+public interface RubyShellTest {
+ static Logger LOG = LoggerFactory.getLogger(RubyShellTest.class);
- private static final Logger LOG =
LoggerFactory.getLogger(AbstractTestShell.class);
+ HBaseTestingUtility getTEST_UTIL();
- protected final static HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
- protected final static ScriptingContainer jruby = new ScriptingContainer();
+ ScriptingContainer getJRuby();
- protected static void setUpConfig() throws IOException {
- Configuration conf = TEST_UTIL.getConfiguration();
+ /** Returns comma separated list of ruby script names for tests */
+ default String getIncludeList() {
+ return "";
+ }
+
+ /** Returns comma separated list of ruby script names for tests to skip */
+ default String getExcludeList() {
+ return "";
+ }
+
+ String getSuitePattern();
+
+ static void setUpConfig(RubyShellTest test) throws IOException {
+ Configuration conf = test.getTEST_UTIL().getConfiguration();
conf.setInt("hbase.regionserver.msginterval", 100);
conf.setInt("hbase.client.pause", 250);
conf.setBoolean("hbase.quota.enabled", true);
@@ -61,60 +70,38 @@ public abstract class AbstractTestShell {
VisibilityTestUtil.enableVisiblityLabels(conf);
}
- protected static void setUpJRubyRuntime() {
- setUpJRubyRuntime(Collections.emptyMap());
+ static void setUpJRubyRuntime(RubyShellTest test) {
+ setUpJRubyRuntime(test, Collections.emptyMap());
}
- protected static void setUpJRubyRuntime(Map<String, Object> extraVars) {
- LOG.debug("Configure jruby runtime, cluster set to {}", TEST_UTIL);
+ static void setUpJRubyRuntime(RubyShellTest test, Map<String, Object>
extraVars) {
+ LOG.debug("Configure jruby runtime, cluster set to {}",
test.getTEST_UTIL());
List<String> loadPaths = new ArrayList<>(2);
loadPaths.add("src/test/ruby");
- jruby.setLoadPaths(loadPaths);
- jruby.put("$TEST_CLUSTER", TEST_UTIL);
+ test.getJRuby().setLoadPaths(loadPaths);
+ test.getJRuby().put("$TEST_CLUSTER", test.getTEST_UTIL());
for (Map.Entry<String, Object> entry : extraVars.entrySet()) {
- jruby.put(entry.getKey(), entry.getValue());
+ test.getJRuby().put(entry.getKey(), entry.getValue());
}
System.setProperty("jruby.jit.logging.verbose", "true");
System.setProperty("jruby.jit.logging", "true");
System.setProperty("jruby.native.verbose", "true");
}
- /** Returns comma separated list of ruby script names for tests */
- protected String getIncludeList() {
- return "";
- }
-
- /** Returns comma separated list of ruby script names for tests to skip */
- protected String getExcludeList() {
- return "";
- }
-
- @Test
- public void testRunShellTests() throws IOException {
- final String tests = getIncludeList();
- final String excludes = getExcludeList();
- if (!tests.isEmpty()) {
- System.setProperty("shell.test.include", tests);
+ static void doTestSetup(RubyShellTest test) {
+ System.setProperty("shell.test.suite_name",
test.getClass().getSimpleName());
+ System.setProperty("shell.test.suite_pattern", test.getSuitePattern());
+ if (!test.getIncludeList().isEmpty()) {
+ System.setProperty("shell.test.include", test.getIncludeList());
}
- if (!excludes.isEmpty()) {
- System.setProperty("shell.test.exclude", excludes);
+ if (!test.getExcludeList().isEmpty()) {
+ System.setProperty("shell.test.exclude", test.getExcludeList());
}
- LOG.info("Starting ruby tests. includes: {} excludes: {}", tests,
excludes);
- jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
- }
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
-
- // Start mini cluster
- TEST_UTIL.startMiniCluster(1);
-
- setUpJRubyRuntime();
+ LOG.info("Starting ruby tests on script: {} includes: {} excludes: {}",
+ test.getClass().getSimpleName(), test.getIncludeList(),
test.getExcludeList());
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TEST_UTIL.shutdownMiniCluster();
+ static void testRunShellTests(RubyShellTest test) throws IOException {
+ test.getJRuby().runScriptlet(PathType.ABSOLUTE,
"src/test/ruby/tests_runner.rb");
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell.java
index 597ae903d1c..2622c80ac64 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell.java
@@ -23,7 +23,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.fs.ErasureCodingUtils;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
@@ -38,15 +38,15 @@ public class TestAdminShell extends AbstractTestShell {
HBaseClassTestRule.forClass(TestAdminShell.class);
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "admin_test.rb";
}
- protected static boolean erasureCodingSupported = false;
+ protected boolean erasureCodingSupported = false;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
+ @Before
+ public void setUp() throws Exception {
+ RubyShellTest.setUpConfig(this);
// Start mini cluster
// 3 datanodes needed for erasure coding checks
@@ -61,7 +61,9 @@ public class TestAdminShell extends AbstractTestShell {
}
// we'll use this extra variable to trigger some differences in the tests
- setUpJRubyRuntime(
+ RubyShellTest.setUpJRubyRuntime(this,
Collections.singletonMap("$ERASURE_CODING_SUPPORTED",
erasureCodingSupported));
+
+ RubyShellTest.doTestSetup(this);
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell2.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell2.java
deleted file mode 100644
index 0bf67cdc8b4..00000000000
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestAdminShell2.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.client;
-
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-
-@Category({ ClientTests.class, LargeTests.class })
-public class TestAdminShell2 extends AbstractTestShell {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAdminShell2.class);
-
- @Override
- protected String getIncludeList() {
- return "admin2_test.rb";
- }
-}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestChangeSftShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestChangeSftShell.java
deleted file mode 100644
index e8127afcc70..00000000000
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestChangeSftShell.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.client;
-
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-
-@Category({ ClientTests.class, LargeTests.class })
-public class TestChangeSftShell extends AbstractTestShell {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestChangeSftShell.class);
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
-
- TEST_UTIL.startMiniCluster(3);
-
- setUpJRubyRuntime();
- }
-
- @Override
- protected String getIncludeList() {
- return "sftchange_shell_test.rb";
- }
-}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestListTablesShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestListTablesShell.java
index b823b6fc3aa..ffd80f91a38 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestListTablesShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestListTablesShell.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.client;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
@@ -30,17 +29,8 @@ public class TestListTablesShell extends AbstractTestShell {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestListTablesShell.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
-
- TEST_UTIL.startMiniCluster(3);
-
- setUpJRubyRuntime();
- }
-
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "list_tables_test.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestQuotasShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestQuotasShell.java
index d7b9fab42a3..1550478d0a7 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestQuotasShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestQuotasShell.java
@@ -25,13 +25,12 @@ import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, LargeTests.class })
public class TestQuotasShell extends AbstractTestShell {
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestQuotasShell.class);
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "quotas_test.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestRSGroupShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestRSGroupShell.java
index b64f4a43ec8..3f77ca5386d 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestRSGroupShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestRSGroupShell.java
@@ -24,7 +24,7 @@ import org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint;
import org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
@@ -35,9 +35,9 @@ public class TestRSGroupShell extends AbstractTestShell {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRSGroupShell.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- setUpConfig();
+ @Before
+ public void setUp() throws Exception {
+ RubyShellTest.setUpConfig(this);
// enable rs group
TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
@@ -48,11 +48,13 @@ public class TestRSGroupShell extends AbstractTestShell {
TEST_UTIL.startMiniCluster(3);
- setUpJRubyRuntime();
+ RubyShellTest.setUpJRubyRuntime(this);
+
+ RubyShellTest.doTestSetup(this);
}
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "rsgroup_shell_test.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestReplicationShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestReplicationShell.java
index ced1e7adda1..5bf0b3a6328 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestReplicationShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestReplicationShell.java
@@ -25,13 +25,12 @@ import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, LargeTests.class })
public class TestReplicationShell extends AbstractTestShell {
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestReplicationShell.class);
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "replication_admin_test.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
index 47918f68019..28b1fb59ef0 100644
--- a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
+++ b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
@@ -25,13 +25,11 @@ import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, LargeTests.class })
public class TestShell extends AbstractTestShell {
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestShell.class);
@Override
- protected String getExcludeList() {
- return
"replication_admin_test.rb,rsgroup_shell_test.rb,admin_test.rb,table_test.rb,"
- + "quotas_test.rb,admin2_test.rb,list_tables_test.rb";
+ public String getSuitePattern() {
+ return "**/*_test_cluster.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShellNoCluster.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShellNoCluster.java
index c8685f34d19..5c312ec1dac 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShellNoCluster.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShellNoCluster.java
@@ -17,51 +17,38 @@
*/
package org.apache.hadoop.hbase.client;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.jruby.embed.PathType;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@Category({ ClientTests.class, MediumTests.class })
public class TestShellNoCluster extends AbstractTestShell {
- private static final Logger LOG =
LoggerFactory.getLogger(TestShellNoCluster.class);
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestShellNoCluster.class);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @Before
+ public void setUp() throws Exception {
+ RubyShellTest.setUpConfig(this);
+
// no cluster
- List<String> loadPaths = new ArrayList<>(2);
- loadPaths.add("src/test/ruby");
- jruby.setLoadPaths(loadPaths);
- jruby.put("$TEST_CLUSTER", TEST_UTIL);
- System.setProperty("jruby.jit.logging.verbose", "true");
- System.setProperty("jruby.jit.logging", "true");
- System.setProperty("jruby.native.verbose", "true");
+
+ RubyShellTest.setUpJRubyRuntime(this);
+
+ RubyShellTest.doTestSetup(this);
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// no cluster
}
- // Keep the same name so we override the with-a-cluster test
@Override
- @Test
- public void testRunShellTests() throws IOException {
- LOG.info("Start ruby tests without cluster");
- jruby.runScriptlet(PathType.CLASSPATH, "no_cluster_tests_runner.rb");
+ public String getSuitePattern() {
+ return "**/*_test_no_cluster.rb";
}
}
diff --git
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestTableShell.java
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestTableShell.java
index 1ae56ac669b..6158570cc05 100644
---
a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestTableShell.java
+++
b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestTableShell.java
@@ -25,13 +25,12 @@ import org.junit.experimental.categories.Category;
@Category({ ClientTests.class, MediumTests.class })
public class TestTableShell extends AbstractTestShell {
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestTableShell.class);
@Override
- protected String getIncludeList() {
+ public String getIncludeList() {
return "table_test.rb";
}
}
diff --git a/hbase-shell/src/test/ruby/hbase/admin2_test.rb
b/hbase-shell/src/test/ruby/hbase/admin2_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/admin2_test.rb
rename to hbase-shell/src/test/ruby/hbase/admin2_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/balancer_utils_test.rb
b/hbase-shell/src/test/ruby/hbase/balancer_utils_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/balancer_utils_test.rb
rename to hbase-shell/src/test/ruby/hbase/balancer_utils_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb
b/hbase-shell/src/test/ruby/hbase/connection_test_no_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb
rename to hbase-shell/src/test/ruby/hbase/connection_test_no_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/hbase_test.rb
b/hbase-shell/src/test/ruby/hbase/hbase_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/hbase_test.rb
rename to hbase-shell/src/test/ruby/hbase/hbase_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/security_admin_test.rb
b/hbase-shell/src/test/ruby/hbase/security_admin_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/security_admin_test.rb
rename to hbase-shell/src/test/ruby/hbase/security_admin_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb
b/hbase-shell/src/test/ruby/hbase/taskmonitor_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb
rename to hbase-shell/src/test/ruby/hbase/taskmonitor_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb
rename to
hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb
b/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb
deleted file mode 100644
index 0d2f1901438..00000000000
--- a/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'rubygems'
-require 'rake'
-require 'set'
-
-
-# This runner will only launch shell tests that don't require a HBase cluster
running.
-
-unless defined?($TEST_CLUSTER)
- include Java
-
- # Set logging level to avoid verboseness
- log_level = 'OFF'
- org.apache.hadoop.hbase.logging.Log4jUtils.setRootLevel(log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.zookeeper',
log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.hadoop.hdfs',
log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.hadoop.hbase',
log_level)
- org.apache.hadoop.hbase.logging.Log4jUtils
- .setAllLevels('org.apache.hadoop.ipc.HBaseServer', log_level)
-
- java_import org.apache.hadoop.hbase.HBaseTestingUtility
-
- $TEST_CLUSTER = HBaseTestingUtility.new
- $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100)
- $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250)
-
$TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER,
6)
-end
-
-require 'test_helper'
-
-puts "Running tests without a cluster..."
-
-if java.lang.System.get_property('shell.test.include')
- includes =
Set.new(java.lang.System.get_property('shell.test.include').split(','))
-end
-
-if java.lang.System.get_property('shell.test.exclude')
- excludes =
Set.new(java.lang.System.get_property('shell.test.exclude').split(','))
-end
-
-files = Dir[ File.dirname(__FILE__) + "/**/*_no_cluster.rb" ]
-files.each do |file|
- filename = File.basename(file)
- if includes != nil && !includes.include?(filename)
- puts "Skip #{filename} because of not included"
- next
- end
- if excludes != nil && excludes.include?(filename)
- puts "Skip #{filename} because of excluded"
- next
- end
- begin
- load(file)
- rescue => e
- puts "ERROR: #{e}"
- raise
- end
-end
-
-# If this system property is set, we'll use it to filter the test cases.
-runner_args = []
-if java.lang.System.get_property('shell.test')
- shell_test_pattern = java.lang.System.get_property('shell.test')
- puts "Only running tests that match #{shell_test_pattern}"
- runner_args << "--testcase=#{shell_test_pattern}"
-end
-# first couple of args are to match the defaults, so we can pass options to
limit the tests run
-if !(Test::Unit::AutoRunner.run(false, nil, runner_args))
- raise "Shell unit tests failed. Check output file for details."
-end
-
-puts "Done with tests! Shutting down the cluster..."
-if @own_cluster
- $TEST_CLUSTER.shutdownMiniCluster
- java.lang.System.exit(0)
-end
diff --git a/hbase-shell/src/test/ruby/shell/commands_test.rb
b/hbase-shell/src/test/ruby/shell/commands_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/commands_test.rb
rename to hbase-shell/src/test/ruby/shell/commands_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/converter_test.rb
b/hbase-shell/src/test/ruby/shell/converter_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/converter_test.rb
rename to hbase-shell/src/test/ruby/shell/converter_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/formatter_test.rb
b/hbase-shell/src/test/ruby/shell/formatter_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/formatter_test.rb
rename to hbase-shell/src/test/ruby/shell/formatter_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/shell_test.rb
b/hbase-shell/src/test/ruby/shell/general_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/shell_test.rb
rename to hbase-shell/src/test/ruby/shell/general_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/list_locks_test.rb
b/hbase-shell/src/test/ruby/shell/list_locks_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/list_locks_test.rb
rename to hbase-shell/src/test/ruby/shell/list_locks_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/list_procedures_test.rb
b/hbase-shell/src/test/ruby/shell/list_procedures_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/list_procedures_test.rb
rename to hbase-shell/src/test/ruby/shell/list_procedures_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/noninteractive_test.rb
b/hbase-shell/src/test/ruby/shell/noninteractive_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/noninteractive_test.rb
rename to hbase-shell/src/test/ruby/shell/noninteractive_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/shell/sftchange_shell_test.rb
b/hbase-shell/src/test/ruby/shell/sftchange_test_cluster.rb
similarity index 100%
rename from hbase-shell/src/test/ruby/shell/sftchange_shell_test.rb
rename to hbase-shell/src/test/ruby/shell/sftchange_test_cluster.rb
diff --git a/hbase-shell/src/test/ruby/tests_runner.rb
b/hbase-shell/src/test/ruby/tests_runner.rb
index e05d11117e5..4e31b81535a 100644
--- a/hbase-shell/src/test/ruby/tests_runner.rb
+++ b/hbase-shell/src/test/ruby/tests_runner.rb
@@ -23,34 +23,13 @@ require 'set'
puts "Ruby description: #{RUBY_DESCRIPTION}"
-unless defined?($TEST_CLUSTER)
- include Java
-
- # Set logging level to avoid verboseness
- log_level = 'OFF'
- org.apache.hadoop.hbase.logging.Log4jUtils.setRootLevel(log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.zookeeper',
log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.hadoop.hdfs',
log_level)
-
org.apache.hadoop.hbase.logging.Log4jUtils.setAllLevels('org.apache.hadoop.hbase',
log_level)
- org.apache.hadoop.hbase.logging.Log4jUtils
- .setAllLevels('org.apache.hadoop.ipc.HBaseServer', log_level)
+require 'test_helper'
- java_import org.apache.hadoop.hbase.HBaseTestingUtility
+test_suite_name = java.lang.System.get_property('shell.test.suite_name')
- $TEST_CLUSTER = HBaseTestingUtility.new
- $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100)
- $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250)
- $TEST_CLUSTER.configuration.set("hbase.quota.enabled", "true")
- $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.period',
5000)
- $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.delay',
5000)
-
$TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER,
6)
- $TEST_CLUSTER.startMiniCluster
- @own_cluster = true
-end
+test_suite_pattern = java.lang.System.get_property('shell.test.suite_pattern')
-require 'test_helper'
-
-puts "Running tests..."
+puts "Running tests for #{test_suite_name} with pattern: #{test_suite_pattern}
..."
if java.lang.System.get_property('shell.test.include')
includes =
Set.new(java.lang.System.get_property('shell.test.include').split(','))
@@ -60,7 +39,7 @@ if java.lang.System.get_property('shell.test.exclude')
excludes =
Set.new(java.lang.System.get_property('shell.test.exclude').split(','))
end
-files = Dir[ File.dirname(__FILE__) + "/**/*_test.rb" ]
+files = Dir[ File.dirname(__FILE__) + "/" + test_suite_pattern ]
files.each do |file|
filename = File.basename(file)
if includes != nil && !includes.include?(filename)
@@ -96,9 +75,3 @@ rescue SystemExit => e
# Unit tests should not raise uncaught SystemExit exceptions. This could
cause tests to be ignored.
raise 'Caught SystemExit during unit test execution! Check output file for
details.'
end
-
-puts "Done with tests! Shutting down the cluster..."
-if @own_cluster
- $TEST_CLUSTER.shutdownMiniCluster
- java.lang.System.exit(0)
-end