Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CurlServiceRule with golang for RayService #2455

Open
Tracked by #2310
MortalHappiness opened this issue Oct 18, 2024 · 0 comments
Open
Tracked by #2310

Implement CurlServiceRule with golang for RayService #2455

MortalHappiness opened this issue Oct 18, 2024 · 0 comments
Assignees
Labels
ci good first issue Good for newcomers

Comments

@MortalHappiness
Copy link
Member

MortalHappiness commented Oct 18, 2024

This is a subtask of #2310. See the parent issue for more information.

Implementation Details

  • Implement the CurlServiceRule here with Golang.
    class CurlServiceRule(Rule):
    """Using curl to access the deployed application(s) on RayService"""
    CURL_CMD_FMT = (
    "kubectl exec curl -n {namespace} -- "
    "curl -X POST -H 'Content-Type: application/json' "
    "{name}-serve-svc.{namespace}.svc.cluster.local:8000{path}/ -d '{json}'"
    )
    def __init__(self, queries: List[Dict[str, str]], start_in_background: bool = False):
    self.queries = queries
    self.start_in_background = start_in_background
    def assert_rule(self, custom_resource, cr_namespace):
    # If curl pod doesn't exist, create one
    if get_pod("default", "run=curl") is None:
    start_curl_pod("curl", cr_namespace, timeout_s=30)
    for query in self.queries:
    cmd = self.CURL_CMD_FMT.format(
    name=custom_resource["metadata"]["name"],
    namespace=cr_namespace,
    path=query.get("path").rstrip("/"),
    json=json.dumps(query["json_args"])
    )
    if self.start_in_background:
    shell_subprocess_run(f"{cmd} &", hide_output=False)
    else:
    output = shell_subprocess_check_output(cmd)
    logger.info("curl output: %s", output.decode('utf-8'))
    if hasattr(query.get("expected_output"), "__iter__"):
    assert output.decode('utf-8') in query["expected_output"]
    else:
    assert output.decode('utf-8') == query["expected_output"]
    time.sleep(1)
  • Needs to wait for Check RayService ray job submit can successfully create a job by running it in the head Pod in the corresponding RayCluster #2453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant