From c6710ae9632db66470a090f205485d9e24f373a9 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 30 Oct 2021 14:58:55 +0800 Subject: [PATCH] [KYUUBI #1313][BUG] Flaky SessionsResourceSuite ### _Why are the changes needed?_ #1313 ### _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 #1315 from simon824/getinfo. Closes #1313 4f26c59a [simon] reduce sleep time ebb6afb5 [simon] fixut 6c366c0b [simon] init Authored-by: simon Signed-off-by: Cheng Pan --- .../server/api/v1/SessionsResourceSuite.scala | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 b0a7921d3..2a2ed5bf1 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 @@ -20,6 +20,8 @@ package org.apache.kyuubi.server.api.v1 import javax.ws.rs.client.Entity import javax.ws.rs.core.{MediaType, Response} +import scala.concurrent.duration._ + import org.apache.kyuubi.KyuubiFunSuite import org.apache.kyuubi.server.{RestFrontendService, RestFrontendServiceSuite} import org.apache.kyuubi.session.SessionHandle @@ -86,7 +88,7 @@ class SessionsResourceSuite extends KyuubiFunSuite { val sessionManager = restFrontendService.be.sessionManager val future = sessionManager.submitBackgroundOperation(() => { - Thread.sleep(3000) + Thread.sleep(1000) }) // verify the exec pool statistic @@ -94,11 +96,12 @@ class SessionsResourceSuite extends KyuubiFunSuite { val execPoolStatistic1 = response.readEntity(classOf[ExecPoolStatistic]) assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1) - // if failed to cancel, need to wait the thread finish. - if (!future.cancel(true)) Thread.sleep(3000) - response = webTarget.path("api/v1/sessions/execpool/statistic").request().get() - val execPoolStatistic2 = response.readEntity(classOf[ExecPoolStatistic]) - assert(execPoolStatistic2.execPoolSize == 1 && execPoolStatistic2.execPoolActiveCount == 0) + future.cancel(true) + eventually(timeout(3.seconds), interval(200.milliseconds)) { + response = webTarget.path("api/v1/sessions/execpool/statistic").request().get() + val statistic = response.readEntity(classOf[ExecPoolStatistic]) + assert(statistic.execPoolSize == 1 && statistic.execPoolActiveCount == 0) + } sessionManager.stop() response = webTarget.path("api/v1/sessions/execpool/statistic").request().get()