[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 <zhangshiming@cvte.com>
Co-authored-by: Simon <3656562@qq.com>
Signed-off-by: ulysses-you <ulyssesyou@apache.org>
This commit is contained in:
simon 2021-10-12 10:52:54 +08:00 committed by ulysses-you
parent bf629291bf
commit a55d5fbf79
No known key found for this signature in database
GPG Key ID: 4C500BC62D576766

View File

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