HeartSaVioR commented on a change in pull request #23764: [SPARK-26825][SS] Fix 
temp checkpoint creation in cluster mode when default filesystem is not local.
URL: https://github.com/apache/spark/pull/23764#discussion_r260440654
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/StreamingCheckpointSuite.scala
 ##########
 @@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming
+
+import java.net.URI
+
+import org.apache.hadoop.fs.{LocalFileSystem, Path, RawLocalFileSystem}
+import org.apache.hadoop.fs.permission.FsPermission
+
+import org.apache.spark.{SparkConf, SparkFunSuite}
+import org.apache.spark.sql.{Encoder, LocalSparkSession, SparkSession, 
SQLContext}
+
+class StreamingCheckpointSuite extends SparkFunSuite with LocalSparkSession {
+
+  test("temp checkpoint dir should stay local even if default filesystem is 
not local") {
+    val conf = new SparkConf()
+      .set("spark.hadoop.fs.file.impl", classOf[LocalFileSystem].getName)
+      .set("spark.hadoop.fs.mockfs.impl", 
classOf[MkdirRecordingFileSystem].getName)
+      .set("spark.hadoop.fs.defaultFS", "mockfs:///")
+
+    spark = 
SparkSession.builder().master("local").appName("test").config(conf).getOrCreate()
+
+    implicit val intEncoder: Encoder[Int] = spark.implicits.newIntEncoder
+    implicit val sqlContext: SQLContext = spark.sqlContext
+
+    MkdirRecordingFileSystem.reset()
+    val query = MemoryStream[Int].toDF().writeStream.format("console").start()
+    try {
+      val checkpointDir = new Path(
+        
query.asInstanceOf[StreamingQueryWrapper].streamingQuery.resolvedCheckpointRoot)
+      val fs = checkpointDir.getFileSystem(spark.sessionState.newHadoopConf())
+      assert(fs.getScheme === "file")
+      assert(fs.exists(checkpointDir))
+      assert(MkdirRecordingFileSystem.requests === 0,
 
 Review comment:
   Nice to have verifying with checkpointDir!
   
   Btw, if we know the path of checkpointDir, we can record actual path of 
request in MkdirRecordingFileSystem (like before) and let them just created, 
and find whether recorded directories have checkpointDir. This would make test 
still pass when Spark will be changed to create multiple directories including 
checkpointDir. 
   
   This change may disable the impact of `fs.exist(checkpointDir)`, but we can 
determine which filesystem creates that directory so IMHO it's not a big deal.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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