1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.test;
20
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.hbase.HBaseConfiguration;
23 import org.apache.hadoop.hbase.IntegrationTestingUtility;
24 import org.apache.hadoop.hbase.chaos.util.ChaosMonkeyRunner;
25 import org.apache.hadoop.hbase.chaos.util.Monkeys;
26 import org.apache.hadoop.hbase.testclassification.IntegrationTests;
27 import org.apache.hadoop.util.ToolRunner;
28 import org.junit.Test;
29 import org.junit.experimental.categories.Category;
30
31
32
33
34
35 @Category(IntegrationTests.class)
36 public class IntegrationTestMonkeys extends ChaosMonkeyRunner {
37 private static final int RUN_SECS = 15 * 1000;
38 private static final int WAIT_SECS = 10 * 1000;
39
40 @Override
41 protected int doWork() throws Exception {
42 super.setUpCluster();
43 runMonkeys();
44 return 0;
45 }
46
47 @Test
48 public void runMonkeys() throws Exception {
49 try (Monkeys monkeys = new Monkeys()) {
50 for (int i = 0; i < 2; i++) {
51 monkeys.startChaos();
52 Thread.sleep(RUN_SECS);
53 monkeys.stopChaos();
54 Thread.sleep(WAIT_SECS);
55 }
56 }
57 }
58
59 public static void main(String[] args) throws Exception {
60
61
62 Configuration conf = HBaseConfiguration.create();
63 IntegrationTestingUtility.setUseDistributedCluster(conf);
64 int exitCode = ToolRunner.run(conf, new IntegrationTestMonkeys(), args);
65 System.exit(exitCode);
66 }
67 }