add more uts
This commit is contained in:
parent
0495a55f9b
commit
443ef11fce
@ -114,7 +114,7 @@ private[kyuubi] class SessionManager private(
|
||||
resourcesRootDir = new File(conf.get(OPERATION_DOWNLOADED_RESOURCES_DIR))
|
||||
if (resourcesRootDir.exists() && !resourcesRootDir.isDirectory) {
|
||||
throw new ServiceException("The operation downloaded resources directory exists but is not" +
|
||||
s" a directory + ${resourcesRootDir.getAbsolutePath}")
|
||||
s" a directory ${resourcesRootDir.getAbsolutePath}")
|
||||
}
|
||||
if (!resourcesRootDir.exists() && !resourcesRootDir.mkdirs()) {
|
||||
throw new ServiceException("Unable to create the operation downloaded resources directory" +
|
||||
|
||||
@ -22,7 +22,6 @@ import java.io.File
|
||||
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod
|
||||
import org.apache.hive.service.cli.thrift.TProtocolVersion
|
||||
import org.apache.spark.{KyuubiConf, KyuubiSparkUtil, SparkFunSuite}
|
||||
import org.apache.spark.KyuubiConf.LOGGING_OPERATION_LOG_DIR
|
||||
import org.apache.spark.sql.SparkSession
|
||||
|
||||
import yaooqinn.kyuubi.KyuubiSQLException
|
||||
@ -34,6 +33,8 @@ import yaooqinn.kyuubi.utils.ReflectUtils
|
||||
|
||||
class KyuubiSessionSuite extends SparkFunSuite {
|
||||
|
||||
import KyuubiConf._
|
||||
|
||||
var server: KyuubiServer = _
|
||||
var session: KyuubiSession = _
|
||||
var spark: SparkSession = _
|
||||
@ -105,10 +106,8 @@ class KyuubiSessionSuite extends SparkFunSuite {
|
||||
}
|
||||
|
||||
test("set operation log session dir") {
|
||||
val operationLogRootDir = new File(server.getConf.get(LOGGING_OPERATION_LOG_DIR.key))
|
||||
operationLogRootDir.setReadable(true)
|
||||
operationLogRootDir.setWritable(true)
|
||||
operationLogRootDir.setExecutable(true)
|
||||
val operationLogRootDir = new File(server.getConf.get(LOGGING_OPERATION_LOG_DIR))
|
||||
operationLogRootDir.mkdirs()
|
||||
session.setOperationLogSessionDir(operationLogRootDir)
|
||||
assert(session.isOperationLogEnabled)
|
||||
assert(operationLogRootDir.exists())
|
||||
@ -128,6 +127,30 @@ class KyuubiSessionSuite extends SparkFunSuite {
|
||||
operationLogRootDir.setExecutable(true)
|
||||
}
|
||||
|
||||
test("set resources session dir") {
|
||||
val resourceRoot = new File(server.getConf.get(OPERATION_DOWNLOADED_RESOURCES_DIR))
|
||||
resourceRoot.mkdirs()
|
||||
resourceRoot.deleteOnExit()
|
||||
assert(resourceRoot.isDirectory)
|
||||
session.setResourcesSessionDir(resourceRoot)
|
||||
val subDir = resourceRoot.listFiles().head
|
||||
assert(subDir.getName === KyuubiSparkUtil.getCurrentUserName)
|
||||
val resourceDir = subDir.listFiles().head
|
||||
assert(resourceDir.getName === session.getSessionHandle.getSessionId + "_resources")
|
||||
session.setResourcesSessionDir(resourceRoot)
|
||||
assert(subDir.listFiles().length === 1, "directory should already exists")
|
||||
assert(resourceDir.delete())
|
||||
resourceDir.createNewFile()
|
||||
assert(resourceDir.isFile)
|
||||
val e1 = intercept[RuntimeException](session.setResourcesSessionDir(resourceRoot))
|
||||
assert(e1.getMessage.startsWith("The resources directory exists but is not a directory"))
|
||||
resourceDir.delete()
|
||||
subDir.setWritable(false)
|
||||
val e2 = intercept[RuntimeException](session.setResourcesSessionDir(resourceRoot))
|
||||
assert(e2.getMessage.startsWith("Couldn't create session resources directory"))
|
||||
subDir.setWritable(true)
|
||||
}
|
||||
|
||||
test("get no operation time") {
|
||||
assert(session.getNoOperationTime !== 0L)
|
||||
}
|
||||
|
||||
@ -24,11 +24,13 @@ import org.apache.hive.service.cli.thrift.TProtocolVersion
|
||||
import org.apache.spark.{KyuubiConf, KyuubiSparkUtil, SparkConf, SparkFunSuite}
|
||||
|
||||
import yaooqinn.kyuubi.KyuubiSQLException
|
||||
import yaooqinn.kyuubi.service.State
|
||||
import yaooqinn.kyuubi.service.{ServiceException, State}
|
||||
import yaooqinn.kyuubi.utils.ReflectUtils
|
||||
|
||||
class SessionManagerSuite extends SparkFunSuite {
|
||||
|
||||
import KyuubiConf._
|
||||
|
||||
test("init operation log") {
|
||||
val logRoot = UUID.randomUUID().toString
|
||||
val logRoot2 = logRoot + "/sub"
|
||||
@ -67,6 +69,28 @@ class SessionManagerSuite extends SparkFunSuite {
|
||||
sessionManager4.stop()
|
||||
}
|
||||
|
||||
test("init resources root dir") {
|
||||
val conf = new SparkConf(true).set(KyuubiConf.LOGGING_OPERATION_ENABLED.key, "false")
|
||||
KyuubiSparkUtil.setupCommonConfig(conf)
|
||||
val sessionManager = new SessionManager()
|
||||
|
||||
sessionManager.init(conf)
|
||||
val resourcesRoot = new File(conf.get(OPERATION_DOWNLOADED_RESOURCES_DIR))
|
||||
assert(resourcesRoot.exists())
|
||||
assert(resourcesRoot.isDirectory)
|
||||
resourcesRoot.delete()
|
||||
resourcesRoot.createNewFile()
|
||||
val e1 = intercept[ServiceException](sessionManager.init(conf))
|
||||
assert(e1.getMessage.startsWith(
|
||||
"The operation downloaded resources directory exists but is not a directory"))
|
||||
resourcesRoot.delete()
|
||||
resourcesRoot.getParentFile.setWritable(false)
|
||||
val e2 = intercept[ServiceException](sessionManager.init(conf))
|
||||
assert(e2.getMessage.startsWith("Unable to create the operation downloaded resources " +
|
||||
"directory"))
|
||||
resourcesRoot.getParentFile.setWritable(true)
|
||||
}
|
||||
|
||||
test("start timeout checker") {
|
||||
val conf = new SparkConf().set(KyuubiConf.FRONTEND_SESSION_CHECK_INTERVAL.key, "-1")
|
||||
val sessionManager = new SessionManager()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user