Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Dec 27, 2021

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

@yaooqinn yaooqinn changed the title Migrating existing rest fe test to real cases Migrating existing rests fe test to real cases Dec 27, 2021
@@ -76,7 +76,7 @@ class KyuubiRestFrontendService(override val serverable: Serverable)

override def connectionUrl: String = {
checkInitialized()
s"${serverAddr.getCanonicalHostName}:$portNum"
s"${serverAddr.getCanonicalHostName}:${connector.getLocalPort}"
Copy link
Member Author

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 {
Copy link
Member Author

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") {
Copy link
Member Author

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") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add 2 swagger tests

@yaooqinn
Copy link
Member Author

cc @pan3793 @yanghua @simon824 @cfmcgrady thanks

@yaooqinn yaooqinn closed this Dec 27, 2021
@yaooqinn yaooqinn reopened this Dec 27, 2021
@yaooqinn yaooqinn closed this Dec 27, 2021
@yaooqinn yaooqinn reopened this Dec 27, 2021
}
}
val resp = webTarget.path("/api/v1/ping").request().get()
resp.getStatusInfo
Copy link
Contributor

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?

Copy link
Member Author

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") {
Copy link
Contributor

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?

Copy link
Contributor

@yanghua yanghua left a 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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") {
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an exception?

@yaooqinn yaooqinn changed the title Migrating existing rests fe test to real cases Migrating existing rest fe tests to real cases Dec 28, 2021
@yaooqinn yaooqinn requested a review from yanghua December 28, 2021 04:06
@yaooqinn yaooqinn self-assigned this Dec 28, 2021
@yaooqinn yaooqinn added the test label Dec 28, 2021
@yaooqinn yaooqinn added this to the v1.5.0 milestone Dec 28, 2021
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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never be called.

Copy link
Member Author

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)
Copy link
Contributor

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])
Copy link
Contributor

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")
Copy link
Contributor

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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: var -> val

@codecov-commenter
Copy link

codecov-commenter commented Dec 28, 2021

Codecov Report

Merging #1631 (c0da809) into master (2af105a) will increase coverage by 0.52%.
The diff coverage is 71.42%.

❗ Current head c0da809 differs from pull request most recent head 2726ab4. Consider uploading reports for the commit 2726ab4 to get more accurate results
Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
...apache/kyuubi/server/api/v1/SessionsResource.scala 77.17% <66.66%> (+0.50%) ⬆️
...ache/kyuubi/server/KyuubiRestFrontendService.scala 86.79% <100.00%> (ø)
.../org/apache/kyuubi/operation/KyuubiOperation.scala 64.78% <0.00%> (-9.86%) ⬇️
...ala/org/apache/kyuubi/operation/LaunchEngine.scala 86.36% <0.00%> (ø)
...org/apache/kyuubi/operation/ExecuteStatement.scala 87.35% <0.00%> (ø)
.../scala/org/apache/kyuubi/server/KyuubiServer.scala 63.29% <0.00%> (+2.53%) ⬆️
...ache/kyuubi/server/api/v1/OperationsResource.scala 73.46% <0.00%> (+8.16%) ⬆️
.../apache/kyuubi/client/KyuubiSyncThriftClient.scala 94.95% <0.00%> (+11.76%) ⬆️
...ache/kyuubi/operation/KyuubiOperationManager.scala 95.00% <0.00%> (+12.50%) ⬆️
...pache/kyuubi/server/BackendServiceTimeMetric.scala 100.00% <0.00%> (+16.21%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2af105a...2726ab4. Read the comment docs.


override def afterAll(): Unit = {
restApiBaseSuite.tearDown()
server.stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary server.stop()?

@yaooqinn yaooqinn closed this in e1587ee Dec 28, 2021
@yaooqinn yaooqinn deleted the resttest branch December 28, 2021 09:17
@yaooqinn
Copy link
Member Author

thanks, merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants