attilapiros commented on code in PR #37468:
URL: https://github.com/apache/spark/pull/37468#discussion_r964330609


##########
hadoop-cloud/src/hadoop-3/test/scala/org/apache/spark/internal/io/cloud/CommitterBindingSuite.scala:
##########
@@ -125,21 +132,57 @@ class CommitterBindingSuite extends SparkFunSuite {
     val instance = FileCommitProtocol.instantiate(
       pathCommitProtocolClassname,
       jobId, "file:///tmp", false)
-
     val protocol = instance.asInstanceOf[PathOutputCommitProtocol]
     assert("file:///tmp" === protocol.destination)
   }
 
-  test("reject dynamic partitioning") {
-    val cause = intercept[InvocationTargetException] {
-      FileCommitProtocol.instantiate(
-        pathCommitProtocolClassname,
-        jobId, "file:///tmp", true)
-    }.getCause
-    if (cause == null || !cause.isInstanceOf[IOException]
-        || !cause.getMessage.contains(PathOutputCommitProtocol.UNSUPPORTED)) {
-      throw cause
+  test("reject dynamic partitioning if not supported") {
+    val path = new Path("http://example/data";)
+    val job = newJob(path)
+    val conf = job.getConfiguration
+    conf.set(MRJobConfig.TASK_ATTEMPT_ID, taskAttempt0)
+    conf.setInt(MRJobConfig.APPLICATION_ATTEMPT_ID, 1)
+    StubPathOutputCommitterBinding.bind(conf, "http")
+    val tContext = new TaskAttemptContextImpl(conf, taskAttemptId0)
+    val committer = FileCommitProtocol.instantiate(
+      pathCommitProtocolClassname,
+      jobId, path.toUri.toString, true)
+    val ioe = intercept[IOException] {
+      committer.setupJob(tContext)
+    }
+    if (!ioe.getMessage.contains(PathOutputCommitProtocol.UNSUPPORTED)) {
+      throw ioe
     }
+    intercept[UnsupportedOperationException] {
+      committer.newTaskTempFileAbsPath(
+        tContext,
+        "/tmp",
+        FileNameSpec("lotus", ".123"))
+    }
+  }
+
+  test("permit dynamic partitioning if the committer says it works") {

Review Comment:
   Could you please add a new test where the exact same things are checked just 
using  `FileOutputCommitterFactory` at the binding (by extracting the test body 
into separate method(s) and reusing most of the parts)?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to