Add Node port of ClickHouse Java's clickhouse-test-runner harness#706
Conversation
Implements step 2 of porting the Java clickhouse-client test harness: - src/backends/client.ts: @clickhouse/client backend, streams exec() output - src/backends/http.ts: built-in fetch backend, streams response.body - src/main.ts: CLI entrypoint with extract-from-config short-circuit, arg parsing, stdin fallback, impl dispatch, and diagnostic logging - bin/clickhouse: bash shim that fast-paths extract-from-config and exec's node on the built dist/main.js entrypoint - package.json: chmod +x dist/main.js after build so bin/clickhouse works Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR introduces tests/clickhouse-test-runner/, a standalone Node.js CLI harness that emulates the upstream clickhouse-client interface so the official ClickHouse tests/clickhouse-test runner can exercise @clickhouse/client against the core SQL test suite.
Changes:
- Added a Node-based
clickhouse-client-like CLI with argument parsing, multi-query splitting, logging, andextract-from-configsupport. - Implemented two execution backends (
@clickhouse/clientstreaming and raw HTTPfetch) that stream results to stdout. - Added standalone tooling/config (TypeScript, ESLint, Vitest) plus unit tests for core utilities.
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/clickhouse-test-runner/vitest.config.ts | Vitest config scoped to the harness tests. |
| tests/clickhouse-test-runner/tsconfig.json | Typecheck config for the harness sources/tests. |
| tests/clickhouse-test-runner/tsconfig.build.json | Build config emitting dist/ output. |
| tests/clickhouse-test-runner/src/split-queries.ts | Quote-aware SQL ; splitter for --multiquery. |
| tests/clickhouse-test-runner/src/settings.ts | Setting allowlists and classifier for forwarding/dropping flags. |
| tests/clickhouse-test-runner/src/main.ts | CLI entrypoint: parse args, read query, dispatch backend, set exit codes. |
| tests/clickhouse-test-runner/src/log.ts | Best-effort logging utilities with fallback path. |
| tests/clickhouse-test-runner/src/extract-from-config.ts | Implements extract-from-config --key behavior. |
| tests/clickhouse-test-runner/src/backends/http.ts | Raw HTTP backend using fetch and streaming stdout writes. |
| tests/clickhouse-test-runner/src/backends/client.ts | @clickhouse/client backend streaming raw response bytes to stdout. |
| tests/clickhouse-test-runner/src/args.ts | CLI argument parser + dynamic setting handling. |
| tests/clickhouse-test-runner/README.md | Documentation for build/usage and environment variables. |
| tests/clickhouse-test-runner/package.json | Standalone package definition + scripts/deps. |
| tests/clickhouse-test-runner/package-lock.json | Locked dependency tree for standalone installs. |
| tests/clickhouse-test-runner/eslint.config.mjs | ESLint flat config for this harness. |
| tests/clickhouse-test-runner/bin/clickhouse | Bash shim to shadow clickhouse-client and short-circuit extract-from-config. |
| tests/clickhouse-test-runner/.gitignore | Ignores build artifacts and logs. |
| tests/clickhouse-test-runner/tests/split-queries.test.ts | Unit tests for query splitting. |
| tests/clickhouse-test-runner/tests/log.test.ts | Unit tests for logging helpers. |
| tests/clickhouse-test-runner/tests/extract-from-config.test.ts | Unit tests for extract-from-config behavior. |
| tests/clickhouse-test-runner/tests/args.test.ts | Unit tests for argument parsing and setting classification. |
Files not reviewed (1)
- tests/clickhouse-test-runner/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ClickHouse/clickhouse-js/sessions/5d9d9755-83c5-4b96-971a-a23e734237b4 Co-authored-by: peter-leonov-ch <209667683+peter-leonov-ch@users.noreply.github.com>
Summary
Ports
ClickHouse/clickhouse-java/tests/clickhouse-clientto this repo astests/clickhouse-test-runner/, a small Node CLI that wraps@clickhouse/clientto mimic the upstreamclickhouse-clientbinary. With it onPATH, the officialtests/clickhouse-testrunner will exercise the JS client against the core ClickHouse SQL test suite.tests/clickhouse-test-runner/, not a workspace, only depends on@clickhouse/client) with its owntsconfig, eslint, and Vitest config.bin/clickhousebash shim — short-circuitsextract-from-config --key listen_host→127.0.0.1(the only key the upstream runner needs), otherwiseexec node dist/main.js.CLICKHOUSE_CLIENT_CLI_IMPL(mirrors Java'sclient/jdbcsplit):client(default) —client.exec({ query, clickhouse_settings: { default_format: 'TabSeparated', ... } })with the response stream piped straight to stdout (raw bytes, no decoding).http— Nodefetchagainst/?default_format=TabSeparated&...with basic auth, body-streamed to stdout with backpressure.src/args.ts) accepting both--foo barand--foo=bar, dashed/underscored variants listed as separate canonical entries inBASE_OPTIONS, short forms (-h/-u/-d/-q/-s/-n), and dynamic long options. Unknown long options are classified against SERVER/CLIENT_ONLY allowlists copied from the Java port: server settings are forwarded, client-only and unknown are silently dropped. Per review feedback,max_threadswas reclassified fromCLIENT_ONLY_SETTINGStoSERVER_SETTINGSso--max_threads=Nfrom the upstream test runner is forwarded to ClickHouse instead of being silently dropped. The unusedaliasesfield onOptionSpecwas removed since the parser never read it (dash/underscore forms work via separateBASE_OPTIONSentries).src/split-queries.ts) — tracks single/double/backtick state and\-escapes; only splits on unquoted;.CLICKHOUSE_CLIENT_CLI_LOG(default/tmp/clickhouse-client-cli.log) with CWD fallback; failures are swallowed so the CLI never breaks tests.process.exitCodeonly — neverprocess.exit()— to avoid truncating stdout writes.split-queries,args,extract-from-config, andlog. Live smoke againstdocker compose up -d clickhouseexercises both backends and--multiqueryover stdin.Usage:
The SERVER/CLIENT_ONLY allowlists are copied from the Java port and will need periodic resync as ClickHouse adds settings.
Checklist