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

routes: new /suite/default endpoint #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/teuthology_api/routes/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ def create_run(
args = args.model_dump(by_alias=True)
args["--user"] = get_username(request)
return run(args, logs, access_token)


@router.post("/default", status_code=200)
def create_run_default(
request: Request,
access_token: str = Depends(get_token),
logs: bool = False,
):
args = {
"--ceph": "wip-leonidc-20240331-00", # 'main' build not found on shaman
"--ceph-repo": "https://github.com/ceph/ceph-ci.git",
"--suite_repo": "https://github.com/ceph/ceph-ci.git",
"--suite": "teuthology:no-ceph",
"--machine-type": "testnode",
"--distro": "ubuntu",
"--distro-version": "20.04",
"<config_yaml>": ["/teuthology/containerized_node.yaml"]
}
default_args = SuiteArgs(**args).model_dump(by_alias=True)
default_args["--user"] = get_username(request)
return run(default_args, logs, access_token)
13 changes: 11 additions & 2 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ def test_suite_run_success(m_get_run_details, m_get_username, m_logs_run):
assert response.json() == {"run": {"id": "7451978", "user": "user1"}}


# make_run_name

# test suite with default args
@patch("teuthology_api.services.suite.logs_run")
@patch("teuthology_api.routes.suite.get_username")
@patch("teuthology_api.services.suite.get_run_details")
def test_suite_run_default_success(m_get_run_details, m_get_username, m_logs_run):
m_get_username.return_value = "user1"
m_get_run_details.return_value = {"id": "7451978", "user": "user1"}
response = client.post("/suite/default", data=json.dumps(mock_suite_args))
assert response.status_code == 200
assert response.json() == {"run": {"id": "7451978", "user": "user1"}}

# make_run_name
def test_make_run_name():
m_run_dic = {
"user": "testuser",
Expand Down