Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6205#discussion_r33798162
  
    --- Diff: core/src/test/scala/org/apache/spark/rpc/RpcEnvSuite.scala ---
    @@ -539,6 +544,97 @@ abstract class RpcEnvSuite extends SparkFunSuite with 
BeforeAndAfterAll {
         }
       }
     
    +  test("construct RpcTimeout with conf property") {
    +    val conf = new SparkConf
    +
    +    val testProp = "spark.ask.test.timeout"
    +    val testDurationSeconds = 30
    +    val secondaryProp = "spark.ask.secondary.timeout"
    +
    +    conf.set(testProp, s"${testDurationSeconds}s")
    +    conf.set(secondaryProp, "100s")
    +
    +    // Construct RpcTimeout with a single property
    +    val rt1 = RpcTimeout(conf, testProp)
    +    assert( testDurationSeconds === rt1.duration.toSeconds )
    +
    +    // Construct RpcTimeout with prioritized list of properties
    +    val rt2 = RpcTimeout(conf, Seq("spark.ask.invalid.timeout", testProp, 
secondaryProp), "1s")
    +    assert( testDurationSeconds === rt2.duration.toSeconds )
    +
    +    // Construct RpcTimeout with default value,
    +    val defaultProp = "spark.ask.default.timeout"
    +    val defaultDurationSeconds = 1
    +    val rt3 = RpcTimeout(conf, Seq(defaultProp), 
defaultDurationSeconds.toString + "s")
    +    assert( defaultDurationSeconds === rt3.duration.toSeconds )
    +    assert( rt3.timeoutProp.contains(defaultProp) )
    +
    +    // Try to construct RpcTimeout with an unconfigured property
    +    intercept[NoSuchElementException] {
    +      RpcTimeout(conf, "spark.ask.invalid.timeout")
    +    }
    +  }
    +
    +  test("ask a message timeout on Future using RpcTimeout") {
    +    case class SleepyReply(msg: String)
    +
    +    val rpcEndpointRef = env.setupEndpoint("ask-future", new RpcEndpoint {
    +      override val rpcEnv = env
    +
    +      override def receiveAndReply(context: RpcCallContext): 
PartialFunction[Any, Unit] = {
    +        case msg: String => {
    +          context.reply(msg)
    +        }
    +        case sr: SleepyReply => {
    +          Thread.sleep(50)
    --- End diff --
    
    +1, great idea.
    
    maybe is it also worth adding one more check that `SleepyReply` does make 
it through after you release the latch?  Or if that isn't necessary, couldn't 
we just change `SleepyReply` to `NeverReply`, which never sends anything back 
and we don't even need the latch.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to