jiangxb1987 commented on a change in pull request #26916: 
[SPARK-25100][TEST][FOLLOWUP] Refactor test cases in `FileSuite` and 
`KryoSerializerSuite`
URL: https://github.com/apache/spark/pull/26916#discussion_r358569006
 
 

 ##########
 File path: core/src/test/scala/org/apache/spark/FileSuite.scala
 ##########
 @@ -702,32 +702,39 @@ class FileSuite extends SparkFunSuite with 
LocalSparkContext {
     assert(collectRDDAndDeleteFileBeforeCompute(true).isEmpty)
   }
 
-  test("SPARK-25100: Using KryoSerializer and" +
-      "setting registrationRequired true can lead job failed") {
-    val inputFile = new File(tempDir, "/input").getAbsolutePath
-    val textFileOutputDir = new File(tempDir, "/out1").getAbsolutePath
-    val dataSetDir = new File(tempDir, "/out2").getAbsolutePath
-
-    Utils.tryWithResource(new PrintWriter(new File(inputFile))) { writer =>
-      for (i <- 1 to 100) {
+  test("SPARK-25100: Support commit tasks when Kyro registration is required") 
{
+    // Prepare the input file
+    val inputFilePath = new File(tempDir, "/input").getAbsolutePath
+    Utils.tryWithResource(new PrintWriter(new File(inputFilePath))) { writer =>
+      for (i <- 1 to 3) {
         writer.print(i)
         writer.write('\n')
       }
     }
 
-    val conf = new SparkConf(false).setMaster("local").
-      set("spark.kryo.registrationRequired", "true").setAppName("test")
-    conf.set("spark.serializer", classOf[KryoSerializer].getName)
+    // Start a new SparkContext
+    val conf = new SparkConf(false)
+      .setMaster("local")
+      .setAppName("test")
+      .set("spark.kryo.registrationRequired", "true")
+      .set("spark.serializer", classOf[KryoSerializer].getName)
+    sc = new SparkContext(conf)
+
+    // Prepare the input RDD
+    val pairRDD = sc.textFile(inputFilePath).map(x => (x, x))
 
+    // Test saveAsTextFile()
+    val outputFilePath1 = new File(tempDir, "/out1").getAbsolutePath
+    pairRDD.saveAsTextFile(outputFilePath1)
+    assert(sc.textFile(outputFilePath1).collect() === Array("(1,1)", "(2,2)", 
"(3,3)"))
 
 Review comment:
   We should ensure the content in the output file is correct.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to