mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-09 17:14:47 +00:00
Merge pull request #66063 from vitlibar/fix-test-grpc-protocol-test-progress
Fix test test_grpc_protocol/test.py::test_progress
This commit is contained in:
commit
196df125b1
@ -370,47 +370,33 @@ def test_progress():
|
||||
"SELECT number, sleep(0.31) FROM numbers(8) SETTINGS max_block_size=2, interactive_delay=100000",
|
||||
stream_output=True,
|
||||
)
|
||||
results = list(results)
|
||||
for result in results:
|
||||
result.time_zone = ""
|
||||
result.query_id = ""
|
||||
# print(results)
|
||||
|
||||
# Note: We can't convert those messages to string like `results = str(results)` and then compare it as a string
|
||||
# because str() can serialize a protobuf message with any order of fields.
|
||||
expected_results = [
|
||||
clickhouse_grpc_pb2.Result(
|
||||
output_format="TabSeparated",
|
||||
progress=clickhouse_grpc_pb2.Progress(
|
||||
read_rows=2, read_bytes=16, total_rows_to_read=8
|
||||
),
|
||||
),
|
||||
clickhouse_grpc_pb2.Result(output=b"0\t0\n1\t0\n"),
|
||||
clickhouse_grpc_pb2.Result(
|
||||
progress=clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16)
|
||||
),
|
||||
clickhouse_grpc_pb2.Result(output=b"2\t0\n3\t0\n"),
|
||||
clickhouse_grpc_pb2.Result(
|
||||
progress=clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16)
|
||||
),
|
||||
clickhouse_grpc_pb2.Result(output=b"4\t0\n5\t0\n"),
|
||||
clickhouse_grpc_pb2.Result(
|
||||
progress=clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16)
|
||||
),
|
||||
clickhouse_grpc_pb2.Result(output=b"6\t0\n7\t0\n"),
|
||||
clickhouse_grpc_pb2.Result(
|
||||
stats=clickhouse_grpc_pb2.Stats(
|
||||
rows=8,
|
||||
blocks=4,
|
||||
allocated_bytes=1092,
|
||||
)
|
||||
),
|
||||
# Note: We can't compare results using a statement like `assert results == expected_results`
|
||||
# because `results` can come in slightly different order.
|
||||
# So we compare `outputs` and `progresses` separately and not `results` as a whole.
|
||||
|
||||
outputs = [i.output for i in results if i.output]
|
||||
progresses = [i.progress for i in results if i.HasField("progress")]
|
||||
|
||||
# print(outputs)
|
||||
# print(progresses)
|
||||
|
||||
expected_outputs = [
|
||||
b"0\t0\n1\t0\n",
|
||||
b"2\t0\n3\t0\n",
|
||||
b"4\t0\n5\t0\n",
|
||||
b"6\t0\n7\t0\n",
|
||||
]
|
||||
|
||||
# Stats data can be returned, which broke the test
|
||||
results = [i for i in results if not isinstance(i, clickhouse_grpc_pb2.Stats)]
|
||||
expected_progresses = [
|
||||
clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16, total_rows_to_read=8),
|
||||
clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16),
|
||||
clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16),
|
||||
clickhouse_grpc_pb2.Progress(read_rows=2, read_bytes=16),
|
||||
]
|
||||
|
||||
assert results == expected_results
|
||||
assert outputs == expected_outputs
|
||||
assert progresses == expected_progresses
|
||||
|
||||
|
||||
def test_session_settings():
|
||||
|
Loading…
Reference in New Issue
Block a user