1
0

[MINOR] Fix local flaky test in TestFSUtils (#4596)

Co-authored-by: Raymond Xu <2701446+xushiyan@users.noreply.github.com>
This commit is contained in:
Y Ethan Guo
2022-01-13 22:48:57 -08:00
committed by GitHub
parent 5ce45c440b
commit 7d163ee3de

View File

@@ -37,10 +37,10 @@ import org.apache.hadoop.fs.Path;
import org.junit.Rule; import org.junit.Rule;
import org.junit.contrib.java.lang.system.EnvironmentVariables; import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@@ -77,6 +77,7 @@ public class TestFSUtils extends HoodieCommonTestHarness {
@BeforeEach @BeforeEach
public void setUp() throws IOException { public void setUp() throws IOException {
initMetaClient(); initMetaClient();
basePath = "file:" + basePath;
} }
@Test @Test
@@ -312,7 +313,7 @@ public class TestFSUtils extends HoodieCommonTestHarness {
assertEquals(LOG_STR, FSUtils.getFileExtensionFromLog(new Path(logFileName))); assertEquals(LOG_STR, FSUtils.getFileExtensionFromLog(new Path(logFileName)));
// create three versions of log file // create three versions of log file
java.nio.file.Path partitionPath = Paths.get(basePath, partitionStr); java.nio.file.Path partitionPath = Paths.get(URI.create(basePath + "/" + partitionStr));
Files.createDirectories(partitionPath); Files.createDirectories(partitionPath);
String log1 = FSUtils.makeLogFileName(fileId, LOG_EXTENTION, instantTime, 1, writeToken); String log1 = FSUtils.makeLogFileName(fileId, LOG_EXTENTION, instantTime, 1, writeToken);
Files.createFile(partitionPath.resolve(log1)); Files.createFile(partitionPath.resolve(log1));
@@ -380,7 +381,6 @@ public class TestFSUtils extends HoodieCommonTestHarness {
new HoodieLocalEngineContext(metaClient.getHadoopConf()), fileSystem, new Path(rootDir), 2)); new HoodieLocalEngineContext(metaClient.getHadoopConf()), fileSystem, new Path(rootDir), 2));
} }
@Disabled
@Test @Test
public void testDeleteSubDirectoryRecursively() throws IOException { public void testDeleteSubDirectoryRecursively() throws IOException {
String rootDir = basePath + "/.hoodie/.temp"; String rootDir = basePath + "/.hoodie/.temp";
@@ -405,7 +405,6 @@ public class TestFSUtils extends HoodieCommonTestHarness {
subPathStr, new SerializableConfiguration(fileSystem.getConf()), false)); subPathStr, new SerializableConfiguration(fileSystem.getConf()), false));
} }
@Disabled
@Test @Test
public void testDeleteSubPathAsFile() throws IOException { public void testDeleteSubPathAsFile() throws IOException {
String rootDir = basePath + "/.hoodie/.temp"; String rootDir = basePath + "/.hoodie/.temp";
@@ -417,7 +416,6 @@ public class TestFSUtils extends HoodieCommonTestHarness {
subPathStr, new SerializableConfiguration(fileSystem.getConf()), false)); subPathStr, new SerializableConfiguration(fileSystem.getConf()), false));
} }
@Disabled
@Test @Test
public void testDeleteNonExistingSubDirectory() throws IOException { public void testDeleteNonExistingSubDirectory() throws IOException {
String rootDir = basePath + "/.hoodie/.temp"; String rootDir = basePath + "/.hoodie/.temp";
@@ -461,7 +459,6 @@ public class TestFSUtils extends HoodieCommonTestHarness {
} }
} }
@Disabled
@Test @Test
public void testGetFileStatusAtLevel() throws IOException { public void testGetFileStatusAtLevel() throws IOException {
String rootDir = basePath + "/.hoodie/.temp"; String rootDir = basePath + "/.hoodie/.temp";
@@ -470,12 +467,12 @@ public class TestFSUtils extends HoodieCommonTestHarness {
List<FileStatus> fileStatusList = FSUtils.getFileStatusAtLevel( List<FileStatus> fileStatusList = FSUtils.getFileStatusAtLevel(
new HoodieLocalEngineContext(fileSystem.getConf()), fileSystem, new HoodieLocalEngineContext(fileSystem.getConf()), fileSystem,
new Path(basePath), 3, 2); new Path(basePath), 3, 2);
assertEquals(CollectionUtils.createImmutableList( assertEquals(CollectionUtils.createImmutableSet(
"file:" + basePath + "/.hoodie/.temp/subdir1/file1.txt", basePath + "/.hoodie/.temp/subdir1/file1.txt",
"file:" + basePath + "/.hoodie/.temp/subdir2/file2.txt"), basePath + "/.hoodie/.temp/subdir2/file2.txt"),
fileStatusList.stream() fileStatusList.stream()
.map(fileStatus -> fileStatus.getPath().toString()) .map(fileStatus -> fileStatus.getPath().toString())
.filter(filePath -> filePath.endsWith(".txt")) .filter(filePath -> filePath.endsWith(".txt"))
.collect(Collectors.toList())); .collect(Collectors.toSet()));
} }
} }