From 32c9e47c7245d175dc0742b877993e840c9107a0 Mon Sep 17 00:00:00 2001 From: Joe Lynch Date: Thu, 24 Oct 2024 11:34:26 +0000 Subject: [PATCH] Fix keepermap test on 24.3 --- astacus/coordinator/plugins/clickhouse/client.py | 2 +- .../coordinator/plugins/clickhouse/test_plugin.py | 2 +- .../coordinator/plugins/clickhouse/test_client.py | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/astacus/coordinator/plugins/clickhouse/client.py b/astacus/coordinator/plugins/clickhouse/client.py index 0624a734..6ac56251 100644 --- a/astacus/coordinator/plugins/clickhouse/client.py +++ b/astacus/coordinator/plugins/clickhouse/client.py @@ -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( diff --git a/tests/integration/coordinator/plugins/clickhouse/test_plugin.py b/tests/integration/coordinator/plugins/clickhouse/test_plugin.py index 915442de..6699784d 100644 --- a/tests/integration/coordinator/plugins/clickhouse/test_plugin.py +++ b/tests/integration/coordinator/plugins/clickhouse/test_plugin.py @@ -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] diff --git a/tests/unit/coordinator/plugins/clickhouse/test_client.py b/tests/unit/coordinator/plugins/clickhouse/test_client.py index c10b7e7a..d485f1b9 100644 --- a/tests/unit/coordinator/plugins/clickhouse/test_client.py +++ b/tests/unit/coordinator/plugins/clickhouse/test_client.py @@ -25,7 +25,9 @@ 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"]] @@ -33,7 +35,9 @@ async def test_successful_execute_returns_rows() -> None: 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") @@ -41,7 +45,7 @@ async def test_failing_execute_raises_an_exception() -> None: 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" @@ -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")