From 4655cd851596038bfbb5dc53f60e7612b702ee5e Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 31 Dec 2021 19:28:57 +0800 Subject: [PATCH] [KYUUBI #1654][Bug] Flaky OperationsResourceSuite ### _Why are the changes needed?_ closes #1654 ### _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/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1655 from simon824/flaky. Closes #1654 92548e46 [simon] style 3a748969 [simon] state 3c507da3 [simon] state 4436bb89 [simon] rm e12d483c [simon] flakyut Authored-by: simon Signed-off-by: Kent Yao --- .../server/api/v1/OperationsResourceSuite.scala | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala index b69860811..6d8808ea4 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala @@ -26,7 +26,7 @@ import org.scalatest.time.SpanSugar.convertIntToGrainOfTime import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper} import org.apache.kyuubi.events.KyuubiOperationEvent -import org.apache.kyuubi.operation.{OperationState, OperationType} +import org.apache.kyuubi.operation.{ExecuteStatement, OperationState, OperationType} import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState} import org.apache.kyuubi.operation.OperationType.OperationType @@ -48,7 +48,20 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper } test("apply an action for an operation") { - val opHandleStr = getOpHandleStr(OperationType.EXECUTE_STATEMENT) + val sessionHandle = fe.be.openSession( + HIVE_CLI_SERVICE_PROTOCOL_V2, + "admin", + "123456", + "localhost", + Map("testConfig" -> "testValue")) + val sessionManager = fe.be.sessionManager + val session = sessionManager.getSession(sessionHandle) + val op = new ExecuteStatement(session, "show tables", true, 3000) + op.setState(OperationState.RUNNING) + sessionManager.operationManager.addOperation(op) + val opHandleStr = s"${op.getHandle.identifier.publicId}|" + + s"${op.getHandle.identifier.secretId}|${op.getHandle.protocol.getValue}|" + + s"${op.getHandle.typ.toString}" var response = webTarget.path(s"api/v1/operations/$opHandleStr") .request(MediaType.APPLICATION_JSON_TYPE)