MCPcopy
hub / github.com/ray-project/ray / test_deploy_basic

Function test_deploy_basic

python/ray/serve/tests/test_cli.py:105–176  ·  view source on GitHub ↗

Deploys some valid config files and checks that the deployments work.

(serve_instance)

Source from the content-addressed store, hash-verified

103
104@pytest.mark.skipif(sys.platform == "win32", reason="File path incorrect on Windows.")
105def test_deploy_basic(serve_instance):
106 """Deploys some valid config files and checks that the deployments work."""
107 # Create absolute file names to YAML config files
108 pizza_file_name = os.path.join(
109 os.path.dirname(__file__), "test_config_files", "pizza.yaml"
110 )
111 arithmetic_file_name = os.path.join(
112 os.path.dirname(__file__), "test_config_files", "arithmetic.yaml"
113 )
114
115 success_message_fragment = b"Sent deploy request successfully."
116
117 # Ensure the CLI is idempotent
118 num_iterations = 2
119 for iteration in range(1, num_iterations + 1):
120 print(f"*** Starting Iteration {iteration}/{num_iterations} ***\n")
121
122 print("Deploying pizza config.")
123 deploy_response = subprocess.check_output(["serve", "deploy", pizza_file_name])
124 assert success_message_fragment in deploy_response
125 print("Deploy request sent successfully.")
126
127 wait_for_condition(
128 check_http_response,
129 json=["ADD", 2],
130 expected_text="3 pizzas please!",
131 timeout=15,
132 )
133 wait_for_condition(
134 check_http_response,
135 json=["MUL", 2],
136 expected_text="-4 pizzas please!",
137 timeout=15,
138 )
139 print("Deployments are reachable over HTTP.")
140
141 deployments = [
142 DeploymentID(name="Router"),
143 DeploymentID(name="Multiplier"),
144 DeploymentID(name="Adder"),
145 ]
146 assert_deployments_live(deployments)
147 print("All deployments are live.\n")
148
149 print("Deploying arithmetic config.")
150 deploy_response = subprocess.check_output(
151 ["serve", "deploy", arithmetic_file_name, "-a", "http://localhost:8265/"]
152 )
153 assert success_message_fragment in deploy_response
154 print("Deploy request sent successfully.")
155
156 wait_for_condition(
157 check_http_response,
158 json=["ADD", 0],
159 expected_text="1",
160 timeout=15,
161 )
162 wait_for_condition(

Callers

nothing calls this directly

Calls 7

wait_for_conditionFunction · 0.90
DeploymentIDClass · 0.90
printFunction · 0.85
assert_deployments_liveFunction · 0.85
check_outputMethod · 0.80
rangeFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…