Skip to content

Commit

Permalink
Add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
maobaolong committed Dec 22, 2023
1 parent ae3a997 commit e8dc5dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ private void updateStream() throws IOException {
mBlockInStream.seek(offset);
}

private boolean isStatusOutdated() {
@VisibleForTesting
public boolean isStatusOutdated() {
return System.currentTimeMillis() > mStatusOutdatedTime;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import alluxio.wire.WorkerNetAddress;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -958,4 +959,17 @@ private void testReadBuffer(int dataRead) throws Exception {
private void validatePartialCaching(int index, int readSize) {
assertEquals(readSize, mInStreams.get(index).getBytesRead());
}

@Test
public void testStatusOutdated() throws IOException {
OpenFilePOptions options =
OpenFilePOptions.newBuilder().setReadType(ReadPType.CACHE_PROMOTE).build();
mTestStream = new AlluxioFileInStream(mStatus, new InStreamOptions(mStatus, options, mConf,
mContext), mContext);
Assert.assertFalse(mTestStream.isStatusOutdated());
mConf.set(PropertyKey.USER_FILE_IN_STREAM_STATUS_EXPIRATION_TIME, 0L);
mTestStream = new AlluxioFileInStream(mStatus, new InStreamOptions(mStatus, options, mConf,
mContext), mContext);
Assert.assertTrue(mTestStream.isStatusOutdated());
}
}

0 comments on commit e8dc5dc

Please sign in to comment.