mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 02:01:24 +08:00
[serve] Add basic test for specifying the method in a serve call (#8172)
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user