test: add misbehaving mock ClickHouse harness (#194)#226
Draft
MukundaKatta wants to merge 1 commit intoClickHouse:mainfrom
Draft
test: add misbehaving mock ClickHouse harness (#194)#226MukundaKatta wants to merge 1 commit intoClickHouse:mainfrom
MukundaKatta wants to merge 1 commit intoClickHouse:mainfrom
Conversation
Closes ClickHouse#194 (issue, not PR). Adds a small in-process HTTP server under test/mock/ that intentionally returns malformed, partial, slow, or dropped responses so the parser and HTTP transport can be exercised against the kinds of inputs the real ClickHouse never produces. Behaviors covered: 5xx errors, unterminated array literals (the bug class fixed in ClickHouse#188), truncated chunked transfers, slow headers, truncated JSON, mid-body socket drops, trailing binary garbage, unterminated quoted strings, backslash at EOF, and Content-Length that overstates the body. Includes a 17-case pytest suite (test/mock/test_mock_clickhouse.py) that locks the wire-level shape of each behavior and is independent of PostgreSQL/ClickHouse, plus an opt-in SQL driver script (test/mock/mock_misbehaving.sql) for running the same misbehaviors through clickhouse_raw_query() once the mock is up. The SQL file lives outside test/sql/ on purpose so it does not run in make installcheck (which would fail without the mock running).
|
|
Author
|
@CLAassistant check |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #194. Adds an in-process Python
ThreadingHTTPServermock that returns malformed, partial, slow, or dropped HTTP responses, plus a 17-case pytest suite that locks down the wire-level contract of each misbehavior.Mock approach (
test/mock/mock_clickhouse.py)Dispatches on a
-- BEHAVIOR=<name>marker embedded in the request body or?behavior=query string. Each behavior emits malformed bytes directly to the socket — some bypasssend_response/shutdownmid-body — so the reallibcurl+parser.cpaths see the kinds of responses real ClickHouse never produces.Behaviors covered
5xx errors with and without
X-ClickHouse-Exception-Code, unterminated array literals (PR #188 regression class), truncated chunked transfer, slow headers / timeout exercise, truncated JSON, mid-body drops, trailing binary garbage, unterminated quoted strings, backslash at EOF, wrongContent-Length, request log.Files changed
All new, all under
test/mock/:mock_clickhouse.py— servertest_mock_clickhouse.py— pytest (17 cases)conftest.py— sys.pathmock_misbehaving.sql— opt-in SQL driver, deliberately outsidetest/sql/somake installcheckis unaffectedREADME.md— documentation761 lines total. No source code changes.
Test plan
ruff formatclean,ruff checkclean,codespellcleanpytest -v17/17 passed in 8.26s