Skip to content

Commit 11f58c1

Browse files
committed
test: reject previous protocol minor workers
1 parent 0d344ab commit 11f58c1

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎tests/conformance/test_protocol_version.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
# The version the real Python client / C++ extension declares and sends.
3030
CLIENT_PROTOCOL_VERSION = VgiProtocol.protocol_version
31+
PREVIOUS_MINOR_PROTOCOL_VERSION = "3.0.0"
3132

3233

3334
def test_client_protocol_version_is_canonical() -> None:
@@ -57,3 +58,25 @@ def test_mismatched_worker_protocol_version_raises() -> None:
5758
assert BAD_PROTOCOL_VERSION in message
5859
# Directional hint: the client (3.1.0) is older than the worker (99.0.0).
5960
assert "upgrade the VGI extension/client" in message
61+
62+
63+
def test_previous_minor_worker_is_rejected_instead_of_silently_backfilled() -> None:
64+
"""A 3.1 client must not interpret a 3.0 response with a different schema."""
65+
command = [
66+
"env",
67+
f"VGI_BAD_PROTOCOL_VERSION={PREVIOUS_MINOR_PROTOCOL_VERSION}",
68+
"vgi-fixture-bad-protocol-worker",
69+
]
70+
with Client(command, pool=None) as client, pytest.raises(ClientError) as exc_info:
71+
list(
72+
client.table_function(
73+
function_name="sequence",
74+
schema_path=["main"],
75+
arguments=Arguments(positional=(pa.scalar(5),)),
76+
)
77+
)
78+
79+
message = str(exc_info.value)
80+
assert "protocol_version mismatch" in message
81+
assert CLIENT_PROTOCOL_VERSION in message
82+
assert PREVIOUS_MINOR_PROTOCOL_VERSION in message

‎vgi/_test_fixtures/bad_protocol.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
subclass's body is what takes effect.
1616
1717
A normal client (Python ``Client`` or the C++ extension) declares
18-
``protocol_version = "1.0.0"`` and sends it on every request. Because this
19-
worker enforces ``"99.0.0"``, the major versions differ and the dispatch
20-
boundary raises ``ProtocolVersionError`` with a directional "upgrade the
21-
client" message that round-trips back to the caller.
18+
``protocol_version = "3.1.0"`` and sends it on every request. Because this
19+
worker defaults to ``"99.0.0"``, the major/minor versions differ and the
20+
dispatch boundary raises ``ProtocolVersionError`` with a directional upgrade
21+
message that round-trips back to the caller. Tests may override the worker to
22+
``"3.0.0"`` to exercise the real previous-minor rollout boundary.
2223
2324
Otherwise this is a drop-in replacement for ``vgi-fixture-worker``: it
2425
inherits every function and the catalog from :class:`ExampleWorker`, so any
@@ -30,15 +31,17 @@
3031

3132
from __future__ import annotations
3233

34+
import os
3335
from typing import ClassVar
3436

3537
from vgi._test_fixtures.worker import ExampleWorker
3638
from vgi.protocol import VgiProtocol
3739

38-
# A major-version bump guarantees a mismatch against any real client's
39-
# "1.0.0" (vgi-rpc compares major+minor exactly, ignoring patch). Declared on
40+
# A major-version bump guarantees a mismatch against any real client. Tests can
41+
# override this with a previous minor (for example 3.0.0 versus 3.1.0) to prove
42+
# that the production rolling-upgrade boundary is enforced too. Declared on
4043
# this class body so ``vars(BadProtocol)["protocol_version"]`` resolves to it.
41-
BAD_PROTOCOL_VERSION = "99.0.0"
44+
BAD_PROTOCOL_VERSION = os.environ.get("VGI_BAD_PROTOCOL_VERSION", "99.0.0")
4245

4346

4447
class BadProtocol(VgiProtocol):

0 commit comments

Comments
 (0)