Skip to content
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

Fix keepermap test on 24.3 #250

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astacus/coordinator/plugins/clickhouse/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def execute(self, query: bytes, timeout: float | None = None, session_id:
if self.password is not None:
headers.append(("X-ClickHouse-Key", self.password))
netloc = build_netloc(self.host, self.port)
params = {"wait_end_of_query": "1"}
params = {"wait_end_of_query": "1", "http_write_exception_in_output_format": "0"}
if session_id is not None:
params["session_id"] = session_id
response = await httpx_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,4 +625,4 @@ async def test_restores_keeper_map_tables(restored_cluster: Sequence[ClickHouseC
assert result == []
with pytest.raises(ClickHouseClientQueryError) as e:
await client.execute(b"SELECT * FROM default.keeper_map_dropped")
assert "Table default.keeper_map_dropped does not exist." in e.value.args[0]
assert "UNKNOWN_TABLE" in e.value.args[0]
14 changes: 10 additions & 4 deletions tests/unit/coordinator/plugins/clickhouse/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,27 @@ async def test_successful_execute_returns_rows() -> None:
"rows": 2,
"rows_before_limit_at_least": 2,
}
respx.post("http://example.org:9000?wait_end_of_query=1").respond(json=content)
respx.post("http://example.org:9000?wait_end_of_query=1&http_write_exception_in_output_format=0").respond(
json=content
)
response = await client.execute(b"SHOW DATABASES")
assert response == [["system"], ["defaultdb"]]


async def test_failing_execute_raises_an_exception() -> None:
client = HttpClickHouseClient(host="example.org", port=9000)
with respx.mock:
respx.post("http://example.org:9000?wait_end_of_query=1").respond(status_code=400)
respx.post("http://example.org:9000?wait_end_of_query=1&http_write_exception_in_output_format=0").respond(
status_code=400
)
with pytest.raises(ClickHouseClientQueryError):
await client.execute(b"SHOW DATABASES")


async def test_sends_authentication_headers() -> None:
client = HttpClickHouseClient(host="example.org", port=9000, username="user", password="password")
with respx.mock:
respx.post("http://example.org:9000?wait_end_of_query=1").respond(content="")
respx.post("http://example.org:9000?wait_end_of_query=1&http_write_exception_in_output_format=0").respond(content="")
await client.execute(b"SELECT 1 LIMIT 0")
request = respx.calls[0][0]
assert request.headers["x-clickhouse-user"] == "user"
Expand All @@ -51,7 +55,9 @@ async def test_sends_authentication_headers() -> None:
async def test_sends_session_id_as_parameter() -> None:
client = HttpClickHouseClient(host="example.org", port=9000)
with respx.mock:
respx.post("http://example.org:9000?wait_end_of_query=1&session_id=something").respond(content="")
respx.post(
"http://example.org:9000?wait_end_of_query=1&http_write_exception_in_output_format=0&session_id=something"
).respond(content="")
await client.execute(b"SELECT 1 LIMIT 0", session_id="something")


Expand Down
Loading