HBASE-24033 Add ut for loading the corrupt recovered hfiles (#1322)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / mob / TestMobCompactionRegularRegionBatchMode.java
blob819f095521934c4604fda4b50003e49fa366ad49
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase.mob;
20 import java.io.IOException;
22 import org.apache.hadoop.hbase.HBaseClassTestRule;
23 import org.apache.hadoop.hbase.client.Admin;
24 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
25 import org.apache.hadoop.hbase.client.TableDescriptor;
26 import org.apache.hadoop.hbase.testclassification.LargeTests;
27 import org.junit.Before;
28 import org.junit.ClassRule;
29 import org.junit.Test;
30 import org.junit.experimental.categories.Category;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 /**
35 * Mob file compaction chore in a regular batch mode test.
36 * 1. Enables batch mode for regular MOB compaction,
37 * Sets batch size to 7 regions.
38 * 2. Disables periodic MOB compactions, sets minimum age to archive to 10 sec
39 * 3. Creates MOB table with 20 regions
40 * 4. Loads MOB data (randomized keys, 1000 rows), flushes data.
41 * 5. Repeats 4. two more times
42 * 6. Verifies that we have 20 *3 = 60 mob files (equals to number of regions x 3)
43 * 7. Runs major MOB compaction.
44 * 8. Verifies that number of MOB files in a mob directory is 20 x4 = 80
45 * 9. Waits for a period of time larger than minimum age to archive
46 * 10. Runs Mob cleaner chore
47 * 11 Verifies that number of MOB files in a mob directory is 20.
48 * 12 Runs scanner and checks all 3 * 1000 rows.
50 @SuppressWarnings("deprecation")
51 @Category(LargeTests.class)
52 public class TestMobCompactionRegularRegionBatchMode extends TestMobCompactionBase{
53 private static final Logger LOG =
54 LoggerFactory.getLogger(TestMobCompactionRegularRegionBatchMode.class);
55 @ClassRule
56 public static final HBaseClassTestRule CLASS_RULE =
57 HBaseClassTestRule.forClass(TestMobCompactionRegularRegionBatchMode.class);
59 private int batchSize = 7;
60 private MobFileCompactionChore compactionChore;
62 public TestMobCompactionRegularRegionBatchMode() {
65 @Before
66 public void setUp() throws Exception {
67 super.setUp();
68 compactionChore = new MobFileCompactionChore(conf, batchSize);
71 protected void initConf() {
72 super.initConf();
73 conf.setInt(MobConstants.MOB_MAJOR_COMPACTION_REGION_BATCH_SIZE, batchSize);
76 @Override
77 protected void mobCompact(Admin admin, TableDescriptor tableDescriptor,
78 ColumnFamilyDescriptor familyDescriptor) throws IOException, InterruptedException {
79 // Major compact with batch mode enabled
80 compactionChore.performMajorCompactionInBatches(admin, tableDescriptor, familyDescriptor);
83 @Test
84 public void testMobFileCompactionBatchMode() throws InterruptedException, IOException {
85 LOG.info("MOB compaction chore regular batch mode started");
86 baseTestMobFileCompaction();
87 LOG.info("MOB compaction chore regular batch mode finished OK");