[serve] Add basic test for specifying the method in a serve call (#8172)

This commit is contained in:
Edward Oakes
2020-04-24 20:15:27 -05:00
committed by GitHub
parent 0dc01d8c1e
commit 9dc625318f
+22
View File
@@ -40,6 +40,28 @@ def test_e2e(serve_instance):
assert resp == "POST"
def test_call_method(serve_instance):
serve.create_endpoint("call-method", "/call-method")
class CallMethod:
def method(self, request):
return "hello"
serve.create_backend(CallMethod, "call-method")
serve.set_traffic("call-method", {"call-method": 1.0})
# Test HTTP path.
resp = requests.get(
"http://127.0.0.1:8000/call-method",
timeout=1,
headers={"X-SERVE-CALL-METHOD": "method"})
assert resp.text == "hello"
# Test serve handle path.
handle = serve.get_handle("call-method")
assert ray.get(handle.options("method").remote()) == "hello"
def test_no_route(serve_instance):
serve.create_endpoint("noroute-endpoint")