1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.mapreduce;
20
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assume.assumeTrue;
23
24 import org.apache.hadoop.conf.Configurable;
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.HBaseConfiguration;
27 import org.apache.hadoop.hbase.IntegrationTestingUtility;
28 import org.apache.hadoop.hbase.testclassification.IntegrationTests;
29 import org.apache.hadoop.mapreduce.Job;
30 import org.apache.hadoop.util.Tool;
31 import org.apache.hadoop.util.ToolRunner;
32 import org.junit.Before;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.junit.experimental.categories.Category;
36
37
38
39
40
41 @Category(IntegrationTests.class)
42 public class IntegrationTestTableMapReduceUtil implements Configurable, Tool {
43
44 private static IntegrationTestingUtility util;
45
46 @BeforeClass
47 public static void provisionCluster() throws Exception {
48 if (null == util) {
49 util = new IntegrationTestingUtility();
50 }
51 }
52
53 @Before
54 public void skipMiniCluster() {
55
56
57 assumeTrue("test requires a distributed cluster.", util.isDistributedCluster());
58 }
59
60
61
62
63 @Test
64 public void testAddDependencyJars() throws Exception {
65 Job job = new Job();
66 TableMapReduceUtil.addDependencyJars(job);
67 String tmpjars = job.getConfiguration().get("tmpjars");
68
69
70 assertTrue(tmpjars.contains("hbase-common"));
71 assertTrue(tmpjars.contains("hbase-protocol"));
72 assertTrue(tmpjars.contains("hbase-client"));
73 assertTrue(tmpjars.contains("hbase-hadoop-compat"));
74 assertTrue(tmpjars.contains("hbase-server"));
75
76
77 assertTrue(tmpjars.contains("zookeeper"));
78 assertTrue(tmpjars.contains("netty"));
79 assertTrue(tmpjars.contains("protobuf"));
80 assertTrue(tmpjars.contains("guava"));
81 assertTrue(tmpjars.contains("htrace"));
82 }
83
84 @Override
85 public int run(String[] args) throws Exception {
86 provisionCluster();
87 skipMiniCluster();
88 testAddDependencyJars();
89 return 0;
90 }
91
92 public void setConf(Configuration conf) {
93 if (util != null) {
94 throw new IllegalArgumentException(
95 "setConf not supported after the test has been initialized.");
96 }
97 util = new IntegrationTestingUtility(conf);
98 }
99
100 @Override
101 public Configuration getConf() {
102 return util.getConfiguration();
103 }
104
105 public static void main(String[] args) throws Exception {
106 Configuration conf = HBaseConfiguration.create();
107 IntegrationTestingUtility.setUseDistributedCluster(conf);
108 int status = ToolRunner.run(conf, new IntegrationTestTableMapReduceUtil(), args);
109 System.exit(status);
110 }
111 }