This is an automated email from the ASF dual-hosted git repository.
yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new b7832330b [KYUUBI #5600] Fix flaky test SessionsResourceSuite
b7832330b is described below
commit b7832330b7a6a23d9eb9cacd070a14e837fa76ad
Author: davidyuan <[email protected]>
AuthorDate: Mon Nov 13 22:57:24 2023 +0800
[KYUUBI #5600] Fix flaky test SessionsResourceSuite
### _Why are the changes needed?_
Because the server process is async, so when we test in ci or local,
because our test operation is synchronize, but the server process is async, it
will random failed, so we need to fix the problem to make sure the random test
not happend.
In the SessionsResourceSuite, there may have 2 random test case failed
```
SessionsResourceSuite:
- open/close and count session *** FAILED ***
1 equaled 1, but 0 did not equal 1 (SessionsResourceSuite.scala:65)
- getSessionList *** FAILED ***
List(Map("duration" -> 0, "sessionType" -> "INTERACTIVE", "identifier" ->
"96ca05ee-ecb1-49cd-a2e4-66cbf49ed343", "createTime" -> 1698822938391, "ipAddr"
-> "127.0.0.1", "exception" -> "", "kyuubiInstance" -> "localhost:35415",
"idleTime" -> 78, "engineId" -> "", "conf" -> Map("kyuubi.session.real.user" ->
"anonymous", "testConfig" -> "testValue", "kyuubi.client.ipAddress" ->
"127.0.0.1", "kyuubi.session.connection.url" -> "localhost:35415",
"kyuubi.server.ipAddress" -> "localhost") [...]
```
1. open/close session: when we open session, the server will process in
async,it may complete or error quickly, so we can not make sure the active
thread count must equal to 1, we need use 1 or 0 to test
2. list sessions: in the test case, we will execute delete sessions
operation, then assert, but if we assert quickly and the session not delete
complete, it will failed, so we need sleep 3 seconds to make the delete
operation async complete
close #5600
### _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
- [x] [Run
test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
locally before make a pull request
### _Was this patch authored or co-authored using generative AI tooling?_
No
Closes #5675 from davidyuan1223/fix_test_bug.
Closes #5600
6aa234c68 [david yuan] Update SessionsResourceSuite.scala
f52ddb9fe [davidyuan] fix SessionsResourceSuite test case bug
6ae539542 [davidyuan] fix SessionsResourceSuite test case bug
f3b4c4dc1 [davidyuan] fix SessionsResourceSuite test case bug
2d6a5ad81 [davidyuan] fix SessionsResourceSuite test case bug
2825eebcd [davidyuan] fix SessionsResourceSuite test case bug
adc7031cd [davidyuan] fix SessionsResourceSuite test case bug
Lead-authored-by: davidyuan <[email protected]>
Co-authored-by: david yuan <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
---
.../kyuubi/server/api/v1/SessionsResourceSuite.scala | 20 ++++++++++++++------
1 file changed, 14 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 b993789ba..af49598fe 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") {