2020-08-25 04:24:23 +08:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import aiohttp.web
|
|
|
|
|
2021-09-15 11:17:15 -05:00
|
|
|
import ray.dashboard.utils as dashboard_utils
|
2022-01-24 14:11:32 +09:00
|
|
|
import ray.dashboard.optional_utils as dashboard_optional_utils
|
2021-09-15 11:17:15 -05:00
|
|
|
import ray.dashboard.modules.test.test_utils as test_utils
|
|
|
|
import ray.dashboard.modules.test.test_consts as test_consts
|
2020-08-30 14:09:34 +08:00
|
|
|
from ray.ray_constants import env_bool
|
2020-08-25 04:24:23 +08:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2022-01-24 14:11:32 +09:00
|
|
|
routes = dashboard_optional_utils.ClassMethodRouteTable
|
2020-08-25 04:24:23 +08:00
|
|
|
|
|
|
|
|
2020-08-30 14:09:34 +08:00
|
|
|
@dashboard_utils.dashboard_module(
|
2022-01-29 18:41:57 -08:00
|
|
|
enable=env_bool(test_consts.TEST_MODULE_ENVIRONMENT_KEY, False)
|
|
|
|
)
|
2020-08-30 14:09:34 +08:00
|
|
|
class TestAgent(dashboard_utils.DashboardAgentModule):
|
2020-08-25 04:24:23 +08:00
|
|
|
def __init__(self, dashboard_agent):
|
|
|
|
super().__init__(dashboard_agent)
|
|
|
|
|
2022-01-26 21:03:54 +09:00
|
|
|
@staticmethod
|
|
|
|
def is_minimal_module():
|
|
|
|
return False
|
|
|
|
|
2020-08-25 04:24:23 +08:00
|
|
|
@routes.get("/test/http_get_from_agent")
|
|
|
|
async def get_url(self, req) -> aiohttp.web.Response:
|
|
|
|
url = req.query.get("url")
|
2022-01-29 18:41:57 -08:00
|
|
|
result = await test_utils.http_get(self._dashboard_agent.http_session, url)
|
2020-08-25 04:24:23 +08:00
|
|
|
return aiohttp.web.json_response(result)
|
|
|
|
|
2020-08-30 14:09:34 +08:00
|
|
|
@routes.head("/test/route_head")
|
|
|
|
async def route_head(self, req) -> aiohttp.web.Response:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@routes.post("/test/route_post")
|
|
|
|
async def route_post(self, req) -> aiohttp.web.Response:
|
|
|
|
pass
|
|
|
|
|
|
|
|
@routes.patch("/test/route_patch")
|
|
|
|
async def route_patch(self, req) -> aiohttp.web.Response:
|
|
|
|
pass
|
|
|
|
|
2020-08-25 04:24:23 +08:00
|
|
|
async def run(self, server):
|
|
|
|
pass
|