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.snapshot; 019 020import static org.junit.Assert.assertTrue; 021 022import org.apache.hadoop.fs.FileSystem; 023import org.apache.hadoop.fs.LocalFileSystem; 024import org.apache.hadoop.fs.Path; 025import org.apache.hadoop.hbase.HBaseClassTestRule; 026import org.apache.hadoop.hbase.HBaseCommonTestingUtil; 027import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.SnapshotMock; 028import org.apache.hadoop.hbase.testclassification.MapReduceTests; 029import org.apache.hadoop.hbase.testclassification.MediumTests; 030import org.junit.Before; 031import org.junit.ClassRule; 032import org.junit.Test; 033import org.junit.experimental.categories.Category; 034import org.slf4j.Logger; 035import org.slf4j.LoggerFactory; 036 037/** 038 * Test Export Snapshot Tool; tests v2 snapshots. 039 * @see TestExportSnapshotV1NoCluster 040 */ 041@Category({ MapReduceTests.class, MediumTests.class }) 042public class TestExportSnapshotV2NoCluster { 043 @ClassRule 044 public static final HBaseClassTestRule CLASS_RULE = 045 HBaseClassTestRule.forClass(TestExportSnapshotV2NoCluster.class); 046 047 private static final Logger LOG = LoggerFactory.getLogger(TestExportSnapshotV2NoCluster.class); 048 049 private HBaseCommonTestingUtil testUtil = new HBaseCommonTestingUtil(); 050 private Path testDir; 051 private FileSystem fs; 052 053 @Before 054 public void before() throws Exception { 055 // Make sure testDir is on LocalFileSystem 056 this.fs = FileSystem.getLocal(this.testUtil.getConfiguration()); 057 this.testDir = TestExportSnapshotV1NoCluster.setup(this.fs, this.testUtil); 058 LOG.info("fs={}, testDir={}", this.fs, this.testDir); 059 assertTrue("FileSystem '" + fs + "' is not local", fs instanceof LocalFileSystem); 060 } 061 062 @Test 063 public void testSnapshotWithRefsExportFileSystemState() throws Exception { 064 final SnapshotMock snapshotMock = new SnapshotMock(testUtil.getConfiguration(), 065 testDir.getFileSystem(testUtil.getConfiguration()), testDir); 066 final SnapshotMock.SnapshotBuilder builder = 067 snapshotMock.createSnapshotV2("tableWithRefsV2", "tableWithRefsV2"); 068 TestExportSnapshotV1NoCluster.testSnapshotWithRefsExportFileSystemState(this.fs, builder, 069 this.testUtil, this.testDir); 070 } 071}