File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
core/src/test/scala/org/apache/spark Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,35 @@ class SparkContextSuite extends FunSuite with LocalSparkContext {
106
106
sc.stop()
107
107
}
108
108
}
109
+
110
+ test(" addFile works with relative path" ) {
111
+ val pluto = Utils .createTempDir()
112
+ val file = File .createTempFile(" someprefix" , " somesuffix" , pluto)
113
+ val relativePath = file.getParent + " /../" + file.getParentFile.getName + " /" + file.getName
114
+ val absolutePath = file.getAbsolutePath
115
+ try {
116
+ Files .write(" somewords" , file, UTF_8 )
117
+ val length = file.length()
118
+ sc = new SparkContext (new SparkConf ().setAppName(" test" ).setMaster(" local" ))
119
+ sc.addFile(relativePath)
120
+ sc.parallelize(Array (1 ), 1 ).map(x => {
121
+ val gotten = new File (SparkFiles .get(file.getName))
122
+ if (! gotten.exists()) {
123
+ throw new SparkException (" file doesn't exist" )
124
+ }
125
+ if (length != gotten.length()) {
126
+ throw new SparkException (
127
+ s " file has different length $length than added file ${gotten.length()}" )
128
+ }
129
+ if (absolutePath == gotten.getAbsolutePath) {
130
+ throw new SparkException (" file should have been copied" )
131
+ }
132
+ x
133
+ }).count()
134
+ } finally {
135
+ sc.stop()
136
+ }
137
+ }
109
138
110
139
test(" addFile recursive works" ) {
111
140
val pluto = Utils .createTempDir()
You can’t perform that action at this time.
0 commit comments