From d63eed274905fe90d2bcdd607a56a0e70cc7936a Mon Sep 17 00:00:00 2001 From: yanghua Date: Tue, 11 Jan 2022 12:45:41 +0800 Subject: [PATCH] =?UTF-8?q?[KYUUBI=20#1709]=20Introduce=20a=20IT=20module?= =?UTF-8?q?=20for=20Kyuubi=20and=20FlinkSQL=20Engine=20t=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …o decouple with kyuubi server ### _Why are the changes needed?_ ### _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 Closes #1711 from yanghua/KYUUBI-1709. Closes #1709 95466130 [yanghua] refactor code 89f9c572 [yanghua] Reorder module list in root pom file b664a4bb [yanghua] Rename IT module names 6b7fa88f [yanghua] Rename IT module names b133e8e9 [yanghua] Reformatted pom indent 38444416 [yanghua] [KYUUBI #1709] Introduce a IT module for Kyuubi and FlinkSQL Engine to decouple with kyuubi server Authored-by: yanghua Signed-off-by: Cheng Pan --- integration-tests/kyuubi-flink-it/pom.xml | 91 +++++++++++++++++++ .../WithKyuubiServerAndFlinkMiniCluster.scala | 28 ++++-- .../operation}/FlinkOperationSuite.scala | 6 +- integration-tests/pom.xml | 38 ++++++++ kyuubi-server/pom.xml | 16 ++++ pom.xml | 1 + 6 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 integration-tests/kyuubi-flink-it/pom.xml rename kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerAndFlinkLocalCluster.scala => integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/WithKyuubiServerAndFlinkMiniCluster.scala (51%) rename {kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink => integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/operation}/FlinkOperationSuite.scala (90%) create mode 100644 integration-tests/pom.xml diff --git a/integration-tests/kyuubi-flink-it/pom.xml b/integration-tests/kyuubi-flink-it/pom.xml new file mode 100644 index 000000000..971204e84 --- /dev/null +++ b/integration-tests/kyuubi-flink-it/pom.xml @@ -0,0 +1,91 @@ + + + + + + integration-tests + org.apache.kyuubi + 1.5.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + kyuubi-flink-it_2.12 + Kyuubi Project IT Flink SQL + + + + + org.apache.kyuubi + kyuubi-common_${scala.binary.version} + ${project.version} + test-jar + test + + + + org.apache.kyuubi + kyuubi-server_${scala.binary.version} + ${project.version} + + + + org.apache.kyuubi + kyuubi-server_${scala.binary.version} + ${project.version} + test-jar + test + + + + org.apache.kyuubi + kyuubi-hive-jdbc-shaded + ${project.version} + test + + + + + org.apache.flink + flink-core + test + + + + org.apache.flink + flink-runtime + test + + + + org.apache.flink + flink-table-runtime_${scala.binary.version} + test + + + + org.slf4j + jul-to-slf4j + test + + + + + diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerAndFlinkLocalCluster.scala b/integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/WithKyuubiServerAndFlinkMiniCluster.scala similarity index 51% rename from kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerAndFlinkLocalCluster.scala rename to integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/WithKyuubiServerAndFlinkMiniCluster.scala index a6d5d92ed..0e0f28265 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerAndFlinkLocalCluster.scala +++ b/integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/WithKyuubiServerAndFlinkMiniCluster.scala @@ -15,24 +15,36 @@ * limitations under the License. */ -package org.apache.kyuubi +package org.apache.kyuubi.it.flink -import scala.sys.process._ +import org.apache.flink.configuration.{Configuration, RestOptions} +import org.apache.flink.runtime.minicluster.{MiniCluster, MiniClusterConfiguration} -import org.apache.kyuubi.engine.flink.FlinkProcessBuilder +import org.apache.kyuubi.WithKyuubiServer -trait WithKyuubiServerAndFlinkLocalCluster extends WithKyuubiServer { +trait WithKyuubiServerAndFlinkMiniCluster extends WithKyuubiServer { - private lazy val FLINK_HOME: String = - new FlinkProcessBuilder(Utils.currentUser, conf).FLINK_HOME + protected lazy val flinkConfig = new Configuration() + protected var miniCluster: MiniCluster = _ override def beforeAll(): Unit = { - s"$FLINK_HOME/bin/start-cluster.sh".! + startMiniCluster() super.beforeAll() } override def afterAll(): Unit = { super.afterAll() - s"$FLINK_HOME/bin/stop-cluster.sh".! + miniCluster.close() + } + + private def startMiniCluster(): Unit = { + val cfg = new MiniClusterConfiguration.Builder() + .setConfiguration(flinkConfig) + .setNumSlotsPerTaskManager(1) + .build + miniCluster = new MiniCluster(cfg) + miniCluster.start() + flinkConfig.setString(RestOptions.ADDRESS, miniCluster.getRestAddress.get().getHost) + flinkConfig.setInteger(RestOptions.PORT, miniCluster.getRestAddress.get().getPort) } } diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala b/integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/operation/FlinkOperationSuite.scala similarity index 90% rename from kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala rename to integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/operation/FlinkOperationSuite.scala index 8915c1978..2ab44a4ef 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/flink/FlinkOperationSuite.scala +++ b/integration-tests/kyuubi-flink-it/src/test/scala/org/apache/kyuubi/it/flink/operation/FlinkOperationSuite.scala @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.kyuubi.operation.flink +package org.apache.kyuubi.it.flink.operation -import org.apache.kyuubi.WithKyuubiServerAndFlinkLocalCluster import org.apache.kyuubi.config.KyuubiConf import org.apache.kyuubi.config.KyuubiConf.{ENGINE_TYPE, FRONTEND_THRIFT_BINARY_BIND_PORT} +import org.apache.kyuubi.it.flink.WithKyuubiServerAndFlinkMiniCluster import org.apache.kyuubi.operation.HiveJDBCTestHelper import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant.TABLE_CAT -class FlinkOperationSuite extends WithKyuubiServerAndFlinkLocalCluster with HiveJDBCTestHelper { +class FlinkOperationSuite extends WithKyuubiServerAndFlinkMiniCluster with HiveJDBCTestHelper { override val conf: KyuubiConf = KyuubiConf() .set(ENGINE_TYPE, "FLINK_SQL") .set(FRONTEND_THRIFT_BINARY_BIND_PORT, 10019) diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml new file mode 100644 index 000000000..df58e73d9 --- /dev/null +++ b/integration-tests/pom.xml @@ -0,0 +1,38 @@ + + + + + + kyuubi-parent + org.apache.kyuubi + 1.5.0-SNAPSHOT + + + 4.0.0 + pom + + integration-tests + Kyuubi Integration Tests + + + kyuubi-flink-it + + + diff --git a/kyuubi-server/pom.xml b/kyuubi-server/pom.xml index 100875402..309f73bd8 100644 --- a/kyuubi-server/pom.xml +++ b/kyuubi-server/pom.xml @@ -460,5 +460,21 @@ target/scala-${scala.binary.version}/classes target/scala-${scala.binary.version}/test-classes + + + + org.apache.maven.plugins + maven-jar-plugin + + + prepare-test-jar + test-compile + + test-jar + + + + + diff --git a/pom.xml b/pom.xml index dfa0df629..225fa5295 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ externals/kyuubi-flink-sql-engine externals/kyuubi-spark-sql-engine externals/kyuubi-trino-engine + integration-tests kyuubi-assembly kyuubi-common kyuubi-ctl