Skip to content

Commit

Permalink
Fix keepermap test on 24.3
Browse files Browse the repository at this point in the history
  • Loading branch information
joelynch committed Oct 24, 2024
1 parent 7d39946 commit 32c9e47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
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

0 comments on commit 32c9e47

Please sign in to comment.