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

    https://github.com/apache/spark/pull/15009#discussion_r106237826
  
    --- Diff: 
resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala
 ---
    @@ -201,6 +210,152 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         finalState should be (SparkAppHandle.State.FAILED)
       }
     
    +  test("monitor app using launcher library for thread") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .launchAsThread(true)
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.stop()
    +
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for proc with auto shutdown") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .autoShutdown()
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.disconnect()
    +      val applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      val yarnClient: YarnClient = getYarnClient
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = 
yarnClient.getApplicationReport(applicationId).getFinalApplicationStatus()
    +        status should be (FinalApplicationStatus.KILLED)
    +      }
    +
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for thread with auto shutdown") 
{
    --- End diff --
    
    This looks like the exact same code as the previous test with a different 
parameter to the `launchAsThread` method, so you could have a helper method for 
it instead of copy & paste.
    
    In fact, the three tests you're adding are basically the same as the 
existing one, with different parameters:
    - whether to run in a thread
    - whether to use auto-shutdown
    - what's the expected final state
    
    So you could have a single test method with these parameters and different 
invocations of that method.


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