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