Skip to content

Commit

Permalink
Fix the unit test in BasicWriteTaskStatsTrackerSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
c21 committed Jan 3, 2019
1 parent 5f43f57 commit 7c544ab
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class BasicWriteTaskStatsTrackerSuite extends SparkFunSuite {
val tracker = new BasicWriteTaskStatsTracker(conf)
tracker.newFile(file.toString)
val stream = localfs.create(file, true)

try {
assertStats(tracker, 1, 0)
stream.write(data1)
Expand All @@ -148,7 +149,7 @@ class BasicWriteTaskStatsTrackerSuite extends SparkFunSuite {
test("Three files, last one empty") {
val file1 = new Path(tempDirPath, "f-3-1")
val file2 = new Path(tempDirPath, "f-3-2")
val file3 = new Path(tempDirPath, "f-3-2")
val file3 = new Path(tempDirPath, "f-3-3")
val tracker = new BasicWriteTaskStatsTracker(conf)
tracker.newFile(file1.toString)
write1(file1)
Expand Down Expand Up @@ -180,6 +181,21 @@ class BasicWriteTaskStatsTrackerSuite extends SparkFunSuite {
assertStats(tracker, 2, len1 + len2)
}

test("Three files, one duplicated") {
val file1 = new Path(tempDirPath, "f-3-1")
val file2 = new Path(tempDirPath, "f-3-2")
val tracker = new BasicWriteTaskStatsTracker(conf)
tracker.newFile(file1.toString)
write1(file1)
tracker.newFile(file2.toString)
write2(file2)
// file 2 is noted again
tracker.newFile(file2.toString)
// the expected size is file1 + file2; only two files are reported
// as found
assertStats(tracker, 2, len1 + len2)
}

/**
* Write a 0-byte file.
* @param file file path
Expand Down

0 comments on commit 7c544ab

Please sign in to comment.