17
17
18
18
package org .apache .spark .metrics
19
19
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 }
23
21
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 }
25
26
import org .apache .spark .SharedSparkContext
26
27
import 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
29
30
import org .scalatest .FunSuite
30
31
31
- import org .apache .hadoop .conf .Configuration
32
- import org .apache .hadoop .fs .{Path , FileSystem }
33
-
34
32
import scala .collection .mutable .ArrayBuffer
35
33
36
34
class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
@@ -69,6 +67,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
69
67
val bytesRead2 = runAndReturnBytesRead {
70
68
sc.textFile(tmpFilePath, 4 ).coalesce(2 ).count()
71
69
}
70
+ assert(bytesRead != 0 )
72
71
assert(bytesRead2 == bytesRead)
73
72
assert(bytesRead2 >= tmpFile.length())
74
73
}
@@ -86,7 +85,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
86
85
}
87
86
88
87
// for count and coelesce, the same bytes should be read.
89
- assert(bytesRead2 >= bytesRead2 )
88
+ assert(bytesRead2 >= bytesRead )
90
89
}
91
90
92
91
test(" input metrics for new Hadoop API with coalesce" ) {
@@ -98,6 +97,7 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext {
98
97
sc.newAPIHadoopFile(tmpFilePath, classOf [NewTextInputFormat ], classOf [LongWritable ],
99
98
classOf [Text ]).coalesce(5 ).count()
100
99
}
100
+ assert(bytesRead != 0 )
101
101
assert(bytesRead2 == bytesRead)
102
102
assert(bytesRead >= tmpFile.length())
103
103
}
0 commit comments