Skip to content

Commit 286e3fb

Browse files
zhang1002yaooqinn
authored andcommitted
[KYUUBI apache#862] Revise the unit test for "add kyuubiStatementInfo into queue"
### _Why are the changes needed?_ Revise the unit test for "add kyuubiStatementInfo into queue" ### _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/tools/testing.html#running-tests) locally before make a pull request Closes apache#862 from zhang1002/update_statementinfo_ut. Closes apache#862 7e5f8b5 [张宇翔] Revise the unit test for "add kyuubiStatementInfo into queue" e517cfc [张宇翔] Merge remote-tracking branch 'upstream/master' 18aebe7 [张宇翔] Merge remote-tracking branch 'upstream/master' f248bef [张宇翔] Merge remote-tracking branch 'upstream/master' 5ffb54f [张宇翔] Add kyuubi-spark-monitor module for nightly.yml Authored-by: 张宇翔 <zhang1002@126.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent ce5fb97 commit 286e3fb

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/KyuubiStatementMonitorSuite.scala

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,29 @@ class KyuubiStatementMonitorSuite extends WithSparkSQLEngine with HiveJDBCTests
3636
override protected def jdbcUrl: String = getJdbcUrl
3737
override def withKyuubiConf: Map[String, String] = Map.empty
3838

39-
test("add kyuubiStatementInfo into queue and remove them by size type threshold") {
40-
val sql = "select timestamp'2021-06-01'"
39+
test("add kyuubiStatementInfo into queue") {
40+
var baseSql = "select timestamp'2021-06-0"
4141
val total: Int = 7
4242
// Clear kyuubiStatementQueue first
4343
val getQueue = PrivateMethod[
4444
ArrayBlockingQueue[KyuubiStatementInfo]](Symbol("kyuubiStatementQueue"))()
4545
val kyuubiStatementQueue = KyuubiStatementMonitor.invokePrivate(getQueue)
4646
kyuubiStatementQueue.clear()
4747
withSessionHandle { (client, handle) =>
48+
4849
for ( a <- 1 to total ) {
50+
val sql = baseSql + a + "'"
4951
val req = new TExecuteStatementReq()
5052
req.setSessionHandle(handle)
5153
req.setStatement(sql)
5254
val tExecuteStatementResp = client.ExecuteStatement(req)
5355
val operationHandle = tExecuteStatementResp.getOperationHandle
54-
waitForOperationToComplete(client, operationHandle)
55-
}
5656

57-
var iterator = kyuubiStatementQueue.iterator()
58-
while (iterator.hasNext) {
59-
val kyuubiStatementInfo = iterator.next()
60-
assert(kyuubiStatementInfo.statement !== null)
61-
assert(kyuubiStatementInfo.statementId !== null)
62-
assert(kyuubiStatementInfo.sessionId !== null)
63-
assert(kyuubiStatementInfo.queryExecution !== null)
64-
assert(kyuubiStatementInfo.stateToTime.size === 4)
57+
val kyuubiStatementInfo = kyuubiStatementQueue.poll()
58+
assert(
59+
kyuubiStatementInfo.statementId === OperationHandle(operationHandle).identifier.toString)
60+
assert(sql === kyuubiStatementInfo.statement)
6561
}
66-
iterator = null
67-
68-
// Test for clear kyuubiStatementQueue
69-
// This function is used for avoiding mem leak
70-
val req = new TExecuteStatementReq()
71-
req.setSessionHandle(handle)
72-
req.setStatement(sql)
73-
val tExecuteStatementResp = client.ExecuteStatement(req)
74-
val operationHandle = tExecuteStatementResp.getOperationHandle
75-
waitForOperationToComplete(client, operationHandle)
76-
77-
assert(kyuubiStatementQueue.size() === 1)
7862
}
7963
}
8064

0 commit comments

Comments
 (0)