Skip to content

Commit 83648dd

Browse files
HDFS-17216. Distcp: When the getBytesPerSec logic is fixed, the adaptation adjusts the logic of the testRead test method.
1 parent 63c18fc commit 83648dd

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/util/TestThrottledInputStream.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,28 @@ private long copyAndAssert(File tmpFile, File outFile,
126126
}
127127

128128
LOG.info("{}", in);
129+
/*
130+
in.getBytesPerSec() should not be called repeatedly,
131+
because each call will return a different value,
132+
and because the program execution also takes time,
133+
which magnifies the error of getBytesPerSec()
134+
*/
129135
bandwidth = in.getBytesPerSec();
130136
Assert.assertEquals(in.getTotalBytesRead(), tmpFile.length());
131-
Assert.assertTrue(in.getBytesPerSec() > maxBandwidth / (factor * 1.2));
132-
Assert.assertTrue(in.getTotalSleepTime() > sleepTime || in.getBytesPerSec() <= maxBPS);
137+
138+
/*
139+
CB.ONE_C is copied using single byte, which will be very slow.
140+
When I fix the getBytesPerSec logic, and the author's original threshold in testRead
141+
does not match, besides this is a small file, the original logic will have overspeed.
142+
So for single-byte copy, the rate threshold should be adjusted
143+
so that it passes the test class.
144+
*/
145+
if (flag != CB.ONE_C) {
146+
Assert.assertTrue(bandwidth > maxBandwidth / (factor * 1.2));
147+
} else {
148+
Assert.assertTrue(bandwidth > maxBandwidth / (factor * 20));
149+
}
150+
Assert.assertTrue(in.getTotalSleepTime() > sleepTime || bandwidth <= maxBPS);
133151
} finally {
134152
IOUtils.closeStream(in);
135153
IOUtils.closeStream(out);

0 commit comments

Comments
 (0)