Skip to content

Commit 7c40c86

Browse files
rustyconoverclaude
andcommitted
test(conformance): converge on the shared compression-disabled fixture
The compression-disabled conformance coverage added here locally has now landed centrally (vgi-rpc-python be1a7a6), so this repo converges onto it rather than keeping a parallel copy. - Fixture renamed ts_http_no_compression_port -> conformance_http_no_compression_port, the name the shared suite looks up. The name is load-bearing: the shared case resolves it by string literal and *skips* rather than fails on a mismatch, so a rename would silently stop testing this port. Noted in the docstring. - The local TestResponseCompressionDisabled class is deleted outright. The shared case subsumes both of its tests exactly -- same OPTIONS /health probe, same present-and-empty assertions, same both-headers zstd request, same "no codec claimed" check. A local test that duplicates the conformance suite keeps passing while this port drifts from the others, which is the failure mode the shared suite exists to prevent. The worker needed no change: the --response-compression off flag added earlier is exactly what the shared fixture drives. Verified against the suite at be1a7a6: 6 passed, 0 skipped for the -k Compression selection, and non-vacuous -- dropping the flag from the fixture fails with `expected an empty advertisement, got ['zstd', 'gzip']`. Note on CI reachability: ci.yml installs vgi-rpc from PyPI, and no released version carries this class yet (it is four commits past v0.25.0, verified against an installed 0.25.0). Until a release ships, CI does not skip these cases -- it does not collect them at all, so their absence is silent rather than reported. The fixture sits unused and harmless until then. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9bd88c2 commit 7c40c86

1 file changed

Lines changed: 14 additions & 62 deletions

File tree

test_ts_conformance.py

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def conformance_http_port(ts_http_port: int) -> int:
109109

110110

111111
@pytest.fixture(scope="session")
112-
def ts_http_no_compression_port() -> Iterator[int]:
112+
def conformance_http_no_compression_port() -> Iterator[int]:
113113
"""Bun conformance HTTP server with response compression explicitly OFF.
114114
115115
Response compression is on by default (zstd level 1), so every other HTTP
@@ -118,6 +118,12 @@ def ts_http_no_compression_port() -> Iterator[int]:
118118
compression", as distinct from an absent header meaning "legacy server,
119119
assume zstd" — is only reachable through an explicit
120120
``compressionLevel: null``, which ``--response-compression off`` passes.
121+
122+
The name is load-bearing: the shared suite's
123+
``TestHttpCompressionNegotiationConformance::test_empty_advertisement_means_never_compressed``
124+
looks this fixture up by literal name via ``request.getfixturevalue`` and
125+
*skips* if it is absent, so a rename here silently stops testing the TS
126+
worker rather than failing.
121127
"""
122128
proc, port = _start_http_server([*BUN_HTTP_WORKER, "--response-compression", "off"])
123129
yield port
@@ -508,64 +514,10 @@ def test_error_on_init(self, conformance_conn: ConnFactory) -> None:
508514
# Hook lives in conftest.py (next to this file) — pytest does not pick up
509515
# `pytest_collection_modifyitems` defined inside a test module.
510516

511-
512-
class TestResponseCompressionDisabled:
513-
"""The explicitly-disabled compression path, kept alive after the default flip.
514-
515-
Response compression now defaults to ON (zstd level 1), so the upstream
516-
``TestHttpCompressionNegotiationConformance`` suite — which runs against
517-
``conformance_http_port`` — takes its compressing branches and *skips*
518-
``test_empty_advertisement_means_never_compressed``. These two cases pin
519-
the other branch against a worker started with ``--response-compression
520-
off``, so turning compression off stays a supported, tested configuration
521-
rather than an accident of the old default.
522-
523-
Deliberately self-contained (no import from the upstream suite) so it runs
524-
against any released ``vgi-rpc``.
525-
"""
526-
527-
# Large and highly compressible: nothing about the payload should stop a
528-
# compressing server, so an uncompressed answer is the server's own choice.
529-
PAYLOAD = "conformance-compression-probe " * 4096
530-
531-
def test_advertisement_is_present_but_empty(self, ts_http_no_compression_port: int) -> None:
532-
import httpx
533-
534-
resp = httpx.options(f"http://127.0.0.1:{ts_http_no_compression_port}/health", timeout=5.0)
535-
raw = resp.headers.get("VGI-Supported-Encodings")
536-
# Absent would mean "legacy server, assume zstd" — the opposite claim.
537-
assert raw is not None, "header must be present, not omitted"
538-
assert [t for t in raw.split(",") if t.strip()] == []
539-
540-
def test_never_compresses_however_asked(self, ts_http_no_compression_port: int) -> None:
541-
from io import BytesIO
542-
543-
import httpx
544-
from vgi_rpc.conformance import ConformanceService
545-
from vgi_rpc.http._common import _ARROW_CONTENT_TYPE
546-
from vgi_rpc.rpc import rpc_methods
547-
from vgi_rpc.rpc._wire import _write_request
548-
549-
info = rpc_methods(ConformanceService)["echo_string"]
550-
version = vars(ConformanceService).get("protocol_version")
551-
buf = BytesIO()
552-
_write_request(
553-
buf,
554-
"echo_string",
555-
info.params_schema,
556-
{"value": self.PAYLOAD},
557-
protocol_version=version if isinstance(version, str) else None,
558-
)
559-
resp = httpx.post(
560-
f"http://127.0.0.1:{ts_http_no_compression_port}/echo_string",
561-
content=buf.getvalue(),
562-
headers={
563-
"Content-Type": _ARROW_CONTENT_TYPE,
564-
"Accept-Encoding": "zstd, gzip",
565-
"X-VGI-Accept-Encoding": "zstd, gzip",
566-
},
567-
timeout=30.0,
568-
)
569-
assert resp.status_code == 200, f"{resp.status_code}: {resp.content[:200]!r}"
570-
assert resp.headers.get("Content-Encoding") is None
571-
assert resp.headers.get("X-VGI-Content-Encoding") is None
517+
# The repo-local ``TestResponseCompressionDisabled`` that used to live here was
518+
# removed once the same ground landed centrally as
519+
# ``TestHttpCompressionNegotiationConformance::test_empty_advertisement_means_never_compressed``
520+
# (vgi-rpc-python be1a7a6), which now drives the ``--response-compression off``
521+
# worker through the ``conformance_http_no_compression_port`` fixture above.
522+
# A local copy would keep passing while this port drifted from the other four
523+
# SDKs — precisely the failure the shared suite exists to catch.

0 commit comments

Comments
 (0)