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

    https://github.com/apache/spark/pull/9317#discussion_r43219668
  
    --- Diff: 
core/src/test/scala/org/apache/spark/deploy/client/AppClientSuite.scala ---
    @@ -0,0 +1,206 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.deploy.client
    +
    +import org.apache.spark._
    +import org.apache.spark.deploy.{Command, ApplicationDescription}
    +import org.apache.spark.deploy.DeployMessages.{MasterStateResponse, 
RequestMasterState}
    +import org.apache.spark.deploy.master.{ApplicationInfo, Master}
    +import org.apache.spark.deploy.worker.Worker
    +import org.apache.spark.rpc.RpcEnv
    +import org.apache.spark.util.Utils
    +import org.scalatest.BeforeAndAfterAll
    +import org.scalatest.concurrent.Eventually._
    +
    +import scala.collection.mutable.{SynchronizedBuffer, ArrayBuffer}
    +import scala.concurrent.duration._
    +
    +/**
    + * End-to-end tests for application client in standalone mode.
    + */
    +class AppClientSuite
    +  extends SparkFunSuite
    +  with LocalSparkContext
    +  with BeforeAndAfterAll {
    +
    +  private val numWorkers = 2
    +  private val conf = new SparkConf()
    +  private val securityManager = new SecurityManager(conf)
    +
    +  private var masterRpcEnv: RpcEnv = null
    +  private var workerRpcEnvs: Seq[RpcEnv] = null
    +  private var master: Master = null
    +  private var workers: Seq[Worker] = null
    +
    +  /**
    +   * Start the local cluster.
    +   * Note: local-cluster mode is insufficient because we want a reference 
to the Master.
    +   */
    +  override def beforeAll(): Unit = {
    +    super.beforeAll()
    +    masterRpcEnv = RpcEnv.create(Master.SYSTEM_NAME, "localhost", 0, conf, 
securityManager)
    +    workerRpcEnvs = (0 until numWorkers).map { i =>
    +      RpcEnv.create(Worker.SYSTEM_NAME + i, "localhost", 0, conf, 
securityManager)
    +    }
    +    master = makeMaster()
    +    workers = makeWorkers(10, 2048)
    +    // Wait until all workers register with master successfully
    +    eventually(timeout(60.seconds), interval(10.millis)) {
    +      assert(getMasterState.workers.size === numWorkers)
    +    }
    +  }
    +
    +  override def afterAll(): Unit = {
    +    workerRpcEnvs.foreach(_.shutdown())
    +    masterRpcEnv.shutdown()
    +    workers.foreach(_.stop())
    +    master.stop()
    +    workerRpcEnvs = null
    +    masterRpcEnv = null
    +    workers = null
    +    master = null
    +    super.afterAll()
    +  }
    +
    +  test("interface methods of AppClient using local Master") {
    +    val ci = new AppClientInst(masterRpcEnv.address.toSparkURL)
    +
    +    ci.client.start()
    +
    +    // Client should connect with one Master which registers the 
application
    +    eventually(timeout(10.seconds), interval(10.millis)) {
    +      val apps = getApplications()
    +      assert(ci.listener.connectedIdList.size === 1, "client listener 
should have one connection")
    +      assert(apps.size === 1, "master should have 1 registered app")
    +    }
    +
    +    // Send message to Master to request Executors, verify request by 
change in executor limit
    +    val numExecutorsRequested = 1
    +    assert( ci.client.requestTotalExecutors(numExecutorsRequested) )
    +
    +    eventually(timeout(10.seconds), interval(10.millis)) {
    +      val apps = getApplications()
    +      assert(apps.head.getExecutorLimit === numExecutorsRequested, 
s"executor request failed")
    +    }
    +
    +    // Send request to kill executor, verify request was made
    +    assert {
    +      val apps = getApplications()
    +      val executorId: String = apps.head.executors.head._2.fullId
    +      ci.client.killExecutors(Seq(executorId))
    +    }
    +
    +    // Issue stop command for Client to disconnect from Master
    +    ci.client.stop()
    +
    +    // Verify Client is marked dead and unregistered from Master
    +    eventually(timeout(10.seconds), interval(10.millis)) {
    +      val apps = getApplications()
    +      assert(ci.listener.deadReasonList.size === 1, "client should have 
been marked dead")
    +      assert(apps.isEmpty, "master should have 0 registered apps")
    +    }
    +  }
    +
    +  test("request from AppClient before initialized with master") {
    +    val ci = new AppClientInst(masterRpcEnv.address.toSparkURL)
    --- End diff --
    
    Is there a way to tell if the client fails to connect to the master?  It 
does log an error, but if I wanted to check to see if the `AppClient` endpoint 
was registered after calling `start()`, there doesn't seem to be a way.


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