-
Notifications
You must be signed in to change notification settings - Fork 938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating existing rest fe tests to real cases #1631
Conversation
@@ -76,7 +76,7 @@ class KyuubiRestFrontendService(override val serverable: Serverable) | |||
|
|||
override def connectionUrl: String = { | |||
checkInitialized() | |||
s"${serverAddr.getCanonicalHostName}:$portNum" | |||
s"${serverAddr.getCanonicalHostName}:${connector.getLocalPort}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's another bug here, in this pr, we only fix a bug for port==0
@@ -46,40 +48,29 @@ object RestFrontendTestHelper { | |||
} | |||
} | |||
|
|||
trait RestFrontendTestHelper { | |||
trait RestFrontendTestHelper extends WithKyuubiServer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refine to use a real singleton Kyuubi server for testing
|
||
class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper { | ||
|
||
test("kyuubi REST frontend service basic") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this case is not very necessary as most logic will be verified in RestFrontendTestHelper
response = webTarget.path("api/v1/ping").request().post(null) | ||
assert(405 == response.getStatus) | ||
assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("method not allowed")) | ||
test("swagger ui") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add 2 swagger tests
cc @pan3793 @yanghua @simon824 @cfmcgrady thanks |
} | ||
} | ||
val resp = webTarget.path("/api/v1/ping").request().get() | ||
resp.getStatusInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert the response value(pong
) or status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
@@ -34,88 +34,62 @@ import org.apache.kyuubi.session.SessionHandle | |||
|
|||
class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { | |||
|
|||
test("test open and count session") { | |||
test("test open/close and count session") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the started test
in the character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
val sessions1 = response2.readEntity(classOf[SessionList]) | ||
assert(sessions1.sessionList.nonEmpty) | ||
|
||
// close a opened session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an?
|
||
assert(sessionHandle.protocol.getValue == 1) | ||
assert(sessionHandle.identifier != null) | ||
// close a opened session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an?
assert(200 == response.getStatus) | ||
|
||
val sessionHandle = response.readEntity(classOf[SessionHandle]) | ||
// verify the open session count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened?
val openedSessionCount = response.readEntity(classOf[SessionOpenCount]) | ||
assert(openedSessionCount.openSessionCount == 0) | ||
} | ||
// verify the open session count again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened?
|
||
response = webTarget.path(s"api/v1/operations/$opHandleStr/event") | ||
.request(MediaType.APPLICATION_JSON_TYPE).get() | ||
assert(404 == response.getStatus) | ||
} | ||
|
||
test("test get result set metadata") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the started test
?
assert(405 == response.getStatus) | ||
assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("method not allowed")) | ||
|
||
// send a request but throws a exception on the server side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an exception?
val catalogsHandleStr = getOpHandleStr(OperationType.GET_CATALOGS) | ||
var response = webTarget.path(s"api/v1/operations/$catalogsHandleStr/event") | ||
.request(MediaType.APPLICATION_JSON_TYPE).get() | ||
val operationEvent = response.readEntity(classOf[KyuubiOperationEvent]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
var response = webTarget.path(s"api/v1/operations/$catalogsHandleStr/event") | ||
.request(MediaType.APPLICATION_JSON_TYPE).get() | ||
val operationEvent = response.readEntity(classOf[KyuubiOperationEvent]) | ||
assert(200 == response.getStatus) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to checkOpState
?
val statementHandleStr = getOpHandleStr(OperationType.EXECUTE_STATEMENT) | ||
response = webTarget.path(s"api/v1/operations/$statementHandleStr/event") | ||
.request(MediaType.APPLICATION_JSON_TYPE).get() | ||
val statementEvent = response.readEntity(classOf[KyuubiOperationEvent]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
operationHandle = response.readEntity(classOf[OperationHandle]) | ||
assert(operationHandle.typ == OperationType.GET_COLUMNS) | ||
|
||
var getFunctionsReq = GetFunctionsRequest("default", "default", "default") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: var -> val
.request(MediaType.APPLICATION_JSON_TYPE) | ||
.post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE)) | ||
assert(200 == response.getStatus) | ||
var operationHandle = response.readEntity(classOf[OperationHandle]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: var -> val
Codecov Report
@@ Coverage Diff @@
## master #1631 +/- ##
============================================
+ Coverage 58.32% 58.85% +0.52%
Complexity 164 164
============================================
Files 260 260
Lines 12930 12932 +2
Branches 1633 1633
============================================
+ Hits 7542 7611 +69
+ Misses 4756 4685 -71
- Partials 632 636 +4
Continue to review full report at Codecov.
|
|
||
override def afterAll(): Unit = { | ||
restApiBaseSuite.tearDown() | ||
server.stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary server.stop()
?
thanks, merged to master |
Why are the changes needed?
In this PR, we target the existing UTs from a noop server to a real shared Kyuubi server.
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 locally before make a pull request