|
9 | 9 | ) |
10 | 10 | from ray.serve._private.grpc_util import set_proxy_default_grpc_options |
11 | 11 | from ray.serve._private.http_util import configure_http_options_with_defaults |
| 12 | +from ray.serve._private.test_utils import skip_if_haproxy |
12 | 13 | from ray.serve.config import HTTPOptions, ProxyLocation, gRPCOptions |
13 | 14 | from ray.serve.exceptions import RayServeConfigException |
14 | 15 | from ray.serve.schema import ServeDeploySchema |
@@ -86,17 +87,30 @@ def test_full_schema_dump_is_not_a_change(): |
86 | 87 |
|
87 | 88 |
|
88 | 89 | 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. |
90 | 105 |
|
91 | 106 | `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. |
94 | 109 | """ |
95 | 110 | client = fake_client() |
96 | 111 | config = ServeDeploySchema.model_validate({"applications": []}) |
97 | 112 | _check_start_time_config_unchanged(client, **declared_start_time_options(config)) |
98 | 113 |
|
99 | | - # The full dump is what the same paths pass to *start* Serve, and it does differ. |
100 | 114 | with pytest.raises(RayServeConfigException, match=r"http_options\.host"): |
101 | 115 | _check_start_time_config_unchanged( |
102 | 116 | client, http_options=config.http_options.model_dump() |
|
0 commit comments