You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/12/27 12:50:16 UTC

[GitHub] [incubator-kyuubi] yaooqinn opened a new pull request #1631: Migrating existing rest fe test to real cases

yaooqinn opened a new pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631


   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
     2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you add a feature, you can talk about the use case of it.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### _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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001868570


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1631](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (80e1404) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/2af105a417342c4e51ec550df7259d90e1fe341e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2af105a) will **increase** coverage by `0.50%`.
   > The diff coverage is `71.42%`.
   
   > :exclamation: Current head 80e1404 differs from pull request most recent head 5d12f70. Consider uploading reports for the commit 5d12f70 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1631      +/-   ##
   ============================================
   + Coverage     58.32%   58.83%   +0.50%     
     Complexity      164      164              
   ============================================
     Files           260      260              
     Lines         12930    12932       +2     
     Branches       1633     1633              
   ============================================
   + Hits           7542     7608      +66     
   + Misses         4756     4686      -70     
   - Partials        632      638       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/kyuubi/server/api/v1/SessionsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL1Nlc3Npb25zUmVzb3VyY2Uuc2NhbGE=) | `77.17% <66.66%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/server/KyuubiRestFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpUmVzdEZyb250ZW5kU2VydmljZS5zY2FsYQ==) | `86.79% <100.00%> (ø)` | |
   | [.../org/apache/kyuubi/operation/KyuubiOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uLnNjYWxh) | `64.78% <0.00%> (-9.86%)` | :arrow_down: |
   | [...he/kyuubi/engine/spark/repl/KyuubiSparkILoop.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9yZXBsL0t5dXViaVNwYXJrSUxvb3Auc2NhbGE=) | `90.16% <0.00%> (-3.28%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/operation/LaunchEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vTGF1bmNoRW5naW5lLnNjYWxh) | `86.36% <0.00%> (ø)` | |
   | [...org/apache/kyuubi/operation/ExecuteStatement.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vRXhlY3V0ZVN0YXRlbWVudC5zY2FsYQ==) | `87.35% <0.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `63.29% <0.00%> (+2.53%)` | :arrow_up: |
   | [...ache/kyuubi/server/api/v1/OperationsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL09wZXJhdGlvbnNSZXNvdXJjZS5zY2FsYQ==) | `73.46% <0.00%> (+8.16%)` | :arrow_up: |
   | [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `92.50% <0.00%> (+10.00%)` | :arrow_up: |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `94.95% <0.00%> (+11.76%)` | :arrow_up: |
   | ... and [5 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2af105a...5d12f70](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775492841



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/RestFrontendTestHelper.scala
##########
@@ -46,40 +48,29 @@ object RestFrontendTestHelper {
   }
 }
 
-trait RestFrontendTestHelper {
+trait RestFrontendTestHelper extends WithKyuubiServer {

Review comment:
       refine to use a real singleton Kyuubi server for testing




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] cfmcgrady commented on a change in pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
cfmcgrady commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775720557



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
##########
@@ -17,116 +17,116 @@
 
 package org.apache.kyuubi.server.api.v1
 
-import javax.ws.rs.client.{Entity, WebTarget}
+import javax.ws.rs.client.Entity
 import javax.ws.rs.core.MediaType
 
 import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
+import org.scalatest.concurrent.PatienceConfiguration.Timeout
+import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
 import org.apache.kyuubi.events.KyuubiOperationEvent
-import org.apache.kyuubi.operation.{ExecuteStatement, GetCatalogs, OperationState, OperationType}
+import org.apache.kyuubi.operation.{OperationState, OperationType}
+import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
 import org.apache.kyuubi.operation.OperationType.OperationType
-import org.apache.kyuubi.server.KyuubiRestFrontendService
 
 class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test get an operation event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val catalogsHandleStr = getOpHandleStr(fe, 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])
-      assert(200 == response.getStatus)
-      assert(operationEvent.state == OperationState.INITIALIZED.name())
-
-      val statementHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-      response = webTarget.path(s"api/v1/operations/$statementHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val statementEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(200 == response.getStatus)
-      assert(statementEvent.state == OperationState.INITIALIZED.name())
-
-      // Invalid operationHandleStr
-      val invalidOperationHandle =
-        statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
-      response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+  test("get an operation event") {
+    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])
+    assert(200 == response.getStatus)
+    checkOpState(catalogsHandleStr, FINISHED)
+
+    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])

Review comment:
       ditto

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
##########
@@ -17,116 +17,116 @@
 
 package org.apache.kyuubi.server.api.v1
 
-import javax.ws.rs.client.{Entity, WebTarget}
+import javax.ws.rs.client.Entity
 import javax.ws.rs.core.MediaType
 
 import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
+import org.scalatest.concurrent.PatienceConfiguration.Timeout
+import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
 import org.apache.kyuubi.events.KyuubiOperationEvent
-import org.apache.kyuubi.operation.{ExecuteStatement, GetCatalogs, OperationState, OperationType}
+import org.apache.kyuubi.operation.{OperationState, OperationType}
+import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
 import org.apache.kyuubi.operation.OperationType.OperationType
-import org.apache.kyuubi.server.KyuubiRestFrontendService
 
 class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test get an operation event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val catalogsHandleStr = getOpHandleStr(fe, 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])
-      assert(200 == response.getStatus)
-      assert(operationEvent.state == OperationState.INITIALIZED.name())
-
-      val statementHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-      response = webTarget.path(s"api/v1/operations/$statementHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val statementEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(200 == response.getStatus)
-      assert(statementEvent.state == OperationState.INITIALIZED.name())
-
-      // Invalid operationHandleStr
-      val invalidOperationHandle =
-        statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
-      response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+  test("get an operation event") {
+    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])

Review comment:
       never be called.

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
##########
@@ -17,116 +17,116 @@
 
 package org.apache.kyuubi.server.api.v1
 
-import javax.ws.rs.client.{Entity, WebTarget}
+import javax.ws.rs.client.Entity
 import javax.ws.rs.core.MediaType
 
 import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
+import org.scalatest.concurrent.PatienceConfiguration.Timeout
+import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
 import org.apache.kyuubi.events.KyuubiOperationEvent
-import org.apache.kyuubi.operation.{ExecuteStatement, GetCatalogs, OperationState, OperationType}
+import org.apache.kyuubi.operation.{OperationState, OperationType}
+import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
 import org.apache.kyuubi.operation.OperationType.OperationType
-import org.apache.kyuubi.server.KyuubiRestFrontendService
 
 class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test get an operation event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val catalogsHandleStr = getOpHandleStr(fe, 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])
-      assert(200 == response.getStatus)
-      assert(operationEvent.state == OperationState.INITIALIZED.name())
-
-      val statementHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-      response = webTarget.path(s"api/v1/operations/$statementHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val statementEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(200 == response.getStatus)
-      assert(statementEvent.state == OperationState.INITIALIZED.name())
-
-      // Invalid operationHandleStr
-      val invalidOperationHandle =
-        statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
-      response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+  test("get an operation event") {
+    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])
+    assert(200 == response.getStatus)

Review comment:
       move to `checkOpState`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775493593



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
##########
@@ -17,80 +17,39 @@
 
 package org.apache.kyuubi.server
 
-import java.util.Locale
+import org.apache.kyuubi.RestFrontendTestHelper
 
-import scala.io.Source
-
-import org.scalatest.time.SpanSugar._
-
-import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
-import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.NoopRestFrontendServer
-import org.apache.kyuubi.service.ServiceState._
-
-class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
-
-  test("kyuubi REST frontend service basic") {
-    val server = new NoopRestFrontendServer()
-    server.stop()
-    val conf = KyuubiConf()
-    assert(server.getServices.isEmpty)
-    assert(server.getServiceState === LATENT)
-    val e = intercept[IllegalStateException](server.frontendServices.head.connectionUrl)
-    assert(e.getMessage startsWith "Illegal Service State: LATENT")
-    assert(server.getConf === null)
-
-    server.initialize(conf)
-    assert(server.getServiceState === INITIALIZED)
-    val frontendService = server.frontendServices.head
-    assert(frontendService.getServiceState == INITIALIZED)
-    assert(server.frontendServices.head.connectionUrl.split(":").length === 2)
-    assert(server.getConf === conf)
-    assert(server.getStartTime === 0)
-    server.stop()
-
-    server.start()
-    assert(server.getServiceState === STARTED)
-    assert(frontendService.getServiceState == STARTED)
-    assert(server.getStartTime !== 0)
-
-    server.stop()
-    assert(server.getServiceState === STOPPED)
-    assert(frontendService.getServiceState == STOPPED)
-    server.stop()
-  }
+class KyuubiRestFrontendServiceSuite extends RestFrontendTestHelper {
 
   test("kyuubi REST frontend service http basic") {
-    withKyuubiRestServer { (_, host, port, _) =>
-      eventually(timeout(10.seconds), interval(50.milliseconds)) {
-        val html = {
-          // noinspection HttpUrlsUsage
-          val s = Source.fromURL(s"http://$host:$port/api/v1/ping")
-          val str = s.mkString
-          s.close()
-          str
-        }
-        assert(html.toLowerCase(Locale.ROOT).equals("pong"))
-      }
-    }
+    val resp = webTarget.path("/api/v1/ping").request().get()
+    resp.getStatusInfo
   }
 
   test("test error and exception response") {
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      // send a not exists request
-      var response = webTarget.path("api/v1/pong").request().get()
-      assert(404 == response.getStatus)
-      assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("not found"))
+    // send a not exists request
+    var response = webTarget.path("api/v1/pong").request().get()
+    assert(404 == response.getStatus)
+    assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("not found"))
+
+    // send a exists request but wrong http method
+    response = webTarget.path("api/v1/ping").request().post(null)
+    assert(405 == response.getStatus)
+    assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("method not allowed"))
+
+    // send a request but throws a exception on the server side
+    response = webTarget.path("api/v1/exception").request().get()
+    assert(500 == response.getStatus)
+    assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("server error"))
+  }
 
-      // send a exists request but wrong http method
-      response = webTarget.path("api/v1/ping").request().post(null)
-      assert(405 == response.getStatus)
-      assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("method not allowed"))
+  test("swagger ui") {

Review comment:
       add 2 swagger tests




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] pan3793 commented on a change in pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775778378



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/RestFrontendTestHelper.scala
##########
@@ -46,40 +48,29 @@ object RestFrontendTestHelper {
   }
 }
 
-trait RestFrontendTestHelper {
+trait RestFrontendTestHelper extends WithKyuubiServer {
 
-  val restFrontendHost: String = "localhost"
-  val restFrontendPort: Int = KyuubiConf().get(KyuubiConf.FRONTEND_REST_BIND_PORT)
+  override protected val conf: KyuubiConf = KyuubiConf()
 
-  def withKyuubiRestServer(
-      f: (KyuubiRestFrontendService, String, Int, WebTarget) => Unit): Unit = {
+  override protected val frontendProtocols: Seq[FrontendProtocol] =
+    FrontendProtocols.REST :: Nil
 
-    val server = new NoopRestFrontendServer()
-    server.stop()
-    val conf = KyuubiConf()
-    conf.set(KyuubiConf.FRONTEND_REST_BIND_HOST, Some(restFrontendHost))
-
-    server.initialize(conf)
-    server.start()
+  private val restApiBaseSuite = new RestApiBaseSuite
 
-    val restApiBaseSuite = new RestApiBaseSuite
+  override def beforeAll(): Unit = {
+    super.beforeAll()
     restApiBaseSuite.setUp()
-    // noinspection HttpUrlsUsage
-    val baseUri = UriBuilder
-      .fromUri(s"http://$restFrontendHost/")
-      .port(restFrontendPort)
-      .build()
-    val webTarget = restApiBaseSuite.client.target(baseUri)
-
-    try {
-      f(
-        server.frontendServices.head,
-        conf.get(KyuubiConf.FRONTEND_REST_BIND_HOST).get,
-        restFrontendPort,
-        webTarget)
-    } finally {
-      restApiBaseSuite.tearDown()
-      server.stop()
-    }
   }
+
+  override def afterAll(): Unit = {
+    restApiBaseSuite.tearDown()
+    server.stop()

Review comment:
       unnecessary `server.stop()`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001868570


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1631](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (80e1404) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/2af105a417342c4e51ec550df7259d90e1fe341e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2af105a) will **increase** coverage by `0.50%`.
   > The diff coverage is `71.42%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1631      +/-   ##
   ============================================
   + Coverage     58.32%   58.83%   +0.50%     
     Complexity      164      164              
   ============================================
     Files           260      260              
     Lines         12930    12932       +2     
     Branches       1633     1633              
   ============================================
   + Hits           7542     7608      +66     
   + Misses         4756     4686      -70     
   - Partials        632      638       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/kyuubi/server/api/v1/SessionsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL1Nlc3Npb25zUmVzb3VyY2Uuc2NhbGE=) | `77.17% <66.66%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/server/KyuubiRestFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpUmVzdEZyb250ZW5kU2VydmljZS5zY2FsYQ==) | `86.79% <100.00%> (ø)` | |
   | [.../org/apache/kyuubi/operation/KyuubiOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uLnNjYWxh) | `64.78% <0.00%> (-9.86%)` | :arrow_down: |
   | [...he/kyuubi/engine/spark/repl/KyuubiSparkILoop.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9yZXBsL0t5dXViaVNwYXJrSUxvb3Auc2NhbGE=) | `90.16% <0.00%> (-3.28%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/operation/LaunchEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vTGF1bmNoRW5naW5lLnNjYWxh) | `86.36% <0.00%> (ø)` | |
   | [...org/apache/kyuubi/operation/ExecuteStatement.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vRXhlY3V0ZVN0YXRlbWVudC5zY2FsYQ==) | `87.35% <0.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `63.29% <0.00%> (+2.53%)` | :arrow_up: |
   | [...ache/kyuubi/server/api/v1/OperationsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL09wZXJhdGlvbnNSZXNvdXJjZS5zY2FsYQ==) | `73.46% <0.00%> (+8.16%)` | :arrow_up: |
   | [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `92.50% <0.00%> (+10.00%)` | :arrow_up: |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `94.95% <0.00%> (+11.76%)` | :arrow_up: |
   | ... and [5 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2af105a...80e1404](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775492525



##########
File path: kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
##########
@@ -76,7 +76,7 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
 
   override def connectionUrl: String = {
     checkInitialized()
-    s"${serverAddr.getCanonicalHostName}:$portNum"
+    s"${serverAddr.getCanonicalHostName}:${connector.getLocalPort}"

Review comment:
       there's another bug here, in this pr, we only fix a bug for port==0




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yanghua commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775531999



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
##########
@@ -17,80 +17,39 @@
 
 package org.apache.kyuubi.server
 
-import java.util.Locale
+import org.apache.kyuubi.RestFrontendTestHelper
 
-import scala.io.Source
-
-import org.scalatest.time.SpanSugar._
-
-import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
-import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.NoopRestFrontendServer
-import org.apache.kyuubi.service.ServiceState._
-
-class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
-
-  test("kyuubi REST frontend service basic") {
-    val server = new NoopRestFrontendServer()
-    server.stop()
-    val conf = KyuubiConf()
-    assert(server.getServices.isEmpty)
-    assert(server.getServiceState === LATENT)
-    val e = intercept[IllegalStateException](server.frontendServices.head.connectionUrl)
-    assert(e.getMessage startsWith "Illegal Service State: LATENT")
-    assert(server.getConf === null)
-
-    server.initialize(conf)
-    assert(server.getServiceState === INITIALIZED)
-    val frontendService = server.frontendServices.head
-    assert(frontendService.getServiceState == INITIALIZED)
-    assert(server.frontendServices.head.connectionUrl.split(":").length === 2)
-    assert(server.getConf === conf)
-    assert(server.getStartTime === 0)
-    server.stop()
-
-    server.start()
-    assert(server.getServiceState === STARTED)
-    assert(frontendService.getServiceState == STARTED)
-    assert(server.getStartTime !== 0)
-
-    server.stop()
-    assert(server.getServiceState === STOPPED)
-    assert(frontendService.getServiceState == STOPPED)
-    server.stop()
-  }
+class KyuubiRestFrontendServiceSuite extends RestFrontendTestHelper {
 
   test("kyuubi REST frontend service http basic") {
-    withKyuubiRestServer { (_, host, port, _) =>
-      eventually(timeout(10.seconds), interval(50.milliseconds)) {
-        val html = {
-          // noinspection HttpUrlsUsage
-          val s = Source.fromURL(s"http://$host:$port/api/v1/ping")
-          val str = s.mkString
-          s.close()
-          str
-        }
-        assert(html.toLowerCase(Locale.ROOT).equals("pong"))
-      }
-    }
+    val resp = webTarget.path("/api/v1/ping").request().get()
+    resp.getStatusInfo

Review comment:
       assert the response value(`pong`) or status?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn closed pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yanghua commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775541617



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -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") {

Review comment:
       Remove the started `test` in the character?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775727980



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
##########
@@ -17,116 +17,116 @@
 
 package org.apache.kyuubi.server.api.v1
 
-import javax.ws.rs.client.{Entity, WebTarget}
+import javax.ws.rs.client.Entity
 import javax.ws.rs.core.MediaType
 
 import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
+import org.scalatest.concurrent.PatienceConfiguration.Timeout
+import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
 import org.apache.kyuubi.events.KyuubiOperationEvent
-import org.apache.kyuubi.operation.{ExecuteStatement, GetCatalogs, OperationState, OperationType}
+import org.apache.kyuubi.operation.{OperationState, OperationType}
+import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
 import org.apache.kyuubi.operation.OperationType.OperationType
-import org.apache.kyuubi.server.KyuubiRestFrontendService
 
 class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test get an operation event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val catalogsHandleStr = getOpHandleStr(fe, 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])
-      assert(200 == response.getStatus)
-      assert(operationEvent.state == OperationState.INITIALIZED.name())
-
-      val statementHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-      response = webTarget.path(s"api/v1/operations/$statementHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val statementEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(200 == response.getStatus)
-      assert(statementEvent.state == OperationState.INITIALIZED.name())
-
-      // Invalid operationHandleStr
-      val invalidOperationHandle =
-        statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
-      response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+  test("get an operation event") {
+    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])

Review comment:
       nice catch




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001868570


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1631](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c0da809) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/2af105a417342c4e51ec550df7259d90e1fe341e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2af105a) will **increase** coverage by `0.52%`.
   > The diff coverage is `71.42%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             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](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/kyuubi/server/api/v1/SessionsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL1Nlc3Npb25zUmVzb3VyY2Uuc2NhbGE=) | `77.17% <66.66%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/server/KyuubiRestFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpUmVzdEZyb250ZW5kU2VydmljZS5zY2FsYQ==) | `86.79% <100.00%> (ø)` | |
   | [.../org/apache/kyuubi/operation/KyuubiOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uLnNjYWxh) | `64.78% <0.00%> (-9.86%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/operation/LaunchEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vTGF1bmNoRW5naW5lLnNjYWxh) | `86.36% <0.00%> (ø)` | |
   | [...org/apache/kyuubi/operation/ExecuteStatement.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vRXhlY3V0ZVN0YXRlbWVudC5zY2FsYQ==) | `87.35% <0.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `63.29% <0.00%> (+2.53%)` | :arrow_up: |
   | [...ache/kyuubi/server/api/v1/OperationsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL09wZXJhdGlvbnNSZXNvdXJjZS5zY2FsYQ==) | `73.46% <0.00%> (+8.16%)` | :arrow_up: |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `94.95% <0.00%> (+11.76%)` | :arrow_up: |
   | [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `95.00% <0.00%> (+12.50%)` | :arrow_up: |
   | [...pache/kyuubi/server/BackendServiceTimeMetric.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvQmFja2VuZFNlcnZpY2VUaW1lTWV0cmljLnNjYWxh) | `100.00% <0.00%> (+16.21%)` | :arrow_up: |
   | ... and [4 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2af105a...c0da809](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] cfmcgrady commented on a change in pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
cfmcgrady commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775721748



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -34,315 +32,258 @@ import org.apache.kyuubi.session.SessionHandle
 
 class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test open and count session") {
+  test("open/close and count session") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    assert(200 == response.getStatus)
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
 
-      assert(200 == response.getStatus)
+    assert(sessionHandle.protocol.getValue == 1)
+    assert(sessionHandle.identifier != null)
 
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val statistic = webTarget.path("api/v1/sessions/execPool/statistic").request().get()
+    val execPoolStatistic1 = statistic.readEntity(classOf[ExecPoolStatistic])
+    assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount.openSessionCount == 1)
 
-      // verify the open session count
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 1)
-    }
+    // close an opened session
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
+    assert(200 == response.getStatus)
+
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount2 = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount2.openSessionCount == 0)
   }
 
-  test("test close and count session") {
+  test("getSessionList") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      assert(200 == response.getStatus)
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
-
-      // close a opened session
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
-      assert(200 == response.getStatus)
-
-      // verify the open session count again
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 0)
-    }
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    // get session list
+    var response2 = webTarget.path("api/v1/sessions").request().get()
+    assert(200 == response2.getStatus)
+    val sessions1 = response2.readEntity(classOf[SessionList])
+    assert(sessions1.sessionList.nonEmpty)
+
+    // close an opened session
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").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[SessionList])
+    assert(sessions2.sessionList.isEmpty)
   }
 
-  test("test execPoolStatistic") {
-    withKyuubiRestServer { (restFe, _, _, webTarget) =>
-      val sessionManager = restFe.be.sessionManager
-      val future = sessionManager.submitBackgroundOperation(() => Thread.sleep(1000))
-
-      // verify the exec pool statistic
-      var response = webTarget.path("api/v1/sessions/execPool/statistic").request().get()
-      val execPoolStatistic1 = response.readEntity(classOf[ExecPoolStatistic])
-      assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
-
-      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()
-      val execPoolStatistic3 = response.readEntity(classOf[ExecPoolStatistic])
-      assert(execPoolStatistic3.execPoolSize == 0 && execPoolStatistic3.execPoolActiveCount == 0)
-    }
-  }
-
-  test("test getSessionList") {
-    val requestObj = SessionOpenRequest(
-      1,
+  test("get session event") {
+    val sessionManager = fe.be.sessionManager
+    val sessionHandle = sessionManager.openSession(
+      HIVE_CLI_SERVICE_PROTOCOL_V2,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      // get session list
-      var response2 = webTarget.path("api/v1/sessions").request().get()
-      assert(200 == response2.getStatus)
-      val sessions1 = response2.readEntity(classOf[SessionList])
-      assert(sessions1.sessionList.nonEmpty)
-
-      // close a opened session
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").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[SessionList])
-      assert(sessions2.sessionList.isEmpty)
-    }
-  }
+    KyuubiServer.kyuubiServer = new KyuubiServer
+    KyuubiServer.kyuubiServer.initialize(KyuubiConf())
+
+    // get session event
+    var response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
+    assert(200 == response.getStatus)
+    val sessions = response.readEntity(classOf[KyuubiSessionEvent])
+    assert(sessions.conf("testConfig").equals("testValue"))
 
-  test("test get session event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val sessionManager = fe.be.sessionManager
-      val sessionHandle = sessionManager.openSession(
-        HIVE_CLI_SERVICE_PROTOCOL_V2,
-        "admin",
-        "123456",
-        "localhost",
-        Map("testConfig" -> "testValue"))
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      KyuubiServer.kyuubiServer = new KyuubiServer
-      KyuubiServer.kyuubiServer.initialize(KyuubiConf())
-
-      // get session event
-      var response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
-      assert(200 == response.getStatus)
-      val sessions = response.readEntity(classOf[KyuubiSessionEvent])
-      assert(sessions.conf("testConfig").equals("testValue"))
-
-      // close a opened session
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
-      assert(200 == response.getStatus)
-
-      // get session detail again
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
-      assert(404 == response.getStatus)
-    }
+    // close an opened session
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
+    assert(200 == response.getStatus)
+
+    // get session detail again
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
+    assert(404 == response.getStatus)
   }
 
-  test("test get infoType") {
+  test("get infoType") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response: Response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/13")
-        .request().get()
-      assert(200 == response.getStatus)
-      val sessions = response.readEntity(classOf[InfoDetail])
-      assert(sessions.infoType.equals("CLI_SERVER_NAME") &&
-        sessions.infoValue.equals("Apache Kyuubi (Incubating)"))
-      // Invalid sessionHandleStr
-      val handle = "b88d6b56-d200-4bb6-bf0a-5da0ea572e11|0c4aad4e-ccf7-4abd-9305-943d4bfd2d9a|0"
-      response = webTarget.path(s"api/v1/sessions/$handle/info/13").request().get()
-      assert(404 == response.getStatus)
-      response = webTarget.path(s"api/v1/sessions/0/info/13").request().get()
-      assert(404 == response.getStatus)
-
-      // Invalid infoType
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/0")
-        .request().get()
-      assert(404 == response.getStatus)
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/str")
-        .request().get()
-      assert(404 == response.getStatus)
-    }
+    var response: Response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/13")
+      .request().get()
+    assert(200 == response.getStatus)
+    val sessions = response.readEntity(classOf[InfoDetail])
+    assert(sessions.infoType.equals("CLI_SERVER_NAME") &&
+      sessions.infoValue.equals("Apache Kyuubi (Incubating)"))
+    // Invalid sessionHandleStr
+    val handle = "b88d6b56-d200-4bb6-bf0a-5da0ea572e11|0c4aad4e-ccf7-4abd-9305-943d4bfd2d9a|0"
+    response = webTarget.path(s"api/v1/sessions/$handle/info/13").request().get()
+    assert(404 == response.getStatus)
+    response = webTarget.path(s"api/v1/sessions/0/info/13").request().get()
+    assert(404 == response.getStatus)
+
+    // Invalid infoType
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/0")
+      .request().get()
+    assert(404 == response.getStatus)
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/str")
+      .request().get()
+    assert(404 == response.getStatus)
   }
 
-  test("test submit operation and get operation handle") {
+  test("submit operation and get operation handle") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response: Response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
-
-      val statementReq = StatementRequest("show tables", true, 3000)
-      response = webTarget
-        .path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      var operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.EXECUTE_STATEMENT)
-
-      response = webTarget.path(s"$pathPrefix/operations/typeInfo").request()
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TYPE_INFO)
-
-      response = webTarget.path(s"$pathPrefix/operations/catalogs")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_CATALOGS)
-
-      val getSchemasReq = GetSchemasRequest("default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/schemas")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getSchemasReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_SCHEMAS)
-
-      val tableTypes = new util.ArrayList[String]()
-      val getTablesReq = GetTablesRequest("default", "default", "default", tableTypes)
-      response = webTarget.path(s"$pathPrefix/operations/tables")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getTablesReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TABLES)
-
-      response = webTarget.path(s"$pathPrefix/operations/tableTypes").request()
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TABLE_TYPES)
-
-      val getColumnsReq = GetColumnsRequest("default", "default", "default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/columns")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getColumnsReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_COLUMNS)
-
-      var getFunctionsReq = GetFunctionsRequest("default", "default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/functions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getFunctionsReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_FUNCTIONS)
-    }
+    var response: Response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+
+    val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
+
+    val statementReq = StatementRequest("show tables", true, 3000)
+    response = webTarget
+      .path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    var operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.EXECUTE_STATEMENT)
+
+    response = webTarget.path(s"$pathPrefix/operations/typeInfo").request()
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TYPE_INFO)
+
+    response = webTarget.path(s"$pathPrefix/operations/catalogs")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_CATALOGS)
+
+    val getSchemasReq = GetSchemasRequest("spark_catalog", "default")
+    response = webTarget.path(s"$pathPrefix/operations/schemas")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getSchemasReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_SCHEMAS)
+
+    val tableTypes = new util.ArrayList[String]()
+    val getTablesReq = GetTablesRequest("spark_catalog", "default", "default", tableTypes)
+    response = webTarget.path(s"$pathPrefix/operations/tables")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getTablesReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TABLES)
+
+    response = webTarget.path(s"$pathPrefix/operations/tableTypes").request()
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TABLE_TYPES)
+
+    val getColumnsReq = GetColumnsRequest("spark_catalog", "default", "default", "default")
+    response = webTarget.path(s"$pathPrefix/operations/columns")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getColumnsReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_COLUMNS)
+
+    var getFunctionsReq = GetFunctionsRequest("default", "default", "default")

Review comment:
       nit: `var -> val`

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -34,315 +32,258 @@ import org.apache.kyuubi.session.SessionHandle
 
 class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
-  test("test open and count session") {
+  test("open/close and count session") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    assert(200 == response.getStatus)
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
 
-      assert(200 == response.getStatus)
+    assert(sessionHandle.protocol.getValue == 1)
+    assert(sessionHandle.identifier != null)
 
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val statistic = webTarget.path("api/v1/sessions/execPool/statistic").request().get()
+    val execPoolStatistic1 = statistic.readEntity(classOf[ExecPoolStatistic])
+    assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount.openSessionCount == 1)
 
-      // verify the open session count
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 1)
-    }
+    // close an opened session
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
+    assert(200 == response.getStatus)
+
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount2 = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount2.openSessionCount == 0)
   }
 
-  test("test close and count session") {
+  test("getSessionList") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      assert(200 == response.getStatus)
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
-
-      // close a opened session
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
-      assert(200 == response.getStatus)
-
-      // verify the open session count again
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 0)
-    }
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    // get session list
+    var response2 = webTarget.path("api/v1/sessions").request().get()
+    assert(200 == response2.getStatus)
+    val sessions1 = response2.readEntity(classOf[SessionList])
+    assert(sessions1.sessionList.nonEmpty)
+
+    // close an opened session
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").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[SessionList])
+    assert(sessions2.sessionList.isEmpty)
   }
 
-  test("test execPoolStatistic") {
-    withKyuubiRestServer { (restFe, _, _, webTarget) =>
-      val sessionManager = restFe.be.sessionManager
-      val future = sessionManager.submitBackgroundOperation(() => Thread.sleep(1000))
-
-      // verify the exec pool statistic
-      var response = webTarget.path("api/v1/sessions/execPool/statistic").request().get()
-      val execPoolStatistic1 = response.readEntity(classOf[ExecPoolStatistic])
-      assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
-
-      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()
-      val execPoolStatistic3 = response.readEntity(classOf[ExecPoolStatistic])
-      assert(execPoolStatistic3.execPoolSize == 0 && execPoolStatistic3.execPoolActiveCount == 0)
-    }
-  }
-
-  test("test getSessionList") {
-    val requestObj = SessionOpenRequest(
-      1,
+  test("get session event") {
+    val sessionManager = fe.be.sessionManager
+    val sessionHandle = sessionManager.openSession(
+      HIVE_CLI_SERVICE_PROTOCOL_V2,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      // get session list
-      var response2 = webTarget.path("api/v1/sessions").request().get()
-      assert(200 == response2.getStatus)
-      val sessions1 = response2.readEntity(classOf[SessionList])
-      assert(sessions1.sessionList.nonEmpty)
-
-      // close a opened session
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").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[SessionList])
-      assert(sessions2.sessionList.isEmpty)
-    }
-  }
+    KyuubiServer.kyuubiServer = new KyuubiServer
+    KyuubiServer.kyuubiServer.initialize(KyuubiConf())
+
+    // get session event
+    var response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
+    assert(200 == response.getStatus)
+    val sessions = response.readEntity(classOf[KyuubiSessionEvent])
+    assert(sessions.conf("testConfig").equals("testValue"))
 
-  test("test get session event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val sessionManager = fe.be.sessionManager
-      val sessionHandle = sessionManager.openSession(
-        HIVE_CLI_SERVICE_PROTOCOL_V2,
-        "admin",
-        "123456",
-        "localhost",
-        Map("testConfig" -> "testValue"))
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      KyuubiServer.kyuubiServer = new KyuubiServer
-      KyuubiServer.kyuubiServer.initialize(KyuubiConf())
-
-      // get session event
-      var response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
-      assert(200 == response.getStatus)
-      val sessions = response.readEntity(classOf[KyuubiSessionEvent])
-      assert(sessions.conf("testConfig").equals("testValue"))
-
-      // close a opened session
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
-      assert(200 == response.getStatus)
-
-      // get session detail again
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
-      assert(404 == response.getStatus)
-    }
+    // close an opened session
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
+    assert(200 == response.getStatus)
+
+    // get session detail again
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().get()
+    assert(404 == response.getStatus)
   }
 
-  test("test get infoType") {
+  test("get infoType") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response: Response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/13")
-        .request().get()
-      assert(200 == response.getStatus)
-      val sessions = response.readEntity(classOf[InfoDetail])
-      assert(sessions.infoType.equals("CLI_SERVER_NAME") &&
-        sessions.infoValue.equals("Apache Kyuubi (Incubating)"))
-      // Invalid sessionHandleStr
-      val handle = "b88d6b56-d200-4bb6-bf0a-5da0ea572e11|0c4aad4e-ccf7-4abd-9305-943d4bfd2d9a|0"
-      response = webTarget.path(s"api/v1/sessions/$handle/info/13").request().get()
-      assert(404 == response.getStatus)
-      response = webTarget.path(s"api/v1/sessions/0/info/13").request().get()
-      assert(404 == response.getStatus)
-
-      // Invalid infoType
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/0")
-        .request().get()
-      assert(404 == response.getStatus)
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/str")
-        .request().get()
-      assert(404 == response.getStatus)
-    }
+    var response: Response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/13")
+      .request().get()
+    assert(200 == response.getStatus)
+    val sessions = response.readEntity(classOf[InfoDetail])
+    assert(sessions.infoType.equals("CLI_SERVER_NAME") &&
+      sessions.infoValue.equals("Apache Kyuubi (Incubating)"))
+    // Invalid sessionHandleStr
+    val handle = "b88d6b56-d200-4bb6-bf0a-5da0ea572e11|0c4aad4e-ccf7-4abd-9305-943d4bfd2d9a|0"
+    response = webTarget.path(s"api/v1/sessions/$handle/info/13").request().get()
+    assert(404 == response.getStatus)
+    response = webTarget.path(s"api/v1/sessions/0/info/13").request().get()
+    assert(404 == response.getStatus)
+
+    // Invalid infoType
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/0")
+      .request().get()
+    assert(404 == response.getStatus)
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/str")
+      .request().get()
+    assert(404 == response.getStatus)
   }
 
-  test("test submit operation and get operation handle") {
+  test("submit operation and get operation handle") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response: Response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-
-      val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
-
-      val statementReq = StatementRequest("show tables", true, 3000)
-      response = webTarget
-        .path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      var operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.EXECUTE_STATEMENT)
-
-      response = webTarget.path(s"$pathPrefix/operations/typeInfo").request()
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TYPE_INFO)
-
-      response = webTarget.path(s"$pathPrefix/operations/catalogs")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_CATALOGS)
-
-      val getSchemasReq = GetSchemasRequest("default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/schemas")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getSchemasReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_SCHEMAS)
-
-      val tableTypes = new util.ArrayList[String]()
-      val getTablesReq = GetTablesRequest("default", "default", "default", tableTypes)
-      response = webTarget.path(s"$pathPrefix/operations/tables")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getTablesReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TABLES)
-
-      response = webTarget.path(s"$pathPrefix/operations/tableTypes").request()
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_TABLE_TYPES)
-
-      val getColumnsReq = GetColumnsRequest("default", "default", "default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/columns")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getColumnsReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_COLUMNS)
-
-      var getFunctionsReq = GetFunctionsRequest("default", "default", "default")
-      response = webTarget.path(s"$pathPrefix/operations/functions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(getFunctionsReq, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_FUNCTIONS)
-    }
+    var response: Response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+
+    val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
+
+    val statementReq = StatementRequest("show tables", true, 3000)
+    response = webTarget
+      .path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    var operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.EXECUTE_STATEMENT)
+
+    response = webTarget.path(s"$pathPrefix/operations/typeInfo").request()
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TYPE_INFO)
+
+    response = webTarget.path(s"$pathPrefix/operations/catalogs")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_CATALOGS)
+
+    val getSchemasReq = GetSchemasRequest("spark_catalog", "default")
+    response = webTarget.path(s"$pathPrefix/operations/schemas")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getSchemasReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_SCHEMAS)
+
+    val tableTypes = new util.ArrayList[String]()
+    val getTablesReq = GetTablesRequest("spark_catalog", "default", "default", tableTypes)
+    response = webTarget.path(s"$pathPrefix/operations/tables")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getTablesReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TABLES)
+
+    response = webTarget.path(s"$pathPrefix/operations/tableTypes").request()
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_TABLE_TYPES)
+
+    val getColumnsReq = GetColumnsRequest("spark_catalog", "default", "default", "default")
+    response = webTarget.path(s"$pathPrefix/operations/columns")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getColumnsReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_COLUMNS)
+
+    var getFunctionsReq = GetFunctionsRequest("default", "default", "default")
+    response = webTarget.path(s"$pathPrefix/operations/functions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(getFunctionsReq, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    operationHandle = response.readEntity(classOf[OperationHandle])
+    assert(operationHandle.typ == OperationType.GET_FUNCTIONS)
   }
 
-  test("test close an operation") {
+  test("close an operation") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response: Response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    var response: Response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
 
-      val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
 
-      response = webTarget.path(s"$pathPrefix/operations/catalogs")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-      var operationHandle = response.readEntity(classOf[OperationHandle])
-      assert(operationHandle.typ == OperationType.GET_CATALOGS)
+    val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
 
-      val serializedOperationHandle = s"${operationHandle.identifier.publicId}|" +
-        s"${operationHandle.identifier.secretId}|${operationHandle.protocol.getValue}|" +
-        s"${operationHandle.typ.toString}"
+    response = webTarget.path(s"$pathPrefix/operations/catalogs")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+    var operationHandle = response.readEntity(classOf[OperationHandle])

Review comment:
       nit: `var -> val`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775493381



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
##########
@@ -17,80 +17,39 @@
 
 package org.apache.kyuubi.server
 
-import java.util.Locale
+import org.apache.kyuubi.RestFrontendTestHelper
 
-import scala.io.Source
-
-import org.scalatest.time.SpanSugar._
-
-import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
-import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.NoopRestFrontendServer
-import org.apache.kyuubi.service.ServiceState._
-
-class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
-
-  test("kyuubi REST frontend service basic") {

Review comment:
       this case is not very necessary as most logic will be verified in RestFrontendTestHelper




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yanghua commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yanghua commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775542424



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -126,61 +100,57 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      // get session list
-      var response2 = webTarget.path("api/v1/sessions").request().get()
-      assert(200 == response2.getStatus)
-      val sessions1 = response2.readEntity(classOf[SessionList])
-      assert(sessions1.sessionList.nonEmpty)
-
-      // close a opened session
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").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[SessionList])
-      assert(sessions2.sessionList.isEmpty)
-    }
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+
+    // get session list
+    var response2 = webTarget.path("api/v1/sessions").request().get()
+    assert(200 == response2.getStatus)
+    val sessions1 = response2.readEntity(classOf[SessionList])
+    assert(sessions1.sessionList.nonEmpty)
+
+    // close a opened session

Review comment:
       an?

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
##########
@@ -17,116 +17,116 @@
 
 package org.apache.kyuubi.server.api.v1
 
-import javax.ws.rs.client.{Entity, WebTarget}
+import javax.ws.rs.client.Entity
 import javax.ws.rs.core.MediaType
 
 import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
+import org.scalatest.concurrent.PatienceConfiguration.Timeout
+import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
 
 import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
 import org.apache.kyuubi.events.KyuubiOperationEvent
-import org.apache.kyuubi.operation.{ExecuteStatement, GetCatalogs, OperationState, OperationType}
+import org.apache.kyuubi.operation.{OperationState, OperationType}
+import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
 import org.apache.kyuubi.operation.OperationType.OperationType
-import org.apache.kyuubi.server.KyuubiRestFrontendService
 
 class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
 
   test("test get an operation event") {
-    withKyuubiRestServer { (fe, _, _, webTarget) =>
-      val catalogsHandleStr = getOpHandleStr(fe, 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])
-      assert(200 == response.getStatus)
-      assert(operationEvent.state == OperationState.INITIALIZED.name())
-
-      val statementHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-      response = webTarget.path(s"api/v1/operations/$statementHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val statementEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(200 == response.getStatus)
-      assert(statementEvent.state == OperationState.INITIALIZED.name())
-
-      // Invalid operationHandleStr
-      val invalidOperationHandle =
-        statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
-      response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+    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])
+    assert(200 == response.getStatus)
+    checkOpState(catalogsHandleStr, FINISHED)
+
+    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])
+    assert(200 == response.getStatus)
+    checkOpState(statementHandleStr, FINISHED)
+
+    // Invalid operationHandleStr
+    val invalidOperationHandle =
+      statementHandleStr.replaceAll("EXECUTE_STATEMENT", "GET_TYPE_INFO")
+    response = webTarget.path(s"api/v1/operations/$invalidOperationHandle/event")
+      .request(MediaType.APPLICATION_JSON_TYPE).get()
+    assert(404 == response.getStatus)
   }
 
   test("test apply an action for an operation") {
-    withKyuubiRestServer { (fe, _, _, webTarget: WebTarget) =>
-      val opHandleStr = getOpHandleStr(fe, OperationType.EXECUTE_STATEMENT)
-
-      var response = webTarget.path(s"api/v1/operations/$opHandleStr")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .put(Entity.entity(OpActionRequest("cancel"), MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-
-      response = webTarget.path(s"api/v1/operations/$opHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      val operationEvent = response.readEntity(classOf[KyuubiOperationEvent])
-      assert(operationEvent.state == OperationState.FINISHED.name() ||
-        operationEvent.state == OperationState.CANCELED.name())
-
-      response = webTarget.path(s"api/v1/operations/$opHandleStr")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .put(Entity.entity(OpActionRequest("close"), MediaType.APPLICATION_JSON_TYPE))
-      assert(200 == response.getStatus)
-
-      response = webTarget.path(s"api/v1/operations/$opHandleStr/event")
-        .request(MediaType.APPLICATION_JSON_TYPE).get()
-      assert(404 == response.getStatus)
-    }
+    val opHandleStr = getOpHandleStr(OperationType.EXECUTE_STATEMENT)
+
+    var response = webTarget.path(s"api/v1/operations/$opHandleStr")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .put(Entity.entity(OpActionRequest("cancel"), MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+
+    response = webTarget.path(s"api/v1/operations/$opHandleStr/event")
+      .request(MediaType.APPLICATION_JSON_TYPE).get()
+    val operationEvent = response.readEntity(classOf[KyuubiOperationEvent])
+    assert(operationEvent.state == OperationState.FINISHED.name() ||
+      operationEvent.state == OperationState.CANCELED.name())
+
+    response = webTarget.path(s"api/v1/operations/$opHandleStr")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .put(Entity.entity(OpActionRequest("close"), MediaType.APPLICATION_JSON_TYPE))
+    assert(200 == response.getStatus)
+
+    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") {

Review comment:
       remove the started `test`?

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -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") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
 
-      assert(200 == response.getStatus)
+    assert(200 == response.getStatus)
 
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    assert(sessionHandle.protocol.getValue == 1)
+    assert(sessionHandle.identifier != null)
 
-      // verify the open session count
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 1)
-    }
-  }
-
-  test("test close and count session") {
-    val requestObj = SessionOpenRequest(
-      1,
-      "admin",
-      "123456",
-      "localhost",
-      Map("testConfig" -> "testValue"))
-
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      assert(200 == response.getStatus)
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    // verify the open session count
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount.openSessionCount == 1)
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    // close a opened session

Review comment:
       an?

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -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") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
 
-      assert(200 == response.getStatus)
+    assert(200 == response.getStatus)
 
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    assert(sessionHandle.protocol.getValue == 1)
+    assert(sessionHandle.identifier != null)
 
-      // verify the open session count
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 1)
-    }
-  }
-
-  test("test close and count session") {
-    val requestObj = SessionOpenRequest(
-      1,
-      "admin",
-      "123456",
-      "localhost",
-      Map("testConfig" -> "testValue"))
-
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      assert(200 == response.getStatus)
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    // verify the open session count

Review comment:
       opened?

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
##########
@@ -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") {
     val requestObj = SessionOpenRequest(
       1,
       "admin",
       "123456",
       "localhost",
       Map("testConfig" -> "testValue"))
 
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
+    var response = webTarget.path("api/v1/sessions")
+      .request(MediaType.APPLICATION_JSON_TYPE)
+      .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
 
-      assert(200 == response.getStatus)
+    assert(200 == response.getStatus)
 
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    val sessionHandle = response.readEntity(classOf[SessionHandle])
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    assert(sessionHandle.protocol.getValue == 1)
+    assert(sessionHandle.identifier != null)
 
-      // verify the open session count
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 1)
-    }
-  }
-
-  test("test close and count session") {
-    val requestObj = SessionOpenRequest(
-      1,
-      "admin",
-      "123456",
-      "localhost",
-      Map("testConfig" -> "testValue"))
-
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      var response = webTarget.path("api/v1/sessions")
-        .request(MediaType.APPLICATION_JSON_TYPE)
-        .post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
-
-      assert(200 == response.getStatus)
-
-      val sessionHandle = response.readEntity(classOf[SessionHandle])
+    // verify the open session count
+    response = webTarget.path("api/v1/sessions/count").request().get()
+    val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
+    assert(openedSessionCount.openSessionCount == 1)
 
-      assert(sessionHandle.protocol.getValue == 1)
-      assert(sessionHandle.identifier != null)
+    // close a opened session
+    val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
+      s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+    response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
+    assert(200 == response.getStatus)
 
-      // close a opened session
-      val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
-        s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
-      response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
-      assert(200 == response.getStatus)
-
-      // verify the open session count again
-      response = webTarget.path("api/v1/sessions/count").request().get()
-      val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
-      assert(openedSessionCount.openSessionCount == 0)
-    }
+    // verify the open session count again

Review comment:
       opened?

##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
##########
@@ -17,80 +17,39 @@
 
 package org.apache.kyuubi.server
 
-import java.util.Locale
+import org.apache.kyuubi.RestFrontendTestHelper
 
-import scala.io.Source
-
-import org.scalatest.time.SpanSugar._
-
-import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
-import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.NoopRestFrontendServer
-import org.apache.kyuubi.service.ServiceState._
-
-class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
-
-  test("kyuubi REST frontend service basic") {
-    val server = new NoopRestFrontendServer()
-    server.stop()
-    val conf = KyuubiConf()
-    assert(server.getServices.isEmpty)
-    assert(server.getServiceState === LATENT)
-    val e = intercept[IllegalStateException](server.frontendServices.head.connectionUrl)
-    assert(e.getMessage startsWith "Illegal Service State: LATENT")
-    assert(server.getConf === null)
-
-    server.initialize(conf)
-    assert(server.getServiceState === INITIALIZED)
-    val frontendService = server.frontendServices.head
-    assert(frontendService.getServiceState == INITIALIZED)
-    assert(server.frontendServices.head.connectionUrl.split(":").length === 2)
-    assert(server.getConf === conf)
-    assert(server.getStartTime === 0)
-    server.stop()
-
-    server.start()
-    assert(server.getServiceState === STARTED)
-    assert(frontendService.getServiceState == STARTED)
-    assert(server.getStartTime !== 0)
-
-    server.stop()
-    assert(server.getServiceState === STOPPED)
-    assert(frontendService.getServiceState == STOPPED)
-    server.stop()
-  }
+class KyuubiRestFrontendServiceSuite extends RestFrontendTestHelper {
 
   test("kyuubi REST frontend service http basic") {
-    withKyuubiRestServer { (_, host, port, _) =>
-      eventually(timeout(10.seconds), interval(50.milliseconds)) {
-        val html = {
-          // noinspection HttpUrlsUsage
-          val s = Source.fromURL(s"http://$host:$port/api/v1/ping")
-          val str = s.mkString
-          s.close()
-          str
-        }
-        assert(html.toLowerCase(Locale.ROOT).equals("pong"))
-      }
-    }
+    val resp = webTarget.path("/api/v1/ping").request().get()
+    resp.getStatusInfo
   }
 
   test("test error and exception response") {
-    withKyuubiRestServer { (_, _, _, webTarget) =>
-      // send a not exists request
-      var response = webTarget.path("api/v1/pong").request().get()
-      assert(404 == response.getStatus)
-      assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("not found"))
+    // send a not exists request
+    var response = webTarget.path("api/v1/pong").request().get()
+    assert(404 == response.getStatus)
+    assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("not found"))
+
+    // send a exists request but wrong http method
+    response = webTarget.path("api/v1/ping").request().post(null)
+    assert(405 == response.getStatus)
+    assert(response.getStatusInfo.getReasonPhrase.equalsIgnoreCase("method not allowed"))
+
+    // send a request but throws a exception on the server side

Review comment:
       an exception?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn closed pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001868570


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1631](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c0da809) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/2af105a417342c4e51ec550df7259d90e1fe341e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2af105a) will **increase** coverage by `0.52%`.
   > The diff coverage is `71.42%`.
   
   > :exclamation: 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](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             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](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/kyuubi/server/api/v1/SessionsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL1Nlc3Npb25zUmVzb3VyY2Uuc2NhbGE=) | `77.17% <66.66%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/server/KyuubiRestFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpUmVzdEZyb250ZW5kU2VydmljZS5zY2FsYQ==) | `86.79% <100.00%> (ø)` | |
   | [.../org/apache/kyuubi/operation/KyuubiOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uLnNjYWxh) | `64.78% <0.00%> (-9.86%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/operation/LaunchEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vTGF1bmNoRW5naW5lLnNjYWxh) | `86.36% <0.00%> (ø)` | |
   | [...org/apache/kyuubi/operation/ExecuteStatement.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vRXhlY3V0ZVN0YXRlbWVudC5zY2FsYQ==) | `87.35% <0.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `63.29% <0.00%> (+2.53%)` | :arrow_up: |
   | [...ache/kyuubi/server/api/v1/OperationsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL09wZXJhdGlvbnNSZXNvdXJjZS5zY2FsYQ==) | `73.46% <0.00%> (+8.16%)` | :arrow_up: |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `94.95% <0.00%> (+11.76%)` | :arrow_up: |
   | [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `95.00% <0.00%> (+12.50%)` | :arrow_up: |
   | [...pache/kyuubi/server/BackendServiceTimeMetric.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvQmFja2VuZFNlcnZpY2VUaW1lTWV0cmljLnNjYWxh) | `100.00% <0.00%> (+16.21%)` | :arrow_up: |
   | ... and [4 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2af105a...2726ab4](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001957926


   thanks, merged to master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001564155


   cc @pan3793 @yanghua @simon824 @cfmcgrady thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn commented on a change in pull request #1631: Migrating existing rests fe test to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#discussion_r775693209



##########
File path: kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
##########
@@ -17,80 +17,39 @@
 
 package org.apache.kyuubi.server
 
-import java.util.Locale
+import org.apache.kyuubi.RestFrontendTestHelper
 
-import scala.io.Source
-
-import org.scalatest.time.SpanSugar._
-
-import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
-import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.NoopRestFrontendServer
-import org.apache.kyuubi.service.ServiceState._
-
-class KyuubiRestFrontendServiceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
-
-  test("kyuubi REST frontend service basic") {
-    val server = new NoopRestFrontendServer()
-    server.stop()
-    val conf = KyuubiConf()
-    assert(server.getServices.isEmpty)
-    assert(server.getServiceState === LATENT)
-    val e = intercept[IllegalStateException](server.frontendServices.head.connectionUrl)
-    assert(e.getMessage startsWith "Illegal Service State: LATENT")
-    assert(server.getConf === null)
-
-    server.initialize(conf)
-    assert(server.getServiceState === INITIALIZED)
-    val frontendService = server.frontendServices.head
-    assert(frontendService.getServiceState == INITIALIZED)
-    assert(server.frontendServices.head.connectionUrl.split(":").length === 2)
-    assert(server.getConf === conf)
-    assert(server.getStartTime === 0)
-    server.stop()
-
-    server.start()
-    assert(server.getServiceState === STARTED)
-    assert(frontendService.getServiceState == STARTED)
-    assert(server.getStartTime !== 0)
-
-    server.stop()
-    assert(server.getServiceState === STOPPED)
-    assert(frontendService.getServiceState == STOPPED)
-    server.stop()
-  }
+class KyuubiRestFrontendServiceSuite extends RestFrontendTestHelper {
 
   test("kyuubi REST frontend service http basic") {
-    withKyuubiRestServer { (_, host, port, _) =>
-      eventually(timeout(10.seconds), interval(50.milliseconds)) {
-        val html = {
-          // noinspection HttpUrlsUsage
-          val s = Source.fromURL(s"http://$host:$port/api/v1/ping")
-          val str = s.mkString
-          s.close()
-          str
-        }
-        assert(html.toLowerCase(Locale.ROOT).equals("pong"))
-      }
-    }
+    val resp = webTarget.path("/api/v1/ping").request().get()
+    resp.getStatusInfo

Review comment:
       nice catch




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] codecov-commenter edited a comment on pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631#issuecomment-1001868570


   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1631](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (80e1404) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/2af105a417342c4e51ec550df7259d90e1fe341e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2af105a) will **increase** coverage by `0.50%`.
   > The diff coverage is `71.42%`.
   
   > :exclamation: Current head 80e1404 differs from pull request most recent head c0da809. Consider uploading reports for the commit c0da809 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/graphs/tree.svg?width=650&height=150&src=pr&token=925D4tb9AH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #1631      +/-   ##
   ============================================
   + Coverage     58.32%   58.83%   +0.50%     
     Complexity      164      164              
   ============================================
     Files           260      260              
     Lines         12930    12932       +2     
     Branches       1633     1633              
   ============================================
   + Hits           7542     7608      +66     
   + Misses         4756     4686      -70     
   - Partials        632      638       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/kyuubi/server/api/v1/SessionsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL1Nlc3Npb25zUmVzb3VyY2Uuc2NhbGE=) | `77.17% <66.66%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/server/KyuubiRestFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpUmVzdEZyb250ZW5kU2VydmljZS5zY2FsYQ==) | `86.79% <100.00%> (ø)` | |
   | [.../org/apache/kyuubi/operation/KyuubiOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uLnNjYWxh) | `64.78% <0.00%> (-9.86%)` | :arrow_down: |
   | [...he/kyuubi/engine/spark/repl/KyuubiSparkILoop.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9yZXBsL0t5dXViaVNwYXJrSUxvb3Auc2NhbGE=) | `90.16% <0.00%> (-3.28%)` | :arrow_down: |
   | [...ala/org/apache/kyuubi/operation/LaunchEngine.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vTGF1bmNoRW5naW5lLnNjYWxh) | `86.36% <0.00%> (ø)` | |
   | [...org/apache/kyuubi/operation/ExecuteStatement.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vRXhlY3V0ZVN0YXRlbWVudC5zY2FsYQ==) | `87.35% <0.00%> (ø)` | |
   | [.../scala/org/apache/kyuubi/server/KyuubiServer.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvS3l1dWJpU2VydmVyLnNjYWxh) | `63.29% <0.00%> (+2.53%)` | :arrow_up: |
   | [...ache/kyuubi/server/api/v1/OperationsResource.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvYXBpL3YxL09wZXJhdGlvbnNSZXNvdXJjZS5zY2FsYQ==) | `73.46% <0.00%> (+8.16%)` | :arrow_up: |
   | [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `92.50% <0.00%> (+10.00%)` | :arrow_up: |
   | [.../apache/kyuubi/client/KyuubiSyncThriftClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jbGllbnQvS3l1dWJpU3luY1RocmlmdENsaWVudC5zY2FsYQ==) | `94.95% <0.00%> (+11.76%)` | :arrow_up: |
   | ... and [5 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2af105a...c0da809](https://codecov.io/gh/apache/incubator-kyuubi/pull/1631?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-kyuubi] yaooqinn closed pull request #1631: Migrating existing rest fe tests to real cases

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #1631:
URL: https://github.com/apache/incubator-kyuubi/pull/1631


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org