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 org.apache.hadoop.conf.Configuration; 021import org.apache.hadoop.fs.FileSystem; 022import org.apache.hadoop.fs.Path; 023import org.junit.jupiter.api.TestTemplate; 024 025public class ExportSnapshotRetryTestBase extends ExportSnapshotTestBase { 026 027 protected ExportSnapshotRetryTestBase(boolean mob) { 028 super(mob); 029 } 030 031 /** 032 * Check that ExportSnapshot will succeed if something fails but the retry succeed. 033 */ 034 @TestTemplate 035 public void testExportRetry() throws Exception { 036 Path copyDir = TestExportSnapshotMisc.getLocalDestinationDir(TEST_UTIL); 037 Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); 038 conf.setBoolean(ExportSnapshot.Testing.CONF_TEST_FAILURE, true); 039 conf.setInt(ExportSnapshot.Testing.CONF_TEST_FAILURE_COUNT, 2); 040 conf.setInt("mapreduce.map.maxattempts", 3); 041 testExportFileSystemState(conf, tableName, snapshotName, snapshotName, tableNumFiles, 042 TEST_UTIL.getDefaultRootDirPath(), copyDir, true, false, getBypassRegionPredicate(), true, 043 false); 044 } 045 046 /** 047 * Check that ExportSnapshot will fail if we inject failure more times than MR will retry. 048 */ 049 @TestTemplate 050 public void testExportFailure() throws Exception { 051 Path copyDir = TestExportSnapshotMisc.getLocalDestinationDir(TEST_UTIL); 052 FileSystem fs = FileSystem.get(copyDir.toUri(), new Configuration()); 053 copyDir = copyDir.makeQualified(fs.getUri(), fs.getWorkingDirectory()); 054 Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); 055 conf.setBoolean(ExportSnapshot.Testing.CONF_TEST_FAILURE, true); 056 conf.setInt(ExportSnapshot.Testing.CONF_TEST_FAILURE_COUNT, 4); 057 conf.setInt("mapreduce.map.maxattempts", 3); 058 testExportFileSystemState(conf, tableName, snapshotName, snapshotName, tableNumFiles, 059 TEST_UTIL.getDefaultRootDirPath(), copyDir, true, false, getBypassRegionPredicate(), false, 060 false); 061 } 062}