add suites to pass code cov

This commit is contained in:
Kent Yao 2018-05-21 23:21:40 +08:00
parent 28421ec5c1
commit 9c2f6fccbb
3 changed files with 67 additions and 3 deletions

View File

@ -27,9 +27,9 @@ import yaooqinn.kyuubi.ui.{KyuubiServerListener, KyuubiServerMonitor}
* This assumes the given SparkContext has enabled its SparkUI.
*/
class KyuubiServerTab(userName: String, sparkContext: SparkContext)
extends SparkUITab(getSparkUI(sparkContext), "sqlserver") {
extends SparkUITab(getSparkUI(sparkContext), userName) {
override val name = "Kyuubi Server"
override val name = s"Kyuubi Tab 4 $userName"
val parent = getSparkUI(sparkContext)

View File

@ -20,7 +20,7 @@ package yaooqinn.kyuubi.ui
import scala.collection.JavaConverters._
import scala.collection.mutable
import org.apache.spark.{SparkConf, KyuubiSparkUtil}
import org.apache.spark.{KyuubiSparkUtil, SparkConf}
import org.apache.spark.scheduler.{SparkListener, SparkListenerJobStart}
import org.apache.spark.sql.internal.SQLConf

View File

@ -0,0 +1,64 @@
/*
* 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.ui
import org.apache.spark.{KyuubiSparkUtil, SparkConf, SparkContext, SparkFunSuite}
import yaooqinn.kyuubi.ui.KyuubiServerListener
class KyuubiServerTabSuite extends SparkFunSuite {
var sc: SparkContext = _
var user: String = _
var tab: KyuubiServerTab = _
override def beforeAll(): Unit = {
val conf = new SparkConf(loadDefaults = true).setMaster("local").setAppName("test")
sc = new SparkContext(conf)
user = KyuubiSparkUtil.getCurrentUserName()
tab = new KyuubiServerTab(user, sc)
}
override def afterAll(): Unit = {
sc.stop()
}
test("testParent") {
assert(tab.parent === sc.ui.get)
}
test("testListener") {
assert(tab.listener !== null)
assert(tab.listener.isInstanceOf[KyuubiServerListener])
}
test("testName") {
assert(tab.name === "Kyuubi Tab 4 " + user)
}
test("testDetach") {
assert(KyuubiServerTab.getSparkUI(sc).getTabs.contains(tab))
tab.detach()
assert(!KyuubiServerTab.getSparkUI(sc).getTabs.contains(tab))
}
test("testGetSparkUI") {
assert(KyuubiServerTab.getSparkUI(sc) === sc.ui.get)
}
}