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

    https://github.com/apache/spark/pull/16650#discussion_r99474371
  
    --- Diff: 
core/src/test/scala/org/apache/spark/deploy/StandaloneDynamicAllocationSuite.scala
 ---
    @@ -489,6 +491,29 @@ class StandaloneDynamicAllocationSuite
         }
       }
     
    +  test("executor registration on a blacklisted host must fail") {
    +    sc = new SparkContext(appConf.set(config.BLACKLIST_ENABLED.key, 
"true"))
    +    val endpointRef = mock(classOf[RpcEndpointRef])
    +    val mockAddress = mock(classOf[RpcAddress])
    +    when(endpointRef.address).thenReturn(mockAddress)
    +    val message = RegisterExecutor("one", endpointRef, "localhost", 10, 
Map.empty)
    +
    +    // Get "localhost" on a blacklist.
    +    val taskScheduler = mock(classOf[TaskSchedulerImpl])
    +    when(taskScheduler.nodeBlacklist()).thenReturn(Set("localhost"))
    +    when(taskScheduler.sc).thenReturn(sc)
    +    sc.taskScheduler = taskScheduler
    +
    +    // Create a fresh scheduler backend to blacklist "localhost".
    +    sc.schedulerBackend.stop()
    +    val backend =
    +     new StandaloneSchedulerBackend(taskScheduler, sc, 
Array(masterRpcEnv.address.toSparkURL))
    +    backend.start()
    +
    +    backend.driverEndpoint.ask[Boolean](message)
    +    verify(endpointRef).send(RegisterExecutorFailed(any()))
    --- End diff --
    
    You need to wrap this in an `eventually` since its async.
    
    btw, a simple way to see if your test is flaky locally is to run it in in a 
loop:
    
    ```scala
      (0 until 100).foreach { idx =>
        test(s"executor registration on a blacklisted host must fail $idx") {
    ```
    
    and then in sbt
    
    ```
    test-only *StandaloneDynamicAllocationSuite -- -z "must fail"
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to