From 67d8d768d7a7e2b023df90003592cb29295b97a4 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 20 Apr 2023 13:41:43 +0800 Subject: [PATCH] [Plugin] Support starrocks --- README.md | 3 + core/datacap-server/pom.xml | 5 ++ .../src/main/etc/conf/plugins/jdbc/doris.yaml | 2 +- .../main/etc/conf/plugins/jdbc/starrocks.yaml | 31 +++++++ .../spi/connection/JdbcConnection.java | 7 +- .../public/static/images/plugin/StarRocks.png | Bin 0 -> 5250 bytes docs/docs/assets/plugin/starrocks.png | Bin 0 -> 8166 bytes docs/docs/index.md | 3 + docs/docs/index.zh.md | 3 + .../reference/connectors/jdbc/starrocks.md | 57 ++++++++++++ .../reference/connectors/jdbc/starrocks.zh.md | 57 ++++++++++++ docs/mkdocs.yml | 1 + plugin/datacap-jdbc-starrocks/pom.xml | 82 ++++++++++++++++++ .../plugin/jdbc/starrocks/StarRocksPlugin.kt | 66 ++++++++++++++ .../jdbc/starrocks/StarRocksPluginModule.kt | 28 ++++++ .../io.edurt.datacap.spi.PluginModule | 1 + .../jdbc/starrocks/StarRocksContainer.kt | 26 ++++++ .../starrocks/StarRocksPluginModuleTest.kt | 29 +++++++ .../jdbc/starrocks/StarRocksPluginTest.kt | 71 +++++++++++++++ pom.xml | 31 ++++--- 20 files changed, 488 insertions(+), 15 deletions(-) create mode 100644 core/datacap-server/src/main/etc/conf/plugins/jdbc/starrocks.yaml create mode 100644 core/datacap-web/console-fe/public/static/images/plugin/StarRocks.png create mode 100644 docs/docs/assets/plugin/starrocks.png create mode 100644 docs/docs/reference/connectors/jdbc/starrocks.md create mode 100644 docs/docs/reference/connectors/jdbc/starrocks.zh.md create mode 100644 plugin/datacap-jdbc-starrocks/pom.xml create mode 100644 plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPlugin.kt create mode 100644 plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModule.kt create mode 100644 plugin/datacap-jdbc-starrocks/src/main/resources/META-INF/services/io.edurt.datacap.spi.PluginModule create mode 100644 plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksContainer.kt create mode 100644 plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModuleTest.kt create mode 100644 plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginTest.kt diff --git a/README.md b/README.md index b7dcde59..ca3aaa2d 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,9 @@ Here are some of the major database solutions that are supported:   Apache Doris +   + + StarRocks

