1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.client.rsgroup;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.apache.hadoop.hbase.HBaseTestingUtility;
24 import org.apache.hadoop.hbase.HConstants;
25 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
26 import org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint;
27 import org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer;
28 import org.apache.hadoop.hbase.security.access.SecureTestUtil;
29 import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
30 import org.apache.hadoop.hbase.testclassification.LargeTests;
31 import org.jruby.embed.PathType;
32 import org.jruby.embed.ScriptingContainer;
33 import org.junit.AfterClass;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.junit.experimental.categories.Category;
37
38 import java.io.IOException;
39 import java.util.ArrayList;
40 import java.util.List;
41
42
43
44 @Category({LargeTests.class})
45 public class TestShellRSGroups {
46 final Log LOG = LogFactory.getLog(getClass());
47 private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
48 private final static ScriptingContainer jruby = new ScriptingContainer();
49 private static String basePath;
50
51 @BeforeClass
52 public static void setUpBeforeClass() throws Exception {
53 basePath = System.getProperty("basedir");
54
55
56 TEST_UTIL.getConfiguration().setBoolean("hbase.online.schema.update.enable", true);
57 TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
58 TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
59 TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
60 TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
61 TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
62 TEST_UTIL.getConfiguration().setInt(HConstants.MASTER_INFO_PORT, -1);
63 TEST_UTIL.getConfiguration().setInt(HConstants.REGIONSERVER_INFO_PORT, -1);
64
65 SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());
66 VisibilityTestUtil.enableVisiblityLabels(TEST_UTIL.getConfiguration());
67
68
69 TEST_UTIL.getConfiguration().set(
70 HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
71 RSGroupBasedLoadBalancer.class.getName());
72 TEST_UTIL.getConfiguration().set(
73 CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
74 RSGroupAdminEndpoint.class.getName());
75 TEST_UTIL.getConfiguration().setBoolean(
76 HConstants.ZOOKEEPER_USEMULTI,
77 true);
78
79 TEST_UTIL.startMiniCluster(1,4);
80
81
82 List<String> loadPaths = new ArrayList();
83 loadPaths.add(basePath+"/src/main/ruby");
84 loadPaths.add(basePath+"/src/test/ruby");
85 jruby.getProvider().setLoadPaths(loadPaths);
86 jruby.put("$TEST_CLUSTER", TEST_UTIL);
87 System.setProperty("jruby.jit.logging.verbose", "true");
88 System.setProperty("jruby.jit.logging", "true");
89 System.setProperty("jruby.native.verbose", "true");
90 }
91
92 @AfterClass
93 public static void tearDownAfterClass() throws Exception {
94 TEST_UTIL.shutdownMiniCluster();
95 }
96
97 @Test
98 public void testRunShellTests() throws IOException {
99 try {
100
101 System.setProperty("shell.test", "Hbase::RSGroupShellTest");
102 jruby.runScriptlet(PathType.ABSOLUTE,
103 basePath + "/src/test/ruby/tests_runner.rb");
104 } finally {
105 System.clearProperty("shell.test");
106 }
107 }
108
109 }
110