001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.mapreduce;
019
020import java.io.IOException;
021import org.apache.hadoop.hbase.HBaseClassTestRule;
022import org.apache.hadoop.hbase.testclassification.LargeTests;
023import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
024import org.junit.ClassRule;
025import org.junit.Test;
026import org.junit.experimental.categories.Category;
027
028/**
029 * TestTableInputFormatScan part 1.
030 * @see TestTableInputFormatScanBase
031 */
032@Category({VerySlowMapReduceTests.class, LargeTests.class})
033public class TestTableInputFormatScan1 extends TestTableInputFormatScanBase {
034
035  @ClassRule
036  public static final HBaseClassTestRule CLASS_RULE =
037      HBaseClassTestRule.forClass(TestTableInputFormatScan1.class);
038
039  /**
040   * Tests a MR scan using specific start and stop rows.
041   *
042   * @throws IOException
043   * @throws ClassNotFoundException
044   * @throws InterruptedException
045   */
046  @Test
047  public void testScanEmptyToEmpty()
048  throws IOException, InterruptedException, ClassNotFoundException {
049    testScan(null, null, null);
050  }
051
052  /**
053   * Tests a MR scan using specific start and stop rows.
054   *
055   * @throws IOException
056   * @throws ClassNotFoundException
057   * @throws InterruptedException
058   */
059  @Test
060  public void testScanEmptyToAPP()
061  throws IOException, InterruptedException, ClassNotFoundException {
062    testScan(null, "app", "apo");
063  }
064
065  /**
066   * Tests a MR scan using specific start and stop rows.
067   *
068   * @throws IOException
069   * @throws ClassNotFoundException
070   * @throws InterruptedException
071   */
072  @Test
073  public void testScanEmptyToBBA()
074  throws IOException, InterruptedException, ClassNotFoundException {
075    testScan(null, "bba", "baz");
076  }
077
078  /**
079   * Tests a MR scan using specific start and stop rows.
080   *
081   * @throws IOException
082   * @throws ClassNotFoundException
083   * @throws InterruptedException
084   */
085  @Test
086  public void testScanEmptyToBBB()
087  throws IOException, InterruptedException, ClassNotFoundException {
088    testScan(null, "bbb", "bba");
089  }
090
091  /**
092   * Tests a MR scan using specific start and stop rows.
093   *
094   * @throws IOException
095   * @throws ClassNotFoundException
096   * @throws InterruptedException
097   */
098  @Test
099  public void testScanEmptyToOPP()
100  throws IOException, InterruptedException, ClassNotFoundException {
101    testScan(null, "opp", "opo");
102  }
103
104  /**
105   * Tests a MR scan using specific number of mappers. The test table has 26 regions,
106   *
107   * @throws IOException
108   * @throws ClassNotFoundException
109   * @throws InterruptedException
110   */
111  @Test
112    public void testGetSplits() throws IOException, InterruptedException, ClassNotFoundException {
113      testNumOfSplits(1, 26);
114      testNumOfSplits(3, 78);
115    }
116
117  /**
118   * Runs a MR to test TIF using specific number of mappers. The test table has 26 regions,
119   * @throws InterruptedException
120   * @throws IOException
121   * @throws ClassNotFoundException
122   */
123  @Test
124  public void testSpecifiedNumOfMappersMR()
125      throws InterruptedException, IOException, ClassNotFoundException {
126    testNumOfSplitsMR(2, 52);
127    testNumOfSplitsMR(4, 104);
128  }
129
130  /**
131   * Test if autoBalance create correct splits
132   * @throws IOException
133   */
134  @Test
135  public void testAutoBalanceSplits() throws IOException {
136    testAutobalanceNumOfSplit();
137  }
138
139}