View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with this
4    * work for additional information regarding copyright ownership. The ASF
5    * licenses this file to you under the Apache License, Version 2.0 (the
6    * "License"); you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14   * License for the specific language governing permissions and limitations
15   * under the License.
16   */
17  package org.apache.hadoop.hbase.util;
18  
19  import static org.junit.Assert.assertEquals;
20  
21  import org.apache.hadoop.hbase.testclassification.LargeTests;
22  import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
23  import org.junit.Test;
24  import org.junit.experimental.categories.Category;
25  import org.junit.runner.RunWith;
26  import org.junit.runners.Parameterized;
27  
28  /**
29   * A write/read/verify load test on a mini HBase cluster. Tests reading
30   * and writing at the same time.
31   */
32  @Category(LargeTests.class)
33  @RunWith(Parameterized.class)
34  public class TestMiniClusterLoadParallel
35      extends TestMiniClusterLoadSequential {
36  
37    public TestMiniClusterLoadParallel(boolean isMultiPut,
38        DataBlockEncoding encoding) {
39      super(isMultiPut, encoding);
40    }
41  
42    @Test(timeout=TIMEOUT_MS)
43    public void loadTest() throws Exception {
44      prepareForLoadTest();
45  
46      readerThreads.linkToWriter(writerThreads);
47  
48      writerThreads.start(0, numKeys, NUM_THREADS);
49      readerThreads.start(0, numKeys, NUM_THREADS);
50  
51      writerThreads.waitForFinish();
52      readerThreads.waitForFinish();
53  
54      assertEquals(0, writerThreads.getNumWriteFailures());
55      assertEquals(0, readerThreads.getNumReadFailures());
56      assertEquals(0, readerThreads.getNumReadErrors());
57      assertEquals(numKeys, readerThreads.getNumUniqueKeysVerified());
58    }
59  
60  }