HDFS-15898. Test case TestOfflineImageViewer fails (#2779)

This commit is contained in:
Hui Fei 2021-03-17 09:11:30 +08:00 committed by GitHub
parent f276f1af80
commit 0d42104119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -74,6 +74,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -153,6 +154,7 @@ public class TestOfflineImageViewer {
private static final long FILE_NODE_ID_3 = 16394;
private static final long DIR_NODE_ID = 16391;
private static final long SAMPLE_TIMESTAMP = 946684800000L;
private static TimeZone defaultTimeZone = null;
// namespace as written to dfs, to be compared with viewer's output
final static HashMap<String, FileStatus> writtenFiles = Maps.newHashMap();
@ -165,6 +167,8 @@ public class TestOfflineImageViewer {
// multiple tests.
@BeforeClass
public static void createOriginalFSImage() throws IOException {
defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
File[] nnDirs = MiniDFSCluster.getNameNodeDirectory(
MiniDFSCluster.getBaseDirectory(), 0, 0);
tempDir = nnDirs[0];
@ -370,6 +374,9 @@ public class TestOfflineImageViewer {
if (originalFsimage != null && originalFsimage.exists()) {
originalFsimage.delete();
}
if (defaultTimeZone != null) {
TimeZone.setDefault(defaultTimeZone);
}
}
// Convenience method to generate a file status from file system for