Repository navigation
[tests] Run the ClickHouse core SQL tests through client-v2 and jdbc-v2 nightly in CI #3389
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
Open
polyglotAI-bot
wants to merge
9
commits into
main
Choose a base branch
from
polyglot/core-sql-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8861977
[tests] Core SQL test harness: clickhouse-client imitation on client-…
polyglotAI-bot cf96060
[tests] Core SQL test harness: version pin and run scripts
polyglotAI-bot 3f93ec9
[tests] Core SQL test harness: allowlist of both backends
polyglotAI-bot ff19b44
[ci] Core SQL test harness: nightly workflow
polyglotAI-bot 671f68e
[tests] Core SQL test harness: README, AGENTS.md, CLAUDE.md
polyglotAI-bot 256cb1c
[tests] Core SQL test harness: runner retries, Raw header, heredoc words
polyglotAI-bot bfa5a56
[tests] Core SQL test harness: check the types line of the Raw header
polyglotAI-bot 239be91
[tests] Core SQL test harness: hide the --password value in the invoc…
polyglotAI-bot a34340f
[tests] Core SQL test harness: keep AGENTS.md minimal
polyglotAI-bot 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,239 @@ | ||
| name: Upstream SQL tests | ||
|
|
||
| # Runs a curated subset of the ClickHouse core SQL tests | ||
| # (tests/queries/0_stateless) through clickhouse-java, with the `client` | ||
| # (client-v2) and the `jdbc` (jdbc-v2) backend of tests/clickhouse-client. | ||
| # See tests/clickhouse-client/README.md. | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| clickhouse_version: | ||
| description: "ClickHouse version to try, for example 26.11.1.10 (default: tests/clickhouse-client/clickhouse-version)" | ||
| required: false | ||
| default: "" | ||
| type: string | ||
| schedule: | ||
| - cron: "0 4 * * *" | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "tests/clickhouse-client/**" | ||
| - ".github/workflows/upstream-sql-tests.yml" | ||
| pull_request: | ||
| paths: | ||
| - "tests/clickhouse-client/**" | ||
| - ".github/workflows/upstream-sql-tests.yml" | ||
|
|
||
| # A new push to a pull request cancels the older run of that pull request. | ||
| # Other runs (nightly, manual tries of other versions, pushes) do not cancel | ||
| # each other. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| # Builds the shim against the clickhouse-java source of this commit, runs its | ||
| # unit and live tests, and gives the jar to the test jobs. | ||
| build: | ||
| name: Build the shim | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install JDK 8 and 17, and Maven | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: | | ||
| 8 | ||
| 17 | ||
| cache: "maven" | ||
|
|
||
| # The same toolchain as in build.yml (see CONTRIBUTING.md). | ||
| - name: Setup Toolchain | ||
| shell: bash | ||
| run: | | ||
| mkdir -p "$HOME/.m2" \ | ||
| && cat << EOF > "$HOME/.m2/toolchains.xml" | ||
| <?xml version="1.0" encoding="UTF8"?> | ||
| <toolchains> | ||
| <toolchain> | ||
| <type>jdk</type> | ||
| <provides> | ||
| <version>17</version> | ||
| </provides> | ||
| <configuration> | ||
| <jdkHome>${{ env.JAVA_HOME }}</jdkHome> | ||
| </configuration> | ||
| </toolchain> | ||
| </toolchains> | ||
| EOF | ||
|
|
||
| # The server version and the upstream tests are pinned together in | ||
| # tests/clickhouse-client/clickhouse-version: the `.reference` files of | ||
| # another release do not match the output of the server. A new server | ||
| # release changes nothing here until a pull request bumps the pin. The | ||
| # `clickhouse_version` input of a manual run tries another version | ||
| # without a commit. | ||
| - name: Select the ClickHouse version | ||
| id: version | ||
| env: | ||
| INPUT_VERSION: ${{ github.event.inputs.clickhouse_version }} | ||
| run: | | ||
| version="${INPUT_VERSION:-$(tests/clickhouse-client/scripts/pinned-version.sh)}" | ||
| if ! [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::clickhouse_version must be a full version such as 26.10.4.207 (got: '${version}')" | ||
| exit 1 | ||
| fi | ||
| echo "version=${version}" >> "${GITHUB_OUTPUT}" | ||
|
|
||
| # The stock server configuration. CLICKHOUSE_SKIP_USER_SETUP keeps the | ||
| # `default` user of the image's users.xml: network access, access | ||
| # management and named-collection control (tests create users, roles | ||
| # and named collections). Without it, the image allows the user without | ||
| # a password only from localhost in the container. | ||
| # | ||
| # The server gets the host name of the runner: tests/clickhouse-test | ||
| # replaces its own host name with `localhost` in the output of each | ||
| # test, and some `.reference` files have `localhost` for hostName(). | ||
| - name: Start ClickHouse ${{ steps.version.outputs.version }} | ||
| env: | ||
| CLICKHOUSE_VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| docker run -d --name clickhouse -p 8123:8123 -p 9000:9000 \ | ||
| --hostname "$(hostname)" \ | ||
| --ulimit nofile=262144:262144 -e CLICKHOUSE_SKIP_USER_SETUP=1 \ | ||
| "clickhouse/clickhouse-server:${CLICKHOUSE_VERSION}" | ||
| for _ in $(seq 1 60); do | ||
| if curl -fsS "http""://localhost:8123/ping" > /dev/null 2>&1; then | ||
| exit 0 | ||
| fi | ||
| sleep 2 | ||
| done | ||
| docker logs clickhouse | ||
| echo "::error::ClickHouse did not start" | ||
| exit 1 | ||
|
|
||
| # The checkout also generates the error code table of the shim, so that | ||
| # the jar knows the error names of the tests of this version. | ||
| - name: Get the upstream tests of ClickHouse ${{ steps.version.outputs.version }} | ||
| run: tests/clickhouse-client/scripts/fetch-upstream.sh "${{ steps.version.outputs.version }}" | ||
|
|
||
| # For the pinned version, the generated table must be the committed one. | ||
| - name: Check the committed error code table | ||
| if: github.event.inputs.clickhouse_version == '' | ||
| run: | | ||
| file=tests/clickhouse-client/src/main/resources/com/clickhouse/client/cli/error-codes.tsv | ||
| if ! git diff --exit-code -- "${file}"; then | ||
| echo "::error::${file} does not match the pinned version. Run scripts/fetch-upstream.sh and commit the file." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Build the shim, with its unit and live tests | ||
| env: | ||
| CLICKHOUSE_CLIENT_CLI_LIVE: "1" | ||
| run: tests/clickhouse-client/scripts/build.sh | ||
|
|
||
| - name: Upload the shim | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: clickhouse-client-cli | ||
| path: tests/clickhouse-client/target/clickhouse-client-cli-1.0.0.jar | ||
| if-no-files-found: error | ||
| # A re-run of failed test jobs does not build again. | ||
| retention-days: 7 | ||
|
|
||
| upstream-sql-tests: | ||
| name: Upstream SQL tests (${{ matrix.backend }}, shard ${{ matrix.shard }}) | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| backend: [client, jdbc] | ||
| # Round-robin shards of the allowlist, about 1,260 tests each. One | ||
| # jdbc shard took about 3.5 minutes at -j 4 with the server and the | ||
| # shim on 4 CPUs, so a shard takes a few minutes on a 4-vCPU runner. | ||
| # Change SHARD_TOTAL below together with this list. | ||
| shard: [1, 2, 3, 4, 5, 6, 7, 8] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: 17 | ||
|
|
||
| - name: Install Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install Python dependencies of tests/clickhouse-test | ||
| run: pip install jinja2 | ||
|
|
||
| # The same server as in the build job. | ||
| - name: Start ClickHouse ${{ needs.build.outputs.version }} | ||
| env: | ||
| CLICKHOUSE_VERSION: ${{ needs.build.outputs.version }} | ||
| run: | | ||
| docker run -d --name clickhouse -p 8123:8123 -p 9000:9000 \ | ||
| --hostname "$(hostname)" \ | ||
| --ulimit nofile=262144:262144 -e CLICKHOUSE_SKIP_USER_SETUP=1 \ | ||
| "clickhouse/clickhouse-server:${CLICKHOUSE_VERSION}" | ||
| for _ in $(seq 1 60); do | ||
| if curl -fsS "http""://localhost:8123/ping" > /dev/null 2>&1; then | ||
| exit 0 | ||
| fi | ||
| sleep 2 | ||
| done | ||
| docker logs clickhouse | ||
| echo "::error::ClickHouse did not start" | ||
| exit 1 | ||
|
|
||
| - name: Get the upstream tests of ClickHouse ${{ needs.build.outputs.version }} | ||
| id: upstream | ||
| run: tests/clickhouse-client/scripts/fetch-upstream.sh "${{ needs.build.outputs.version }}" | ||
|
|
||
| - name: Download the shim | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: clickhouse-client-cli | ||
| path: tests/clickhouse-client/target | ||
|
|
||
| # No RETRY_FAILED: no known client bug makes random tests fail, so a | ||
| # failed test fails the job. | ||
| - name: Run upstream SQL tests | ||
| env: | ||
| CLICKHOUSE_CLIENT_CLI_IMPL: ${{ matrix.backend }} | ||
| CLICKHOUSE_CLIENT_CLI_LOG: ${{ github.workspace }}/upstream-run.log | ||
| SKIP_BUILD: "1" | ||
| SHARD_INDEX: ${{ matrix.shard }} | ||
| SHARD_TOTAL: 8 | ||
| run: tests/clickhouse-client/scripts/run-upstream-tests.sh -j 4 | ||
|
|
||
| # The runner writes the diff of a failed test to the job log, and the | ||
| # output of the test next to it (<test>.<pid>.stdout and .stderr). | ||
| - name: Upload test artifacts | ||
| if: failure() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: upstream-sql-tests-${{ steps.upstream.outputs.ref }}-${{ matrix.backend }}-shard-${{ matrix.shard }} | ||
| retention-days: 14 | ||
| if-no-files-found: ignore | ||
| path: | | ||
| upstream-run.log | ||
| tests/clickhouse-client/.upstream/ClickHouse/tests/queries/**/*.stdout | ||
| tests/clickhouse-client/.upstream/ClickHouse/tests/queries/**/*.stderr |
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,5 @@ | ||
| # The root .gitignore ignores *.sh; the scripts of the harness are part of it. | ||
| !scripts/*.sh | ||
| .bin-real-client/ | ||
| .upstream/ | ||
| .real-client/ |
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,40 @@ | ||
| # Instructions for agents: core SQL test harness | ||
|
|
||
| This harness runs the ClickHouse core SQL tests through clickhouse-java, with | ||
| the `client` (client-v2) and the `jdbc` (jdbc-v2) backend. | ||
| [`README.md`](README.md) tells how it works, how to run it, and how to find | ||
| the cause of a failure. | ||
|
|
||
| The goal is to find bugs in clickhouse-java, not to pass more tests. A failed | ||
| test is information. Do not hide it. | ||
|
|
||
| ## Rules | ||
|
|
||
| 1. **Find the cause of a failure before you do anything with the test** | ||
| ([steps](README.md#find-the-cause-of-a-failure)). The cause is the client | ||
| (client-v2, jdbc-v2, or `clickhouse-data`), the shim (the program in this | ||
| directory), or the environment (the test cannot pass through any client on | ||
| this server, see [Environment causes](README.md#environment-causes)). | ||
| 2. **Fix a client bug in the client**, in a pull request of its own with a | ||
| test in the module. Do not fix it in a pull request that changes the | ||
| harness. | ||
| 3. **Fix a shim bug in the shim**: make it copy `clickhouse-client` more | ||
| exactly. Do not change the shim to hide a client bug (another read method, | ||
| a type-name workaround, a correction of a wrong value). `client` reads each | ||
| value with `ClickHouseBinaryFormatReader.readValue(i)`, `jdbc` with | ||
| `ResultSet.getObject(i)`. | ||
| 4. **A test that fails because of a client bug or a shim gap stays visible** | ||
| in [`allowlist.txt`](allowlist.txt), as a known failure in the group of its | ||
| cause. Do not delete it. See [The allowlist](README.md#the-allowlist) for | ||
| the format. | ||
| 5. **Only an environment cause removes a test** from the allowlist, or gives | ||
| it `# only=<backend>: <reason>` when it fails on one backend only. Write | ||
| the reason in the commit message. | ||
| 6. **Add only tests that pass reliably** | ||
| ([Grow the allowlist](README.md#grow-the-allowlist)). | ||
| 7. **Bump the server version in a pull request of its own** | ||
| ([Bump the server version](README.md#bump-the-server-version)). | ||
| 8. **Keep the documents in sync.** When you change the behavior of the shim | ||
| (flags, statement handling, output formats, settings, environment | ||
| variables), update `README.md`, the usage text of the shim | ||
| (`CliOptions.usage`) and the workflow in the same change. | ||
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 @@ | ||
| @AGENTS.md |
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.