diff --git a/python/ray/serve/tests/test_api.py b/python/ray/serve/tests/test_api.py index ffb599d60..5b57c91fc 100644 --- a/python/ray/serve/tests/test_api.py +++ b/python/ray/serve/tests/test_api.py @@ -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")