private void testArchiveStoreFilesDifferentFileSystems(String walDir, String expectedBase,
    boolean archiveFileExists, boolean sourceFileExists, boolean archiveFileDifferentLength,
    ArchivingFunction<Configuration, FileSystem, RegionInfo, Path, byte[],
      Collection<HStoreFile>> archivingFunction)
    throws IOException {
    FileSystem mockedFileSystem = mock(FileSystem.class);
    Configuration conf = new Configuration(UTIL.getConfiguration());
    if (walDir != null) {
      conf.set(CommonFSUtils.HBASE_WAL_DIR, walDir);
    }
    when(mockedFileSystem.getScheme()).thenReturn("mockFS");
    when(mockedFileSystem.mkdirs(any())).thenReturn(true);
    HashMap<Path, Boolean> existsTracker = new HashMap<>();
    Path filePath = new Path("/mockDir/wals/mockFile");
    String expectedDir = expectedBase
      + "archive/data/default/mockTable/mocked-region-encoded-name/testfamily/mockFile";
    existsTracker.put(new Path(expectedDir), archiveFileExists);
    existsTracker.put(filePath, sourceFileExists);
    when(mockedFileSystem.exists(any()))
      .thenAnswer(invocation -> existsTracker.getOrDefault((Path) invocation.getArgument(0), true));
    FileStatus mockedStatus = mock(FileStatus.class);
    when(mockedStatus.getLen()).thenReturn(12L).thenReturn(archiveFileDifferentLength ? 34L : 12L);
    when(mockedFileSystem.getFileStatus(any())).thenReturn(mockedStatus);
    RegionInfo mockedRegion = mock(RegionInfo.class);
    TableName tableName = TableName.valueOf("mockTable");
    when(mockedRegion.getTable()).thenReturn(tableName);
    when(mockedRegion.getEncodedName()).thenReturn("mocked-region-encoded-name");
    Path tableDir = new Path("mockFS://mockDir/tabledir");
    byte[] family = Bytes.toBytes("testfamily");
    HStoreFile mockedFile = mock(HStoreFile.class);
    List<HStoreFile> list = new ArrayList<>();
    list.add(mockedFile);
    when(mockedFile.getPath()).thenReturn(filePath);
    when(mockedFileSystem.rename(any(), any())).thenReturn(true);
    archivingFunction.apply(conf, mockedFileSystem, mockedRegion, tableDir, family, list);

    if (sourceFileExists) {
      ArgumentCaptor<Path> srcPath = ArgumentCaptor.forClass(Path.class);
      ArgumentCaptor<Path> destPath = ArgumentCaptor.forClass(Path.class);
      if (archiveFileExists) {
        // Verify we renamed the archived file to sideline, and then renamed the source file.
        verify(mockedFileSystem, times(2)).rename(srcPath.capture(), destPath.capture());
        assertEquals(expectedDir, srcPath.getAllValues().get(0).toString());
        assertEquals(filePath, srcPath.getAllValues().get(1));
        assertEquals(expectedDir, destPath.getAllValues().get(1).toString());
      } else {
        // Verify we renamed the source file to the archived file.
        verify(mockedFileSystem, times(1)).rename(srcPath.capture(), destPath.capture());
        assertEquals(filePath, srcPath.getAllValues().get(0));
        assertEquals(expectedDir, destPath.getAllValues().get(0).toString());
      }
    } else {
      if (archiveFileExists) {
        // Verify we did not rename. No source file with a present archive file should be a no-op.
        verify(mockedFileSystem, never()).rename(any(), any());
      } else {
        fail("Unsupported test conditions: sourceFileExists and archiveFileExists both false.");
      }
    }
  }
Setup the config for the cluster
hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestHFileArchiving.java