diff --git a/core/datacap-server/pom.xml b/core/datacap-server/pom.xml index a7f2223f..1ae3af04 100644 --- a/core/datacap-server/pom.xml +++ b/core/datacap-server/pom.xml @@ -335,6 +335,11 @@ datacap-jdbc-doris ${project.version} + + io.edurt.datacap + datacap-jdbc-starrocks + ${project.version} + io.edurt.datacap diff --git a/core/datacap-server/src/main/etc/conf/plugins/jdbc/doris.yaml b/core/datacap-server/src/main/etc/conf/plugins/jdbc/doris.yaml index ee0a363a..4f778a35 100644 --- a/core/datacap-server/src/main/etc/conf/plugins/jdbc/doris.yaml +++ b/core/datacap-server/src/main/etc/conf/plugins/jdbc/doris.yaml @@ -15,7 +15,7 @@ configures: required: true min: 1 max: 65535 - value: 9030 + value: 9093 message: port is a required field, please be sure to enter - field: username type: String diff --git a/core/datacap-server/src/main/etc/conf/plugins/jdbc/starrocks.yaml b/core/datacap-server/src/main/etc/conf/plugins/jdbc/starrocks.yaml new file mode 100644 index 00000000..bddd5c5a --- /dev/null +++ b/core/datacap-server/src/main/etc/conf/plugins/jdbc/starrocks.yaml @@ -0,0 +1,31 @@ +name: StarRocks +supportTime: '2023-04-20' +configures: + - field: name + type: String + required: true + message: name is a required field, please be sure to enter + - field: host + type: String + required: true + value: 127.0.0.1 + message: host is a required field, please be sure to enter + - field: port + type: Number + required: true + min: 1 + max: 65535 + value: 9030 + message: port is a required field, please be sure to enter + - field: username + type: String + group: authorization + - field: password + type: String + group: authorization + - field: database + type: String + required: true + value: default + message: database is a required field, please be sure to enter + group: advanced diff --git a/core/datacap-spi/src/main/java/io/edurt/datacap/spi/connection/JdbcConnection.java b/core/datacap-spi/src/main/java/io/edurt/datacap/spi/connection/JdbcConnection.java index e4b8ac88..463da544 100644 --- a/core/datacap-spi/src/main/java/io/edurt/datacap/spi/connection/JdbcConnection.java +++ b/core/datacap-spi/src/main/java/io/edurt/datacap/spi/connection/JdbcConnection.java @@ -9,6 +9,7 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.stream.Collectors; @Slf4j @@ -74,7 +75,11 @@ public class JdbcConnection } else { log.info("Connection username and password not present"); - this.connection = DriverManager.getConnection(url); + Properties properties = new Properties(); + if (jdbcConfigure.getUsername().isPresent()) { + properties.put("user", jdbcConfigure.getUsername().get()); + } + this.connection = DriverManager.getConnection(url, properties); } response.setIsConnected(Boolean.TRUE); } diff --git a/core/datacap-web/console-fe/public/static/images/plugin/StarRocks.png b/core/datacap-web/console-fe/public/static/images/plugin/StarRocks.png new file mode 100644 index 0000000000000000000000000000000000000000..4739041effda0df27c8e849dbb423a04b88f0c64 GIT binary patch literal 5250 zcmbtY_g7O}(+)-hB3()l5tZHvReBSoLkL|Yp(+rXgdozvOGhMtG^6xhr1ui3F`yz{ zKt$<6@B$Jd?F-)Z{RQt?>-;i%=9y<^o_+RSC*I8D9zE?fS^xk*udjF48~~sKpT9I9 ziY4~>MiKzPs;_@n)8dK4Hda09`aN{4pl@C;l{Sb$-r`$CBoM>^miE;Et3@nbFrn$g zD7eT2KlNTNP*F_>(zZtYTxYm*y)~O|?(UU49;D}QjX~5xQc1JD04l)_P9XJRd-+55m@DJH1vBz(b8t{!b_xBj~otTNpNKv)Pvg$nPQbfP7E^q8Vn)Vi1y4DYd zgWGl(0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fzhyFM%(PozJ6&#bN@D1{x{7w;BBb!EKuJ!s zx`ljJ8l#U}wm>O`Uo|oO#kN8hqOU;|z4_p&{KxtYALu*Z`^t%oEqW>w2%`oC=ZmCk z-e8(8Y^+u?3Dod!%XTkKyye*UlDsEcPFf7IQw}WkD-=Ki8DuPCf;|1@@xet~{sZNj zEo$~ur5}FLEr!~3rcDC=A2p2z6YM%1L7ATdaxr1qnY8V56NBnNMUv`g5(RWnHIYK! zaRpnx1bg*X3t&9j_F^P$PLC^L&O<8q_3s&SrvtK{%Ai~%*h zt3L~z(--yIrS>n65ob2YyAkdj8x0jUrrPoKlb9c2b(4o{Pbi%~Vb(co7-v98+DQ{c z|2uMXyp%01q2y~bFL!omjX9jNBc>(b*#*7VY@raZCMo?MtiNiP8`p6Ac|h< zWaW`{zKQ>U`uKItqIGq>jph}=#duqj^pzXJJKow@do~Jzd#%If<<4 zW~H$6Kkz+EO$rp>vmu&H=_FR$|g6wR>5ng&+6QVq13Pqa9#v0pwi z=G*HC(!WjoXT1Y}I`qe)KIXj6a{DNogwS z=tC*c*=MK>3gS4sRz9Qt)-Phl3a-)LX^uSlln#J2Pi2!LSLve}iAsy|k14pX{eb4` zxn@SWn3uQ8sY#4Lejr^!?gsp?-D1s}0^RZ*GakQ%K1cuciiS4_oOxj84+iSSmHq!{ zu>%WGP{#O-7ePKMy=A%=m`_bH9{}+~x-X|NL5N`KuCp&@fQ1Kb?*Z@3f9IXizXeaM zq+7OY)|>~rpV!gDnU8HpS7~NB)D_ee2jm0  Apache Doris +   + + StarRocks

diff --git a/docs/docs/index.zh.md b/docs/docs/index.zh.md index c3a67959..bd08bc95 100644 --- a/docs/docs/index.zh.md +++ b/docs/docs/index.zh.md @@ -194,6 +194,9 @@ Datacap 是快速、轻量级、直观的系统。   Apache Doris +   + + StarRocks

diff --git a/docs/docs/reference/connectors/jdbc/starrocks.md b/docs/docs/reference/connectors/jdbc/starrocks.md new file mode 100644 index 00000000..7401474b --- /dev/null +++ b/docs/docs/reference/connectors/jdbc/starrocks.md @@ -0,0 +1,57 @@ +--- +title: StarRocks +status: new +--- + + + +#### What is StarRocks ? + +An Open-Source, High-Performance Analytical Database + +#### Environment + +!!! note + + If you need to use this data source, you need to upgrade the DataCap service to >= `1.9.x` + +Support Time: `2023-04-20` + +#### Configure + +--- + +!!! note + + If your StarRocks service version requires other special configurations, please refer to modifying the configuration file and restarting the DataCap service. + +=== "Configure" + + | Field | Required | Default Value | + |:------:|:---------------------------------:|:-------------:| + | `Name` | :material-check-circle: { .red } | - | + | `Host` | :material-check-circle: { .red } | `127.0.0.1` | + | `Port` | :material-check-circle: { .red } | `9030` | + +=== "Authorization" + + | Field | Required | Default Value | + |:----------:|:-----------------------:|:-------------:| + | `Username` | :material-close-circle: | - | + | `Password` | :material-close-circle: | - | + +=== "Advanced" + + | Field | Required | Default Value | + |:----------:|:-----------------------:|:-------------:| + | `Database` | :material-close-circle: | - | + +#### Version (Validation) + +--- + +!!! warning + + The online service has not been tested yet, if you have detailed test results, please submit [issues](https://github.com/EdurtIO/datacap/issues/new/choose) to us + +- [x] 2.2.x diff --git a/docs/docs/reference/connectors/jdbc/starrocks.zh.md b/docs/docs/reference/connectors/jdbc/starrocks.zh.md new file mode 100644 index 00000000..cd070d29 --- /dev/null +++ b/docs/docs/reference/connectors/jdbc/starrocks.zh.md @@ -0,0 +1,57 @@ +--- +title: StarRocks +status: new +--- + + + +#### 什么是 StarRocks ? + +开源、高性能的分析数据库 + +#### 环境 + +!!! note + + 如果你需要使用这个数据源, 您需要将 DataCap 服务升级到 >= `1.9.x` + +支持时间: `2023-04-20` + +#### 配置 + +--- + +!!! note + + 如果您的 StarRocks 服务版本需要其他特殊配置,请参考修改配置文件并重启 DataCap 服务。 + +=== "配置" + + | Field | Required | Default Value | + |:------:|:---------------------------------:|:-------------:| + | `Name` | :material-check-circle: { .red } | - | + | `Host` | :material-check-circle: { .red } | `127.0.0.1` | + | `Port` | :material-check-circle: { .red } | `9030` | + +=== "授权" + + | Field | Required | Default Value | + |:----------:|:-----------------------:|:-------------:| + | `Username` | :material-close-circle: | - | + | `Password` | :material-close-circle: | - | + +=== "高级" + + | Field | Required | Default Value | + |:----------:|:-----------------------:|:-------------:| + | `Database` | :material-close-circle: | - | + +#### 版本(验证) + +--- + +!!! warning + + 服务版本尚未测试,如果您有详细的测试并发现错误,请提交 [issues](https://github.com/EdurtIO/datacap/issues/new/choose) + +- [x] 2.2.x diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 102e3456..ba29a9e7 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -148,6 +148,7 @@ nav: - Connecting to connectors: - reference/connectors/index.md - JDBC: + - StarRocks: reference/connectors/jdbc/starrocks.md - Apache Doris: reference/connectors/jdbc/doris.md - DuckDB: reference/connectors/jdbc/duckdb.md - Yandex Database: reference/connectors/jdbc/ydb.md diff --git a/plugin/datacap-jdbc-starrocks/pom.xml b/plugin/datacap-jdbc-starrocks/pom.xml new file mode 100644 index 00000000..daeb415f --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + io.edurt.datacap + datacap + 1.9.0-SNAPSHOT + ../../pom.xml + + + datacap-jdbc-starrocks + DataCap - StarRocks + + + 8.0.28 + jdbc-starrocks + + + + + io.edurt.datacap + datacap-spi + provided + + + mysql + mysql-connector-java + ${mysql.version} + + + commons-beanutils + commons-beanutils + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + test + + + org.jetbrains.kotlin + kotlin-reflect + + + org.testcontainers + testcontainers + test + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + ${assembly-plugin.version} + + ${plugin.name} + + ../../configure/assembly/assembly-plugin.xml + + ../../dist/plugins/${plugin.name} + + + + make-assembly + package + + single + + + + + + + + diff --git a/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPlugin.kt b/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPlugin.kt new file mode 100644 index 00000000..15ac441e --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPlugin.kt @@ -0,0 +1,66 @@ +package io.edurt.datacap.plugin.jdbc.starrocks + +import io.edurt.datacap.spi.Plugin +import io.edurt.datacap.spi.PluginType +import io.edurt.datacap.spi.adapter.JdbcAdapter +import io.edurt.datacap.spi.connection.JdbcConfigure +import io.edurt.datacap.spi.connection.JdbcConnection +import io.edurt.datacap.spi.model.Configure +import io.edurt.datacap.spi.model.Response +import org.apache.commons.beanutils.BeanUtils +import org.apache.commons.lang3.ObjectUtils +import org.slf4j.LoggerFactory.getLogger + +class StarRocksPlugin : Plugin { + private val log = getLogger(StarRocksPlugin::class.java) + + private var jdbcConfigure: JdbcConfigure? = null + private var jdbcConnection: JdbcConnection? = null + private var jdbcResponse: Response? = null + + override fun name(): String { + return "StarRocks" + } + + override fun description(): String { + return "Integrate StarRocks data sources" + } + + override fun type(): PluginType { + return PluginType.JDBC + } + + override fun connect(configure: Configure?) { + try { + log.info("Connecting to StarRocks") + jdbcResponse = Response() + jdbcConfigure = JdbcConfigure() + BeanUtils.copyProperties(jdbcConfigure, configure) + jdbcConfigure!!.jdbcDriver = "com.mysql.cj.jdbc.Driver" + jdbcConfigure!!.jdbcType = "mysql" + jdbcConnection = object : JdbcConnection(jdbcConfigure, jdbcResponse) {} + } catch (ex: Exception) { + jdbcResponse!!.isConnected = false + jdbcResponse!!.message = ex.message + } + } + + override fun execute(content: String?): Response { + if (ObjectUtils.isNotEmpty(jdbcConnection)) { + log.info("Execute starrocks plugin logic started") + jdbcResponse = jdbcConnection?.response + val processor = JdbcAdapter(jdbcConnection) + jdbcResponse = processor.handlerExecute(content) + log.info("Execute starrocks plugin logic end") + } + destroy() + return jdbcResponse!! + } + + override fun destroy() { + if (ObjectUtils.isNotEmpty(jdbcConnection)) { + jdbcConnection?.destroy() + jdbcConnection = null + } + } +} \ No newline at end of file diff --git a/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModule.kt b/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModule.kt new file mode 100644 index 00000000..4ed4ee26 --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/main/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModule.kt @@ -0,0 +1,28 @@ +package io.edurt.datacap.plugin.jdbc.starrocks + +import com.google.inject.multibindings.Multibinder +import io.edurt.datacap.spi.AbstractPluginModule +import io.edurt.datacap.spi.Plugin +import io.edurt.datacap.spi.PluginModule +import io.edurt.datacap.spi.PluginType + +class StarRocksPluginModule : AbstractPluginModule(), PluginModule { + override fun getName(): String { + return "StarRocks" + } + + override fun getType(): PluginType { + return PluginType.JDBC + } + + override fun get(): AbstractPluginModule { + return this + } + + override fun configure() { + val module = Multibinder.newSetBinder(binder(), String::class.java) + module.addBinding().toInstance(this.javaClass.simpleName) + val plugin: Multibinder = Multibinder.newSetBinder(binder(), Plugin::class.java) + plugin.addBinding().to(StarRocksPlugin::class.java) + } +} \ No newline at end of file diff --git a/plugin/datacap-jdbc-starrocks/src/main/resources/META-INF/services/io.edurt.datacap.spi.PluginModule b/plugin/datacap-jdbc-starrocks/src/main/resources/META-INF/services/io.edurt.datacap.spi.PluginModule new file mode 100644 index 00000000..44badc78 --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/main/resources/META-INF/services/io.edurt.datacap.spi.PluginModule @@ -0,0 +1 @@ +io.edurt.datacap.plugin.jdbc.starrocks.StarRocksPluginModule diff --git a/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksContainer.kt b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksContainer.kt new file mode 100644 index 00000000..d65e1d50 --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksContainer.kt @@ -0,0 +1,26 @@ +package io.edurt.datacap.plugin.jdbc.starrocks + +import org.testcontainers.containers.GenericContainer +import org.testcontainers.utility.DockerImageName + +class StarRocksContainer : GenericContainer { + constructor() : super(DEFAULT_IMAGE_NAME) + + constructor(dockerImageName: DockerImageName) : super(dockerImageName) { + dockerImageName.assertCompatibleWith(dockerImageName) + withExposedPorts(BE_PORT, WEBSERVER_PORT, HEARTBEAT_SERVICE_PORT, BRPC_PORT, HTTP_PORT, RPC_PORT, QUERY_PORT, EDIT_LOG_PORT, BROKER_IPC_PORT) + } + + companion object { + private val DEFAULT_IMAGE_NAME = DockerImageName.parse("starrocks:2.2.12") + const val BE_PORT = 9060 + const val WEBSERVER_PORT = 8040 + const val HEARTBEAT_SERVICE_PORT = 9050 + const val BRPC_PORT = 8060 + const val HTTP_PORT = 8030 + const val RPC_PORT = 9020 + const val QUERY_PORT = 9030 + const val EDIT_LOG_PORT = 9010 + const val BROKER_IPC_PORT = 8000 + } +} \ No newline at end of file diff --git a/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModuleTest.kt b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModuleTest.kt new file mode 100644 index 00000000..c67d111b --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginModuleTest.kt @@ -0,0 +1,29 @@ +package io.edurt.datacap.plugin.jdbc.starrocks + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; +import io.edurt.datacap.spi.Plugin; +import org.apache.commons.lang3.ObjectUtils +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.Set; + +class StarRocksPluginModuleTest { + private var injector: Injector? = null + + @Before + fun before() { + injector = Guice.createInjector(StarRocksPluginModule()) + } + + @Test + fun test() { + val plugin: Plugin? = injector?.getInstance(Key.get(object : TypeLiteral?>() {})) + ?.first { v -> v?.name().equals("StarRocks") } + Assert.assertTrue(ObjectUtils.isNotEmpty(plugin)) + } +} diff --git a/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginTest.kt b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginTest.kt new file mode 100644 index 00000000..c15a16a5 --- /dev/null +++ b/plugin/datacap-jdbc-starrocks/src/test/kotlin/io/edurt/datacap/plugin/jdbc/starrocks/StarRocksPluginTest.kt @@ -0,0 +1,71 @@ +package io.edurt.datacap.plugin.jdbc.starrocks + +import com.google.inject.Guice +import com.google.inject.Injector +import com.google.inject.Key +import com.google.inject.TypeLiteral +import io.edurt.datacap.spi.Plugin +import io.edurt.datacap.spi.model.Configure +import io.edurt.datacap.spi.model.Response +import org.apache.commons.lang3.ObjectUtils +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import org.slf4j.LoggerFactory.getLogger +import org.testcontainers.containers.Network +import org.testcontainers.lifecycle.Startables +import org.testcontainers.shaded.com.google.common.collect.Lists +import org.testcontainers.shaded.org.awaitility.Awaitility.given +import java.util.* +import java.util.Set +import java.util.concurrent.TimeUnit + + +class StarRocksPluginTest { + private val log = getLogger(StarRocksPluginTest::class.java) + + private val host = "StarRocksCluster" + private var container: StarRocksContainer? = null + + private var injector: Injector? = null + private var configure: Configure? = null + + @Before + fun before() { + val network = Network.newNetwork() + container = StarRocksContainer() + ?.withNetwork(network) + ?.withNetworkAliases(host) + container?.portBindings = Lists.newArrayList(String.format("%s:%s", StarRocksContainer.QUERY_PORT, StarRocksContainer.QUERY_PORT)) + Startables.deepStart(java.util.stream.Stream.of(container)).join() + log.info("StarRocks container started") + + given().ignoreExceptions() + .await() + .atMost(400, TimeUnit.SECONDS) + + injector = Guice.createInjector(StarRocksPluginModule()) + configure = Configure() + configure!!.host = "0.0.0.0" + configure!!.port = StarRocksContainer.QUERY_PORT + configure!!.username = Optional.of("root") + } + + @Test + fun test() { + val plugin: Plugin? = injector?.getInstance(Key.get(object : TypeLiteral?>() {})) + ?.first { v -> v?.name().equals("StarRocks") } + if (ObjectUtils.isNotEmpty(plugin)) { + plugin?.connect(configure) + val sql = "SHOW DATABASES" + val response: Response = plugin!!.execute(sql) + log.info("================ plugin executed information =================") + if (!response.isSuccessful) { + log.error("Message: {}", response.message) + } else { + response.columns.forEach { column -> log.info(column.toString()) } + } + Assert.assertTrue(response.isSuccessful) + } + } +} diff --git a/pom.xml b/pom.xml index 5ed3c74f..ec34b1e1 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ plugin/datacap-jdbc-tdengine plugin/datacap-jdbc-trino plugin/datacap-jdbc-doris + plugin/datacap-jdbc-starrocks executor/datacap-executor-example executor/datacap-executor-seatunnel @@ -117,7 +118,7 @@ 1.7.36 2.0.3 31.1-jre - 1.8.10 + 1.8.20 1.9.4 3.8.0 1.17.6 @@ -146,6 +147,17 @@ lombok ${lombok.version}
+ + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + @@ -252,32 +264,25 @@ kotlin-maven-plugin + + 1.8 + org.jetbrains.kotlin ${kotlin.version} compile + compile compile - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/main/java - - test-compile + test-compile test-compile - - - ${project.basedir}/src/test/kotlin - ${project.basedir}/src/test/java - -