diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala index b993789ba72..af49598fe82 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala @@ -62,8 +62,11 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { val statistic = webTarget.path("api/v1/sessions/execPool/statistic").request().get() val execPoolStatistic1 = statistic.readEntity(classOf[ExecPoolStatistic]) + // because this operation is asynchronous, + // there is no guarantee that it will complete quickly or fail in the process + // so we can not guarantee the poolActiveThread count must equal to 1 assert(execPoolStatistic1.getExecPoolSize == 1 && - execPoolStatistic1.getExecPoolActiveCount == 1) + execPoolStatistic1.getExecPoolActiveCount <= 1) response = webTarget.path("api/v1/sessions/count").request().get() val openedSessionCount = response.readEntity(classOf[SessionOpenCount]) @@ -97,11 +100,16 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { response = webTarget.path(s"api/v1/sessions/$sessionHandle").request().delete() assert(200 == response.getStatus) - // get session list again - response2 = webTarget.path("api/v1/sessions").request().get() - assert(200 == response2.getStatus) - val sessions2 = response2.readEntity(classOf[Seq[SessionData]]) - assert(sessions2.isEmpty) + // because delete is a asynchronous operation, we need eventually to + // make sure the delete operation process complete + eventually(timeout(3.seconds)) { + // get session list again + response2 = webTarget.path("api/v1/sessions").request().get() + assert(200 == response2.getStatus) + + val sessions = response2.readEntity(classOf[Seq[SessionData]]) + assert(sessions.isEmpty) + } } test("get session event") {