-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-6338 [CORE] Use standard temp dir mechanisms in tests to avoid orphaned temp files #5029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
57609e4
9004081
4a212fa
27b740a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,6 @@ class UtilsSuite extends FunSuite with ResetSystemProperties { | |
|
|
||
| test("reading offset bytes of a file") { | ||
| val tmpDir2 = Utils.createTempDir() | ||
| tmpDir2.deleteOnExit() | ||
| val f1Path = tmpDir2 + "/f1" | ||
| val f1 = new FileOutputStream(f1Path) | ||
| f1.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n".getBytes(UTF_8)) | ||
|
|
@@ -151,7 +150,6 @@ class UtilsSuite extends FunSuite with ResetSystemProperties { | |
|
|
||
| test("reading offset bytes across multiple files") { | ||
| val tmpDir = Utils.createTempDir() | ||
| tmpDir.deleteOnExit() | ||
| val files = (1 to 3).map(i => new File(tmpDir, i.toString)) | ||
| Files.write("0123456789", files(0), UTF_8) | ||
| Files.write("abcdefghij", files(1), UTF_8) | ||
|
|
@@ -357,7 +355,8 @@ class UtilsSuite extends FunSuite with ResetSystemProperties { | |
| } | ||
|
|
||
| test("loading properties from file") { | ||
| val outFile = File.createTempFile("test-load-spark-properties", "test") | ||
| val tmpDir = Utils.createTempDir() | ||
| val outFile = File.createTempFile("test-load-spark-properties", "test", tmpDir) | ||
| try { | ||
| System.setProperty("spark.test.fileNameLoadB", "2") | ||
| Files.write("spark.test.fileNameLoadA true\n" + | ||
|
|
@@ -370,7 +369,7 @@ class UtilsSuite extends FunSuite with ResetSystemProperties { | |
| assert(sparkConf.getBoolean("spark.test.fileNameLoadA", false) === true) | ||
| assert(sparkConf.getInt("spark.test.fileNameLoadB", 1) === 2) | ||
| } finally { | ||
| outFile.delete() | ||
| Utils.deleteRecursively(tmpDir) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary now that we're using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is redundant now. |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,16 +25,15 @@ import scala.concurrent.duration._ | |
| import scala.language.postfixOps | ||
| import scala.util.Random | ||
|
|
||
| import com.google.common.io.Files | ||
| import kafka.serializer.StringDecoder | ||
| import kafka.utils.{ZKGroupTopicDirs, ZkUtils} | ||
| import org.apache.commons.io.FileUtils | ||
| import org.scalatest.BeforeAndAfter | ||
| import org.scalatest.concurrent.Eventually | ||
|
|
||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.storage.StorageLevel | ||
| import org.apache.spark.streaming.{Milliseconds, StreamingContext} | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| class ReliableKafkaStreamSuite extends KafkaStreamSuiteBase with BeforeAndAfter with Eventually { | ||
|
|
||
|
|
@@ -60,18 +59,15 @@ class ReliableKafkaStreamSuite extends KafkaStreamSuiteBase with BeforeAndAfter | |
| ) | ||
|
|
||
| ssc = new StreamingContext(sparkConf, Milliseconds(500)) | ||
| tempDirectory = Files.createTempDir() | ||
| tempDirectory = Utils.createTempDir() | ||
| ssc.checkpoint(tempDirectory.getAbsolutePath) | ||
| } | ||
|
|
||
| after { | ||
| if (ssc != null) { | ||
| ssc.stop() | ||
| } | ||
| if (tempDirectory != null && tempDirectory.exists()) { | ||
| FileUtils.deleteDirectory(tempDirectory) | ||
| tempDirectory = null | ||
| } | ||
| Utils.deleteRecursively(tempDirectory) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary now that we're using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is this. |
||
| tearDownKafka() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,11 @@ import java.io.File | |
|
|
||
| import org.scalatest.BeforeAndAfter | ||
|
|
||
| import com.google.common.io.Files | ||
|
|
||
| import org.apache.spark.sql.execution.QueryExecutionException | ||
| import org.apache.spark.sql.{QueryTest, _} | ||
| import org.apache.spark.sql.hive.test.TestHive | ||
| import org.apache.spark.sql.types._ | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| /* Implicits */ | ||
| import org.apache.spark.sql.hive.test.TestHive._ | ||
|
|
@@ -112,7 +111,7 @@ class InsertIntoHiveTableSuite extends QueryTest with BeforeAndAfter { | |
|
|
||
| test("SPARK-4203:random partition directory order") { | ||
| sql("CREATE TABLE tmp_table (key int, value string)") | ||
| val tmpDir = Files.createTempDir() | ||
| val tmpDir = Utils.createTempDir() | ||
| sql(s"CREATE TABLE table_with_partition(c1 string) PARTITIONED by (p1 string,p2 string,p3 string,p4 string,p5 string) location '${tmpDir.toURI.toString}' ") | ||
| sql("INSERT OVERWRITE TABLE table_with_partition partition (p1='a',p2='b',p3='c',p4='c',p5='1') SELECT 'blarr' FROM tmp_table") | ||
| sql("INSERT OVERWRITE TABLE table_with_partition partition (p1='a',p2='b',p3='c',p4='c',p5='2') SELECT 'blarr' FROM tmp_table") | ||
|
|
@@ -136,6 +135,7 @@ class InsertIntoHiveTableSuite extends QueryTest with BeforeAndAfter { | |
| assert(listFolders(tmpDir,List()).sortBy(_.toString()) == expected.sortBy(_.toString)) | ||
| sql("DROP TABLE table_with_partition") | ||
| sql("DROP TABLE tmp_table") | ||
| Utils.deleteRecursively(tmpDir) | ||
|
||
| } | ||
|
|
||
| test("Insert ArrayType.containsNull == false") { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're here, might as well fix this guy too.