-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core, Test: Refactor tests to support ClickHouse Cloud (#349)
* Build, Core: Test with ClickHouse Cloud * Spark 3.5: Test with ClickHouse Cloud * Spark 3.4: Test with ClickHouse Cloud * Spark 3.3: Test with ClickHouse Cloud * Add withNodeClient username/password/opts & change Table engine from Log() to Memory() * Add ssl only if isSslEnabled is true * Extend table name to a void tests from hitting same table name * Add connection timeout & set database name for the Client * Fix spotless * Disable parallel tun of Cloud tests * Do not expect AnalysisException when running cloud test against Spark 3.3 * Code cleanup * move import & set parallel = 1 when testing * Add conditional sleep to older version * Add missing import * Fix Versions * Moving back to parallel for local tests --------- Co-authored-by: Cheng Pan <[email protected]>
- Loading branch information
Showing
30 changed files
with
406 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
name: "ClickHouse Cloud" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "branch-*" | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "branch-*" | ||
- "main" | ||
|
||
jobs: | ||
run-tests-with-clickhouse-cloud: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
max-parallel: 1 | ||
fail-fast: false | ||
matrix: | ||
spark: [ 3.3, 3.4, 3.5 ] | ||
scala: [ 2.12, 2.13 ] | ||
env: | ||
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }} | ||
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: zulu | ||
java-version: 8 | ||
cache: gradle | ||
- run: >- | ||
./gradlew clean cloudTest --no-daemon --refresh-dependencies | ||
-Dspark_binary_version=${{ matrix.spark }} | ||
-Dscala_binary_version=${{ matrix.scala }} | ||
-PmavenCentralMirror=https://maven-central.storage-download.googleapis.com/maven2/ | ||
- name: Upload test logs | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: log-clickhouse-cloud-spark-${{ matrix.spark }}-scala-${{ matrix.scala }} | ||
path: | | ||
**/build/unit-tests.log | ||
log/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clickhouse-core/src/testFixtures/java/org/scalatest/tags/Cloud.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalatest.tags; | ||
|
||
import java.lang.annotation.*; | ||
import org.scalatest.TagAnnotation; | ||
|
||
@TagAnnotation | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
@Inherited | ||
public @interface Cloud {} |
38 changes: 38 additions & 0 deletions
38
clickhouse-core/src/testFixtures/scala/com/clickhouse/spark/base/ClickHouseCloudMixIn.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.clickhouse.spark.base | ||
|
||
import com.clickhouse.data.ClickHouseVersion | ||
import com.clickhouse.spark.Utils | ||
|
||
trait ClickHouseCloudMixIn extends ClickHouseProvider { | ||
|
||
override def clickhouseHost: String = Utils.load("CLICKHOUSE_CLOUD_HOST") | ||
|
||
override def clickhouseHttpPort: Int = Utils.load("CLICKHOUSE_CLOUD_HTTP_PORT", "8443").toInt | ||
|
||
override def clickhouseTcpPort: Int = Utils.load("CLICKHOUSE_CLOUD_TCP_PORT", "9000").toInt | ||
|
||
override def clickhouseUser: String = Utils.load("CLICKHOUSE_CLOUD_USER", "default") | ||
|
||
override def clickhousePassword: String = Utils.load("CLICKHOUSE_CLOUD_PASSWORD") | ||
|
||
override def clickhouseDatabase: String = "default" | ||
|
||
override def clickhouseVersion: ClickHouseVersion = ClickHouseVersion.of("latest") | ||
|
||
override def isSslEnabled: Boolean = true | ||
override def isCloud: Boolean = true | ||
} |
51 changes: 51 additions & 0 deletions
51
clickhouse-core/src/testFixtures/scala/com/clickhouse/spark/base/ClickHouseProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.clickhouse.spark.base | ||
|
||
import com.clickhouse.client.ClickHouseProtocol | ||
import com.clickhouse.client.ClickHouseProtocol.HTTP | ||
import com.clickhouse.data.ClickHouseVersion | ||
import com.clickhouse.spark.Utils | ||
import com.clickhouse.spark.client.NodeClient | ||
import com.clickhouse.spark.spec.NodeSpec | ||
import scala.collection.JavaConverters._ | ||
|
||
trait ClickHouseProvider { | ||
def clickhouseHost: String | ||
def clickhouseHttpPort: Int | ||
def clickhouseTcpPort: Int | ||
def clickhouseUser: String | ||
def clickhousePassword: String | ||
def clickhouseDatabase: String | ||
def clickhouseVersion: ClickHouseVersion | ||
def isSslEnabled: Boolean | ||
def isCloud: Boolean = false | ||
|
||
def withNodeClient(protocol: ClickHouseProtocol = HTTP)(block: NodeClient => Unit): Unit = | ||
Utils.tryWithResource { | ||
NodeClient(NodeSpec( | ||
clickhouseHost, | ||
Some(clickhouseHttpPort), | ||
Some(clickhouseTcpPort), | ||
protocol, | ||
username = clickhouseUser, | ||
database = clickhouseDatabase, | ||
password = clickhousePassword, | ||
options = Map("ssl" -> isSslEnabled.toString).asJava | ||
)) | ||
} { | ||
client => block(client) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.