View Javadoc

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  package org.apache.hadoop.hbase.snapshot;
19  
20  import java.io.IOException;
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.hadoop.conf.Configuration;
25  import org.apache.hadoop.hbase.HBaseTestingUtility;
26  import org.apache.hadoop.hbase.TableName;
27  import org.apache.hadoop.hbase.client.Table;
28  import org.apache.hadoop.hbase.mob.MobConstants;
29  import org.apache.hadoop.hbase.testclassification.LargeTests;
30  import org.junit.BeforeClass;
31  import org.junit.experimental.categories.Category;
32  
33  /**
34   * Test clone/restore snapshots from the client
35   *
36   * TODO This is essentially a clone of TestRestoreSnapshotFromClient.  This is worth refactoring
37   * this because there will be a few more flavors of snapshots that need to run these tests.
38   */
39  @Category({LargeTests.class})
40  public class TestMobRestoreFlushSnapshotFromClient extends TestRestoreFlushSnapshotFromClient {
41    final Log LOG = LogFactory.getLog(getClass());
42  
43    @BeforeClass
44    public static void setupCluster() throws Exception {
45      setupConf(UTIL.getConfiguration());
46      UTIL.startMiniCluster(3);
47    }
48  
49    protected static void setupConf(Configuration conf) {
50      TestRestoreFlushSnapshotFromClient.setupConf(conf);
51      UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 0);
52    }
53  
54    @Override
55    protected void createTable() throws Exception {
56      MobSnapshotTestingUtils.createMobTable(UTIL, tableName, 1, FAMILY);
57    }
58  
59    @Override
60    protected void verifyRowCount(final HBaseTestingUtility util, final TableName tableName,
61        long expectedRows) throws IOException {
62      MobSnapshotTestingUtils.verifyMobRowCount(util, tableName, expectedRows);
63    }
64  
65    @Override
66    protected int countRows(final Table table, final byte[]... families) throws IOException {
67      return MobSnapshotTestingUtils.countMobRows(table, families);
68    }
69  }