This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.7 by this push:
new 8ef443639 [KYUUBI #4978] Fix flaky test: close expired operations
8ef443639 is described below
commit 8ef443639415df5866af2a9e8c4df20502fabab1
Author: Cheng Pan <[email protected]>
AuthorDate: Mon Jun 19 11:54:41 2023 +0800
[KYUUBI #4978] Fix flaky test: close expired operations
### _Why are the changes needed?_
https://github.com/apache/kyuubi/actions/runs/5302176227/jobs/9596926968
```
- close expired operations *** FAILED ***
The code passed to eventually never returned normally. Attempted 70 times
over 1.00037702345 minutes. Last failure message: 1687069174227 was not greater
than 1687069174227. (TFrontendServiceSuite.scala:540)
```
Key change is
from
```
assert(session.lastIdleTime > lastAccessTime)
```
to
```
assert(lastAccessTime <= session.lastIdleTime)
```
because there are updated nearly at the same time.
```
private def release(userAccess: Boolean): Unit = {
if (userAccess) {
_lastAccessTime = System.currentTimeMillis
}
if (opHandleSet.isEmpty) {
_lastIdleTime = System.currentTimeMillis
}
}
```
This PR also changes some assertion statements from `assert(actual ==
expected)` to `assert(actual === expected)`, the former is Scala assert syntax,
the latter is scalatest method
### _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
Closes #4978 from pan3793/test.
Closes #4978
84dd8334d [Cheng Pan] nit
565b9c0b4 [Cheng Pan] Fix flaky test: close expired operations
Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit 688b0f23bc7028afa1e656a09e63b7af1e9dd1c3)
Signed-off-by: Cheng Pan <[email protected]>
---
.../kyuubi/service/TFrontendServiceSuite.scala | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git
a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/TFrontendServiceSuite.scala
b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/TFrontendServiceSuite.scala
index 6d8c5d71d..91bd3a264 100644
---
a/kyuubi-common/src/test/scala/org/apache/kyuubi/service/TFrontendServiceSuite.scala
+++
b/kyuubi-common/src/test/scala/org/apache/kyuubi/service/TFrontendServiceSuite.scala
@@ -124,7 +124,7 @@ class TFrontendServiceSuite extends KyuubiFunSuite {
val resp = client.OpenSession(req)
val handle = resp.getSessionHandle
assert(handle != null)
- assert(resp.getStatus.getStatusCode == TStatusCode.SUCCESS_STATUS)
+ assert(resp.getStatus.getStatusCode === TStatusCode.SUCCESS_STATUS)
req.setConfiguration(Map("kyuubi.test.should.fail" -> "true").asJava)
val resp1 = client.OpenSession(req)
@@ -514,41 +514,39 @@ class TFrontendServiceSuite extends KyuubiFunSuite {
test("close expired operations") {
withSessionHandle { (client, handle) =>
- val req = new TCancelOperationReq()
- val req1 = new TGetSchemasReq(handle)
- val resp1 = client.GetSchemas(req1)
+ val req = new TGetSchemasReq(handle)
+ val resp = client.GetSchemas(req)
val sessionManager = server.backendService.sessionManager
val session = sessionManager
.getSession(SessionHandle(handle))
.asInstanceOf[AbstractSession]
var lastAccessTime = session.lastAccessTime
- assert(sessionManager.getOpenSessionCount == 1)
+ assert(sessionManager.getOpenSessionCount === 1)
assert(session.lastIdleTime > 0)
- resp1.getOperationHandle
- req.setOperationHandle(resp1.getOperationHandle)
- val resp2 = client.CancelOperation(req)
- assert(resp2.getStatus.getStatusCode === TStatusCode.SUCCESS_STATUS)
- assert(sessionManager.getOpenSessionCount == 1)
- assert(session.lastIdleTime == 0)
+ val cancelOpReq = new TCancelOperationReq(resp.getOperationHandle)
+ val cancelOpResp = client.CancelOperation(cancelOpReq)
+ assert(cancelOpResp.getStatus.getStatusCode ===
TStatusCode.SUCCESS_STATUS)
+ assert(sessionManager.getOpenSessionCount === 1)
+ assert(session.lastIdleTime === 0)
eventually(timeout(Span(60, Seconds)), interval(Span(1, Seconds))) {
assert(lastAccessTime < session.lastAccessTime)
}
lastAccessTime = session.lastAccessTime
eventually(timeout(Span(60, Seconds)), interval(Span(1, Seconds))) {
- assert(session.lastIdleTime > lastAccessTime)
+ assert(lastAccessTime <= session.lastIdleTime)
}
info("operation is terminated")
- assert(lastAccessTime == session.lastAccessTime)
- assert(sessionManager.getOpenSessionCount == 1)
+ assert(lastAccessTime === session.lastAccessTime)
+ assert(sessionManager.getOpenSessionCount === 1)
eventually(timeout(Span(60, Seconds)), interval(Span(1, Seconds))) {
assert(session.lastAccessTime > lastAccessTime)
}
- assert(sessionManager.getOpenSessionCount == 0)
+ assert(sessionManager.getOpenSessionCount === 0)
}
}
@@ -564,7 +562,7 @@ class TFrontendServiceSuite extends KyuubiFunSuite {
Map(
"session.engine.spark.main.resource" -> "org.apahce.kyuubi.test",
"session.check.interval" -> "10000"))
- assert(conf.size == 1)
- assert(conf("session.check.interval") == "10000")
+ assert(conf.size === 1)
+ assert(conf("session.check.interval") === "10000")
}
}