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.util; 019 020import static org.junit.jupiter.api.Assertions.assertNotNull; 021 022import java.io.IOException; 023import org.apache.hadoop.conf.Configuration; 024import org.apache.hadoop.fs.Path; 025import org.apache.hadoop.hbase.TableName; 026import org.apache.hadoop.hbase.client.RegionInfo; 027import org.apache.hadoop.hbase.client.RegionInfoBuilder; 028import org.apache.hadoop.hbase.testclassification.MiscTests; 029import org.apache.hadoop.hbase.testclassification.SmallTests; 030import org.junit.jupiter.api.Tag; 031import org.junit.jupiter.api.Test; 032import org.junit.jupiter.api.TestInfo; 033 034/** 035 * Test that the utility works as expected 036 */ 037@Tag(MiscTests.TAG) 038@Tag(SmallTests.TAG) 039public class TestHFileArchiveUtil { 040 041 private Path rootDir = new Path("./"); 042 043 @Test 044 public void testGetTableArchivePath(TestInfo testInfo) { 045 assertNotNull(HFileArchiveUtil.getTableArchivePath(rootDir, 046 TableName.valueOf(testInfo.getTestMethod().get().getName()))); 047 } 048 049 @Test 050 public void testGetArchivePath() throws Exception { 051 Configuration conf = new Configuration(); 052 CommonFSUtils.setRootDir(conf, new Path("root")); 053 assertNotNull(HFileArchiveUtil.getArchivePath(conf)); 054 } 055 056 @Test 057 public void testRegionArchiveDir(TestInfo testInfo) { 058 Path regionDir = new Path("region"); 059 assertNotNull(HFileArchiveUtil.getRegionArchiveDir(rootDir, 060 TableName.valueOf(testInfo.getTestMethod().get().getName()), regionDir)); 061 } 062 063 @Test 064 public void testGetStoreArchivePath(TestInfo testInfo) throws IOException { 065 byte[] family = Bytes.toBytes("Family"); 066 Path tabledir = CommonFSUtils.getTableDir(rootDir, 067 TableName.valueOf(testInfo.getTestMethod().get().getName())); 068 RegionInfo region = RegionInfoBuilder 069 .newBuilder(TableName.valueOf(testInfo.getTestMethod().get().getName())).build(); 070 Configuration conf = new Configuration(); 071 CommonFSUtils.setRootDir(conf, new Path("root")); 072 assertNotNull(HFileArchiveUtil.getStoreArchivePath(conf, region, tabledir, family)); 073 } 074}