1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.procedure;
19
20 import static org.junit.Assert.assertArrayEquals;
21
22 import java.io.IOException;
23 import java.util.HashMap;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.hadoop.conf.Configuration;
28 import org.apache.hadoop.hbase.HBaseTestingUtility;
29 import org.apache.hadoop.hbase.testclassification.SmallTests;
30 import org.apache.hadoop.hbase.client.Admin;
31 import org.junit.AfterClass;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.junit.experimental.categories.Category;
35
36 @Category(SmallTests.class)
37 public class TestProcedureManager {
38
39 static final Log LOG = LogFactory.getLog(TestProcedureManager.class);
40 private static final int NUM_RS = 2;
41 private static HBaseTestingUtility util = new HBaseTestingUtility();
42
43 @BeforeClass
44 public static void setupBeforeClass() throws Exception {
45
46 Configuration conf = util.getConfiguration();
47
48 conf.set(ProcedureManagerHost.MASTER_PROCEUDRE_CONF_KEY,
49 SimpleMasterProcedureManager.class.getName());
50 conf.set(ProcedureManagerHost.REGIONSERVER_PROCEDURE_CONF_KEY,
51 SimpleRSProcedureManager.class.getName());
52
53 util.startMiniCluster(NUM_RS);
54 }
55
56 @AfterClass
57 public static void tearDownAfterClass() throws Exception {
58 util.shutdownMiniCluster();
59 }
60
61 @Test
62 public void testSimpleProcedureManager() throws IOException {
63 Admin admin = util.getHBaseAdmin();
64
65 byte[] result = admin.execProcedureWithRet(SimpleMasterProcedureManager.SIMPLE_SIGNATURE,
66 "mytest", new HashMap<String, String>());
67 assertArrayEquals("Incorrect return data from execProcedure",
68 SimpleMasterProcedureManager.SIMPLE_DATA.getBytes(), result);
69 }
70 }