Skip to content

Commit

Permalink
Fixed flaky test, fixed thirdparty import
Browse files Browse the repository at this point in the history
  • Loading branch information
craigcondit committed Dec 4, 2020
1 parent c53b4ce commit 24f004b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.runc.squashfs.directory;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.runc.squashfs.inode.INodeType;
import org.apache.hadoop.runc.squashfs.metadata.MetadataWriter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,11 @@ public void archiveWithFileContainingFullBlockShouldWork() throws Exception {
Random r = new Random(0L);
r.nextBytes(content);

long modified = System.currentTimeMillis();

try (SquashFsWriter writer = new SquashFsWriter(archive)) {
SquashFsEntry entry = writer.entry("/full.dat")
.lastModified(Instant.now())
.lastModified(Instant.ofEpochMilli(modified))
.uid(1000)
.gid(2000)
.content(new ByteArrayInputStream(content))
Expand All @@ -428,8 +430,8 @@ public void archiveWithFileContainingFullBlockShouldWork() throws Exception {
assertEquals("wrong gid", (short) 2, entry.getGid());
assertEquals("wrong nlink count", 1, entry.getNlink());
assertEquals("wrong file size", 131072L, entry.getFileSize());
assertEquals("wrong last modified", System.currentTimeMillis(),
entry.getLastModified() * 1000L, 10000L);
assertEquals("wrong last modified",
modified, entry.getLastModified() * 1000L, 10000L);
assertEquals("wrong data block count", 1, entry.getDataBlocks().size());
assertNull("fragment found", entry.getFragment());
}
Expand Down Expand Up @@ -1003,6 +1005,8 @@ public void fileWithNoFileSizeShouldFail() throws Exception {
public void fileWithNoTimestampShouldUseDefault() throws Exception {
File archive = temp.newFile();

long timestamp = System.currentTimeMillis();

try (SquashFsWriter writer = new SquashFsWriter(archive)) {
SquashFsEntry entry = writer.entry("/no-timestamp.dat")
.uid(0)
Expand All @@ -1011,8 +1015,10 @@ public void fileWithNoTimestampShouldUseDefault() throws Exception {
.permissions((short) 0644)
.build();

assertEquals("wrong timestamp", System.currentTimeMillis(),
entry.getLastModified() * 1000L, 10000L);
long actualTimestamp = entry.getLastModified() * 1000L;

assertEquals("wrong timestamp", (double) timestamp,
(double) (entry.getLastModified() * 1000d), 60_000d);
}
}

Expand Down

0 comments on commit 24f004b

Please sign in to comment.