1717
1818package org .apache .spark .metrics
1919
20- import java .io .{FileWriter , PrintWriter , File }
21- import org .apache .hadoop .io .{Text , LongWritable }
22- import org .apache .hadoop .mapreduce .lib .input .{TextInputFormat => NewTextInputFormat }
20+ import java .io .{File , FileWriter , PrintWriter }
2321
24- import org .apache .spark .util .Utils
22+ import org .apache .hadoop .conf .Configuration
23+ import org .apache .hadoop .fs .{FileSystem , Path }
24+ import org .apache .hadoop .io .{LongWritable , Text }
25+ import org .apache .hadoop .mapreduce .lib .input .{TextInputFormat => NewTextInputFormat }
2526import org .apache .spark .SharedSparkContext
2627import org .apache .spark .deploy .SparkHadoopUtil
27- import org .apache .spark .scheduler .{SparkListenerTaskEnd , SparkListener }
28-
28+ import org .apache .spark .scheduler .{SparkListener , SparkListenerTaskEnd }
29+ import org . apache . spark . util . Utils
2930import org .scalatest .FunSuite
3031
31- import org .apache .hadoop .conf .Configuration
32- import org .apache .hadoop .fs .{Path , FileSystem }
33-
3432import scala .collection .mutable .ArrayBuffer
3533
3634class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
@@ -69,6 +67,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
6967 val bytesRead2 = runAndReturnBytesRead {
7068 sc.textFile(tmpFilePath, 4 ).coalesce(2 ).count()
7169 }
70+ assert(bytesRead != 0 )
7271 assert(bytesRead2 == bytesRead)
7372 assert(bytesRead2 >= tmpFile.length())
7473 }
@@ -86,7 +85,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
8685 }
8786
8887 // for count and coelesce, the same bytes should be read.
89- assert(bytesRead2 >= bytesRead2 )
88+ assert(bytesRead2 >= bytesRead )
9089 }
9190
9291 test(" input metrics for new Hadoop API with coalesce" ) {
@@ -98,6 +97,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
9897 sc.newAPIHadoopFile(tmpFilePath, classOf [NewTextInputFormat ], classOf [LongWritable ],
9998 classOf [Text ]).coalesce(5 ).count()
10099 }
100+ assert(bytesRead != 0 )
101101 assert(bytesRead2 == bytesRead)
102102 assert(bytesRead >= tmpFile.length())
103103 }
0 commit comments