Skip to content

Commit 68e7242

Browse files
Do not assert the host-default divergence under HAProxy mode
RAY_SERVE_ENABLE_HA_PROXY=1 sets DEFAULT_HTTP_HOST to all interfaces, which is what HTTPOptionsSchema already defaults to, so the two models agree and the new test failed only in the haproxy premerge step. Pin the declared-vs-dumped behavior on a port instead, which does not move with the environment, and keep the host divergence as its own skip_if_haproxy test. Signed-off-by: john.taylor <john.taylor@anyscale.com>
1 parent fbd9054 commit 68e7242

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

python/ray/serve/tests/unit/test_start_time_config.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
from ray.serve._private.grpc_util import set_proxy_default_grpc_options
1111
from ray.serve._private.http_util import configure_http_options_with_defaults
12+
from ray.serve._private.test_utils import skip_if_haproxy
1213
from ray.serve.config import HTTPOptions, ProxyLocation, gRPCOptions
1314
from ray.serve.exceptions import RayServeConfigException
1415
from ray.serve.schema import ServeDeploySchema
@@ -86,17 +87,30 @@ def test_full_schema_dump_is_not_a_change():
8687

8788

8889
def test_declarative_config_reports_only_what_it_declared():
89-
"""A config that omits a section must not request that section's defaults.
90+
"""A config that omits a section must not request that section's defaults."""
91+
client = fake_client(HTTPOptions(port=8001))
92+
config = ServeDeploySchema.model_validate({"applications": []})
93+
_check_start_time_config_unchanged(client, **declared_start_time_options(config))
94+
95+
# The full dump is what the same paths pass to *start* Serve, and it does differ.
96+
with pytest.raises(RayServeConfigException, match=r"http_options\.port"):
97+
_check_start_time_config_unchanged(
98+
client, http_options=config.http_options.model_dump()
99+
)
100+
101+
102+
@skip_if_haproxy("HAProxy mode defaults host to all interfaces, as the schema does")
103+
def test_schema_and_internal_host_defaults_diverge():
104+
"""The divergence that makes the full dump reject an untouched config.
90105
91106
`HTTPOptionsSchema.host` defaults to 0.0.0.0 while `HTTPOptions.host` defaults
92-
to the loopback, so diffing the full dump rejects every declarative apply to a
93-
Serve instance that was started from Python.
107+
to the loopback, so a config with no http_options rejects every declarative
108+
apply to a Serve instance started from Python.
94109
"""
95110
client = fake_client()
96111
config = ServeDeploySchema.model_validate({"applications": []})
97112
_check_start_time_config_unchanged(client, **declared_start_time_options(config))
98113

99-
# The full dump is what the same paths pass to *start* Serve, and it does differ.
100114
with pytest.raises(RayServeConfigException, match=r"http_options\.host"):
101115
_check_start_time_config_unchanged(
102116
client, http_options=config.http_options.model_dump()

0 commit comments

Comments
 (0)