Compare commits

...

3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
f183ed607f Use constants consistently across all test functions
Co-authored-by: mykaul <4655593+mykaul@users.noreply.github.com>
2025-12-14 16:03:24 +00:00
copilot-swe-agent[bot]
deb3bc5b83 Apply code review fixes to test_protocol_exceptions.py
Co-authored-by: mykaul <4655593+mykaul@users.noreply.github.com>
2025-12-14 16:01:49 +00:00
copilot-swe-agent[bot]
2f32e37beb Initial plan 2025-12-14 15:58:43 +00:00

View File

@@ -13,6 +13,10 @@ import struct
from test.cqlpy import nodetool
from test.cqlpy.util import cql_session
# Module-level constants for test parameters
RUN_COUNT = 200
CPP_EXCEPTION_THRESHOLD = 20
def get_protocol_error_metrics(host) -> int:
result = 0
metrics = requests.get(f"http://{host}:9180/metrics").text
@@ -51,7 +55,6 @@ def cql_with_protocol(host_str, port, creds, protocol_version):
protocol_version=protocol_version,
) as session:
yield session
session.shutdown()
except NoHostAvailable:
yield None
@@ -101,8 +104,8 @@ def debug_exceptions_logging(request, cql):
# If there is a protocol version mismatch, the server should
# raise a protocol error, which is counted in the metrics.
def test_protocol_version_mismatch(scylla_only, debug_exceptions_logging, request, host):
run_count = 200
cpp_exception_threshold = 20
run_count = RUN_COUNT
cpp_exception_threshold = CPP_EXCEPTION_THRESHOLD
cpp_exception_metrics_before = get_cpp_exceptions_metrics(host)
protocol_exception_metrics_before = get_protocol_error_metrics(host)
@@ -141,8 +144,9 @@ def _build_frame(*, opcode: int, stream: int, body: bytes) -> bytearray:
def _send_frame(sock: socket.socket, *, opcode: int, stream: int, body: bytes) -> None:
sock.send(_build_frame(opcode=opcode, stream=stream, body=body))
MAX_RECV_FRAME_SIZE = 4096
def _recv_frame(sock: socket.socket) -> bytes:
return sock.recv(4096)
return sock.recv(MAX_RECV_FRAME_SIZE)
# Many protocol errors are caused by sending malformed messages.
# It is not possible to reproduce them with the Python driver,
@@ -284,8 +288,8 @@ def _protocol_error_impl(
s.close()
def _test_impl(host, flag):
run_count = 200
cpp_exception_threshold = 20
run_count = RUN_COUNT
cpp_exception_threshold = CPP_EXCEPTION_THRESHOLD
cpp_exception_metrics_before = get_cpp_exceptions_metrics(host)
protocol_exception_metrics_before = get_protocol_error_metrics(host)
@@ -346,8 +350,8 @@ def test_process_register_malformed_string_list(scylla_only, no_ssl, debug_excep
# This is to ensure that the protocol exceptions are not cleared or reset
# during the test execution.
def test_no_protocol_exceptions(scylla_only, no_ssl, debug_exceptions_logging, host):
run_count = 200
cpp_exception_threshold = 20
run_count = RUN_COUNT
cpp_exception_threshold = CPP_EXCEPTION_THRESHOLD
cpp_exception_metrics_before = get_cpp_exceptions_metrics(host)
protocol_exception_metrics_before = get_protocol_error_metrics(host)