improve test for operation log

This commit is contained in:
Kent Yao 2020-09-10 16:59:57 +08:00
parent ee315c6963
commit 13706c3c3a
2 changed files with 17 additions and 2 deletions

View File

@ -89,8 +89,8 @@ object OperationLog extends Logging {
class OperationLog(path: Path) extends Logging {
private lazy val writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)
private lazy val reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)
private val writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)
private val reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)
/**
* write log to the operation log file

View File

@ -100,4 +100,19 @@ class OperationLogSuite extends KyuubiFunSuite {
assert(list2.isEmpty)
operationLog.close()
}
test("exception when creating log files") {
val sHandle = SessionHandle(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10)
val logRoot = Paths.get(OperationLog.LOG_ROOT, sHandle.identifier.toString).toFile
logRoot.deleteOnExit()
Files.createFile(Paths.get(OperationLog.LOG_ROOT, sHandle.identifier.toString))
assert(logRoot.exists())
OperationLog.createOperationLogRootDirectory(sHandle)
assert(logRoot.isFile)
val oHandle = OperationHandle(
OperationType.EXECUTE_STATEMENT, TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10)
val log = OperationLog.createOperationLog(sHandle, oHandle)
assert(log === null)
}
}