-
Notifications
You must be signed in to change notification settings - Fork 623
[repo] Adopt CLI tests from ClickHouse client #2772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9075819
added simple client
chernser 5f9180d
Complete implementation that just works
chernser 1616cfb
moved script to dedicated folder
chernser 6ae8949
Updated readme to have only important information
chernser 6dffc9b
Added JDBC cli for tests
chernser 67109a4
Reimplemented using commons-csv
chernser 98694ef
added commons-cli to handle cli things
chernser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,43 @@ | ||
| # clickhouse-client-cli | ||
|
|
||
| A simple CLI tool that mimics `clickhouse-client` for executing SQL queries against a ClickHouse server. | ||
| Used to test with ClickHouse test framework designed for `clickhouse-client` (https://github.com/ClickHouse/ClickHouse/blob/master/tests/clickhouse-test). | ||
| Note: do not clone ClickHouse repo - it takes a lot of time. Download zip instead. | ||
|
|
||
| ## Build Java Application | ||
|
|
||
| ```bash | ||
| cd tests/clickhouse-client | ||
| mvn package -DskipTests | ||
| ``` | ||
|
|
||
| This produces an executable fat JAR at `target/clickhouse-client-cli-1.0.0.jar`. | ||
|
|
||
| ## Wrapper executable | ||
|
|
||
| A wrapper script named `clickhouse-client` is provided in `bin/` directory. It is a simple shell script that calls | ||
| java application. It is required because `clickhouse-test` script calls `clickhouse-client` binary found in `PATH` environment variable. | ||
| It is recommended to set `PATH` locally in terminal session to not override real `clickhouse-client`. | ||
|
|
||
| ## Environment variables | ||
|
|
||
| | Variable | Description | | ||
| |---|---| | ||
| | `CLICKHOUSE_CLIENT_CLI_IMPL` | Backend implementation to use: `client` (default, uses client-v2 API) or `jdbc` (uses ClickHouse JDBC driver) | | ||
| | `CLICKHOUSE_CLIENT_CLI_LOG` | Path to log file for troubleshooting | | ||
|
|
||
| ## Examples | ||
|
|
||
| Run tests using the default client-v2 backend: | ||
|
|
||
| ```shell | ||
| cd ClickHouse-master | ||
| CLICKHOUSE_CLIENT_CLI_LOG=./test-run.log PATH="$PATH:/home/someuser/clickhouse-java/tests/clickhouse-client/bin/" tests/clickhouse-test 01428_hash_set_nan_key | ||
| ``` | ||
|
|
||
| Run tests using the JDBC backend: | ||
|
|
||
| ```shell | ||
| cd ClickHouse-master | ||
| CLICKHOUSE_CLIENT_CLI_IMPL=jdbc CLICKHOUSE_CLIENT_CLI_LOG=./test-run.log PATH="$PATH:/home/someuser/clickhouse-java/tests/clickhouse-client/bin/" tests/clickhouse-test 01428_hash_set_nan_key | ||
| ``` |
This file contains hidden or 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,39 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| JAR_PATH="${SCRIPT_DIR}/../target/clickhouse-client-cli-1.0.0.jar" | ||
|
|
||
| if [[ "${1:-}" == "extract-from-config" ]]; then | ||
| shift | ||
| key="" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --key) | ||
| key="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --key=*) | ||
| key="${1#--key=}" | ||
| shift | ||
| ;; | ||
| *) | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Minimal compatibility for clickhouse-test usage. | ||
| if [[ "${key}" == "listen_host" ]]; then | ||
| echo "127.0.0.1" | ||
| fi | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ ! -f "${JAR_PATH}" ]]; then | ||
| echo "Jar not found: ${JAR_PATH}" >&2 | ||
| echo "Build it first: (cd ${SCRIPT_DIR} && mvn package -DskipTests)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| exec java -jar "${JAR_PATH}" "$@" | ||
This file contains hidden or 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,104 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
| xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.clickhouse</groupId> | ||
| <artifactId>clickhouse-client-cli</artifactId> | ||
| <version>1.0.0</version> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <name>clickhouse-client-cli</name> | ||
| <description>Simple CLI tool that mimics clickhouse-client for executing SQL queries</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| <clickhouse-java.version>0.9.6-SNAPSHOT</clickhouse-java.version> | ||
| <main.class>com.clickhouse.client.cli.Main</main.class> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.clickhouse</groupId> | ||
| <artifactId>clickhouse-jdbc</artifactId> | ||
| <version>${clickhouse-java.version}</version> | ||
| <classifier>all</classifier> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| <version>2.0.13</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.commons</groupId> | ||
| <artifactId>commons-csv</artifactId> | ||
| <version>1.14.1</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>commons-cli</groupId> | ||
| <artifactId>commons-cli</artifactId> | ||
| <version>1.11.0</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-simple</artifactId> | ||
| <version>2.0.13</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <version>3.3.0</version> | ||
| <configuration> | ||
| <archive> | ||
| <manifest> | ||
| <mainClass>${main.class}</mainClass> | ||
| </manifest> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-shade-plugin</artifactId> | ||
| <version>3.5.1</version> | ||
| <executions> | ||
| <execution> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>shade</goal> | ||
| </goals> | ||
| <configuration> | ||
| <transformers> | ||
| <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
| <mainClass>${main.class}</mainClass> | ||
| </transformer> | ||
| </transformers> | ||
| <filters> | ||
| <filter> | ||
| <artifact>*:*</artifact> | ||
| <excludes> | ||
| <exclude>META-INF/*.SF</exclude> | ||
| <exclude>META-INF/*.DSA</exclude> | ||
| <exclude>META-INF/*.RSA</exclude> | ||
| </excludes> | ||
| </filter> | ||
| </filters> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.