1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.hadoop.hbase;
20
21 import java.io.IOException;
22
23 import junit.framework.Assert;
24
25 import org.apache.hadoop.hbase.util.Bytes;
26 import org.apache.hadoop.hbase.util.ChaosMonkey;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.experimental.categories.Category;
31
32 /**
33 * A system test which does large data ingestion and verify using {@link LoadTestTool},
34 * while killing the region servers and the master(s) randomly. You can configure how long
35 * should the load test run by using "hbase.IntegrationTestDataIngestWithChaosMonkey.runtime"
36 * configuration parameter.
37 */
38 @Category(IntegrationTests.class)
39 public class IntegrationTestDataIngestWithChaosMonkey extends IngestIntegrationTestBase {
40
41 private static final int NUM_SLAVES_BASE = 4; //number of slaves for the smallest cluster
42
43 // run for 5 min by default
44 private static final long DEFAULT_RUN_TIME = 5 * 60 * 1000;
45
46 private ChaosMonkey monkey;
47
48 @Before
49 public void setUp() throws Exception {
50 super.setUp(NUM_SLAVES_BASE);
51 monkey = new ChaosMonkey(util, ChaosMonkey.EVERY_MINUTE_RANDOM_ACTION_POLICY);
52 monkey.start();
53 }
54
55 @After
56 public void tearDown() throws Exception {
57 if (monkey != null) {
58 monkey.stop("test has finished, that's why");
59 monkey.waitForStop();
60 }
61 super.tearDown();
62 }
63
64 @Test
65 public void testDataIngest() throws Exception {
66 runIngestTest(DEFAULT_RUN_TIME, 2500, 10, 100, 20);
67 }
68 }