nit
This commit is contained in:
parent
642b52e965
commit
91c14960f4
@ -31,20 +31,21 @@ abstract class Serverable(name: String) extends CompositeService(name) {
|
||||
|
||||
def connectionUrl: String = frontendService.connectionUrl
|
||||
|
||||
override def initialize(conf: KyuubiConf): Unit = {
|
||||
override def initialize(conf: KyuubiConf): Unit = synchronized {
|
||||
addService(backendService)
|
||||
addService(frontendService)
|
||||
super.initialize(conf)
|
||||
}
|
||||
|
||||
override def start(): Unit = {
|
||||
super.start()
|
||||
started.set(true)
|
||||
override def start(): Unit = synchronized {
|
||||
if (!started.getAndSet(true)) {
|
||||
super.start()
|
||||
}
|
||||
}
|
||||
|
||||
protected def stopServer(): Unit
|
||||
|
||||
override def stop(): Unit = {
|
||||
override def stop(): Unit = synchronized {
|
||||
try {
|
||||
stopServer()
|
||||
} catch {
|
||||
|
||||
@ -35,13 +35,13 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
|
||||
this.getClass.getProtectionDomain.getCodeSource.getLocation.getPath, "kyuubi-kdc").toFile
|
||||
val kdcConf = MiniKdc.createConf()
|
||||
val hostName = "localhost"
|
||||
kdcConf.setProperty(MiniKdc.INSTANCE, "KyuubiKrbServer")
|
||||
kdcConf.setProperty(MiniKdc.ORG_NAME, "KYUUBI")
|
||||
kdcConf.setProperty(MiniKdc.INSTANCE, this.getClass.getSimpleName)
|
||||
kdcConf.setProperty(MiniKdc.ORG_NAME, this.getClass.getSimpleName)
|
||||
kdcConf.setProperty(MiniKdc.ORG_DOMAIN, "COM")
|
||||
kdcConf.setProperty(MiniKdc.KDC_BIND_ADDRESS, hostName)
|
||||
if (logger.isDebugEnabled) {
|
||||
kdcConf.setProperty(MiniKdc.DEBUG, "true")
|
||||
}
|
||||
kdcConf.setProperty(MiniKdc.KDC_PORT, "0")
|
||||
kdcConf.setProperty(MiniKdc.DEBUG, "true")
|
||||
|
||||
private var kdc: MiniKdc = _
|
||||
|
||||
eventually(timeout(60.seconds), interval(1.second)) {
|
||||
@ -59,9 +59,7 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
|
||||
}
|
||||
|
||||
private val keytabFile = new File(baseDir, "kyuubi-test.keytab")
|
||||
|
||||
protected val testKeytab: String = keytabFile.getAbsolutePath
|
||||
|
||||
protected var testPrincipal = s"client/$hostName"
|
||||
kdc.createPrincipal(keytabFile, testPrincipal)
|
||||
|
||||
@ -93,7 +91,7 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
|
||||
|
||||
kdc.getKrb5conf.delete()
|
||||
Files.write(krb5confStr, kdc.getKrb5conf, StandardCharsets.UTF_8)
|
||||
debug(s"krb5.conf file content: $krb5confStr")
|
||||
info(s"krb5.conf file content: $krb5confStr")
|
||||
}
|
||||
|
||||
private def addedKrb5Config(key: String, value: String): String = {
|
||||
@ -101,6 +99,7 @@ trait KerberizedTestHelper extends KyuubiFunSuite {
|
||||
}
|
||||
|
||||
rewriteKrb5Conf()
|
||||
|
||||
testPrincipal = testPrincipal + "@" + kdc.getRealm
|
||||
|
||||
info(s"KerberizedTest Principal: $testPrincipal")
|
||||
|
||||
@ -51,7 +51,6 @@ class KinitAuxiliaryServiceSuite extends KerberizedTestHelper {
|
||||
assert(service.getServiceState === ServiceState.STARTED)
|
||||
service.stop()
|
||||
assert(service.getServiceState === ServiceState.STOPPED)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,23 +32,24 @@ class ServerableSuite extends KyuubiFunSuite {
|
||||
assert(serverable.getServiceState === ServiceState.LATENT)
|
||||
intercept[IllegalStateException](serverable.start())
|
||||
|
||||
val serverable1 = new NoopServer()
|
||||
val conf = KyuubiConf().set(KyuubiConf.FRONTEND_BIND_PORT, 0)
|
||||
serverable.initialize(conf)
|
||||
serverable.stop()
|
||||
assert(serverable.getStartTime === 0)
|
||||
assert(serverable.getConf === conf)
|
||||
assert(serverable.connectionUrl.nonEmpty)
|
||||
assert(serverable.getServiceState === ServiceState.INITIALIZED)
|
||||
serverable.start()
|
||||
assert(serverable.getStartTime !== 0)
|
||||
assert(serverable.getConf === conf)
|
||||
assert(serverable.getServiceState === ServiceState.STARTED)
|
||||
serverable.stop()
|
||||
assert(serverable.getStartTime !== 0)
|
||||
assert(serverable.getConf === conf)
|
||||
assert(serverable.connectionUrl.nonEmpty)
|
||||
assert(serverable.getServiceState === ServiceState.STOPPED)
|
||||
serverable.stop()
|
||||
serverable1.initialize(conf)
|
||||
serverable1.stop()
|
||||
assert(serverable1.getStartTime === 0)
|
||||
assert(serverable1.getConf === conf)
|
||||
assert(serverable1.connectionUrl.nonEmpty)
|
||||
assert(serverable1.getServiceState === ServiceState.INITIALIZED)
|
||||
serverable1.start()
|
||||
assert(serverable1.getStartTime !== 0)
|
||||
assert(serverable1.getConf === conf)
|
||||
assert(serverable1.getServiceState === ServiceState.STARTED)
|
||||
serverable1.stop()
|
||||
assert(serverable1.getStartTime !== 0)
|
||||
assert(serverable1.getConf === conf)
|
||||
assert(serverable1.connectionUrl.nonEmpty)
|
||||
assert(serverable1.getServiceState === ServiceState.STOPPED)
|
||||
serverable1.stop()
|
||||
}
|
||||
|
||||
test("invalid port") {
|
||||
|
||||
@ -23,13 +23,13 @@ import javax.security.auth.login.Configuration
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
import org.apache.kyuubi.{KerberizedTestHelper, KYUUBI_VERSION, KyuubiFunSuite}
|
||||
import org.apache.kyuubi.{KerberizedTestHelper, KYUUBI_VERSION}
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.ha.HighAvailabilityConf._
|
||||
import org.apache.kyuubi.ha.server.EmbeddedZkServer
|
||||
import org.apache.kyuubi.service.{NoopServer, Serverable, ServiceState}
|
||||
|
||||
class ServiceDiscoverySuite extends KyuubiFunSuite with KerberizedTestHelper {
|
||||
class ServiceDiscoverySuite extends KerberizedTestHelper {
|
||||
val zkServer = new EmbeddedZkServer()
|
||||
val conf: KyuubiConf = KyuubiConf()
|
||||
|
||||
|
||||
@ -19,9 +19,9 @@ package org.apache.kyuubi.ha.client
|
||||
|
||||
import org.apache.zookeeper.ZooDefs
|
||||
|
||||
import org.apache.kyuubi.{KerberizedTestHelper, KyuubiFunSuite}
|
||||
import org.apache.kyuubi.KerberizedTestHelper
|
||||
|
||||
class ZooKeeperACLProviderSuite extends KyuubiFunSuite with KerberizedTestHelper {
|
||||
class ZooKeeperACLProviderSuite extends KerberizedTestHelper {
|
||||
|
||||
test("acl for zookeeper") {
|
||||
val provider = new ZooKeeperACLProvider()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user