[KYUUBI #3549][FOLLOWUP] Simplify test

### _Why are the changes needed?_

Simplify test by using helper method `withJdbcStatement`

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #3556 from pan3793/followup.

Closes #3549

75103f85 [Cheng Pan] nit
449a2563 [Cheng Pan] [KYUUBI #3549][FOLLOWUP] Simplify test

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
Cheng Pan 2022-09-26 18:06:06 +08:00
parent 97a50acb18
commit ec999017f4
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D

View File

@ -19,7 +19,7 @@ package org.apache.kyuubi.engine.flink.operation
import java.nio.file.Files
import java.sql.DatabaseMetaData
import java.util.{Properties, UUID}
import java.util.UUID
import scala.collection.JavaConverters._
@ -34,7 +34,7 @@ import org.apache.kyuubi.engine.flink.FlinkEngineUtils._
import org.apache.kyuubi.engine.flink.WithFlinkSQLEngine
import org.apache.kyuubi.engine.flink.result.Constants
import org.apache.kyuubi.engine.flink.util.TestUserClassLoaderJar
import org.apache.kyuubi.jdbc.hive.{KyuubiConnection, KyuubiStatement}
import org.apache.kyuubi.jdbc.hive.KyuubiStatement
import org.apache.kyuubi.operation.{HiveJDBCTestHelper, NoneMode}
import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant._
import org.apache.kyuubi.service.ServiceState._
@ -977,14 +977,14 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
}
test("get query id") {
val conn = new KyuubiConnection(jdbcUrl, new Properties())
val stmt = conn.createStatement()
stmt.executeQuery("create table tbl_a (a int) with ('connector' = 'blackhole')")
assert(stmt.asInstanceOf[KyuubiStatement].getQueryId === null)
stmt.executeQuery("insert into tbl_a values (1)")
val queryId = stmt.asInstanceOf[KyuubiStatement].getQueryId
assert(queryId !== null)
// parse the string to check if it's valid Flink job id
assert(JobID.fromHexString(queryId) !== null)
withJdbcStatement("tbl_a") { stmt =>
stmt.executeQuery("create table tbl_a (a int) with ('connector' = 'blackhole')")
assert(stmt.asInstanceOf[KyuubiStatement].getQueryId === null)
stmt.executeQuery("insert into tbl_a values (1)")
val queryId = stmt.asInstanceOf[KyuubiStatement].getQueryId
assert(queryId !== null)
// parse the string to check if it's valid Flink job id
assert(JobID.fromHexString(queryId) !== null)
}
}
}