From a55d5fbf79976d457975bbcbf0103f276e6d67cd Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 12 Oct 2021 10:52:54 +0800 Subject: [PATCH] [KYUUBI #1039] [TEST] Add kill application test ### Why are the changes needed? Add kill application test for #1119 ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1194 from simon824/killTest. Closes #1039 36386726 [Simon] Merge branch 'apache:master' into killTest acb55492 [simon] init 3d9c12d3 [simon] Merge remote-tracking branch 'upstream/master' 5b905dbd [simon] Merge remote-tracking branch 'upstream/master' Lead-authored-by: simon Co-authored-by: Simon <3656562@qq.com> Signed-off-by: ulysses-you --- .../spark/SparkProcessBuilderSuite.scala | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala index 592822946..e46407ac6 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala @@ -225,6 +225,26 @@ class SparkProcessBuilderSuite extends KerberizedTestHelper { val b2 = new SparkProcessBuilder("test", conf) assert(b2.mainResource.getOrElse("") != jarPath.toString) } + + test("kill application") { + val pb1 = new FakeSparkProcessBuilder(conf) { + override protected def env: Map[String, String] = Map() + } + val exit1 = pb1.killApplication("21/09/30 17:12:47 INFO yarn.Client: " + + "Application report for application_1593587619692_20149 (state: ACCEPTED)") + assert(exit1.contains("KYUUBI_HOME is not set!")) + + val pb2 = new FakeSparkProcessBuilder(conf) { + override protected def env: Map[String, String] = Map("KYUUBI_HOME" -> "") + } + val exit2 = pb2.killApplication("21/09/30 17:12:47 INFO yarn.Client: " + + "Application report for application_1593587619692_20149 (state: ACCEPTED)") + assert(exit2.contains("application_1593587619692_20149") + && !exit2.contains("KYUUBI_HOME is not set!")) + + val exit3 = pb2.killApplication("unknow") + assert(exit3.equals("")) + } } class FakeSparkProcessBuilder(config: KyuubiConf)