srowen commented on a change in pull request #28002: [SPARK-31233][Core] 
Enhance RpcTimeoutException Log Message
URL: https://github.com/apache/spark/pull/28002#discussion_r407840992
 
 

 ##########
 File path: 
core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala
 ##########
 @@ -135,4 +136,49 @@ class NettyRpcEnvSuite extends RpcEnvSuite with 
MockitoSugar with TimeLimits {
       anotherEnv.awaitTermination()
     }
   }
+
+
+  test("SPARK-31233: ask rpcEndpointRef in client mode timeout") {
+    var remoteRef: RpcEndpointRef = null
+    env.setupEndpoint("ask-remotely-server", new RpcEndpoint {
+      override val rpcEnv = env
+      override def receiveAndReply(context: RpcCallContext): 
PartialFunction[Any, Unit] = {
+        case Register(ref) =>
+          remoteRef = ref
+          context.reply("okay")
+        case msg: String =>
+          context.reply(msg)
+      }
+    })
+    val conf = new SparkConf()
+    val anotherEnv = createRpcEnv(conf, "remote", 0, clientMode = true)
+    // Use anotherEnv to find out the RpcEndpointRef
+    val rpcEndpointRef = anotherEnv.setupEndpointRef(env.address, 
"ask-remotely-server")
+    // Register a rpcEndpointRef in anotherEnv
+    val anotherRef = anotherEnv.setupEndpoint("receiver", new RpcEndpoint {
+      override val rpcEnv = anotherEnv
+      override def receiveAndReply(context: RpcCallContext): 
PartialFunction[Any, Unit] = {
+        case _ =>
+          Thread.sleep(1200)
+          context.reply("okay")
+      }
+    })
+    try {
+      val reply = rpcEndpointRef.askSync[String](Register(anotherRef))
+      assert("okay" === reply)
+      val timeout = "1s"
+      val answer = remoteRef.ask[String]("msg",
+        RpcTimeout(conf, Seq("spark.rpc.askTimeout", "spark.network.timeout"), 
timeout))
+      val thrown = intercept[RpcTimeoutException] {
+        ThreadUtils.awaitResult(answer, Duration(1300, MILLISECONDS))
+      }
+      val remoteAddr = 
remoteRef.asInstanceOf[NettyRpcEndpointRef].client.getChannel.remoteAddress
+      val exptMsg = s"Cannot receive any reply from $remoteAddr in 1 second. " 
+
 
 Review comment:
   I wouldn't be this specific in testing error messages. Just assert it 
contains the address you are expecting and/or maybe another key phrase

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to