Skip to content

Commit

Permalink
suite: remove "dry_run" query param
Browse files Browse the repository at this point in the history
Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
  • Loading branch information
VallariAg committed Feb 13, 2024
1 parent 03f304f commit 1b81850
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ Returns `{"root": "success", "session": { <authentication details> }}`.

POST `/suite/`: schedules a run.

Two query parameters:
- `dry_run` (boolean) - Do a dry run; do not schedule anything.
Query parameters:
- `logs` (boolean) - Send scheduling logs in response.

Example

curl --location --request POST 'http://localhost:8082/suite?dry_run=false&logs=true' \
curl --location --request POST 'http://localhost:8082/suite&logs=true' \
--header 'Content-Type: application/json' \
--data-raw '{
"--ceph": "main",
Expand All @@ -101,10 +100,10 @@ Example
"--suite": "teuthology:no-ceph",
"--suite-branch": "main",
"--suite-repo": "https://github.com/ceph/ceph-ci.git",
"--teuthology-branch": "main",
"--teuthology-branch": "", // necessary for docker setup
"--verbose": "1",
"<config_yaml>": ["/teuthology/containerized_node.yaml"]
"--owner": "example",
"<config_yaml>": ["/teuthology/containerized_node.yaml"],
"--owner": "example"
}'

Note: "--owner" in data body should be same as your github username (case sensitive). Otherwise, you wouldn't have permission to kill jobs/run.
Expand Down
3 changes: 1 addition & 2 deletions src/teuthology_api/routes/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def create_run(
request: Request,
args: SuiteArgs,
access_token: str = Depends(get_token),
dry_run: bool = False,
logs: bool = False,
):
args = args.model_dump(by_alias=True)
args["--user"] = get_username(request)
return run(args, dry_run, logs, access_token)
return run(args, logs, access_token)
16 changes: 5 additions & 11 deletions src/teuthology_api/services/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
log = logging.getLogger(__name__)


def run(args, dry_run: bool, send_logs: bool, access_token: str):
def run(args, send_logs: bool, access_token: str):
"""
Schedule a suite.
:returns: Run details (dict) and logs (list).
Expand All @@ -22,16 +22,8 @@ def run(args, dry_run: bool, send_logs: bool, access_token: str):
)
try:
args["--timestamp"] = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
if dry_run:
args["--dry-run"] = True
logs = logs_run(teuthology.suite.main, args)
return {"run": {}, "logs": logs}

logs = []
if send_logs:
logs = logs_run(teuthology.suite.main, args)
else:
teuthology.suite.main(args)
logs = logs_run(teuthology.suite.main, args)

# get run details from paddles
run_name = make_run_name(
Expand All @@ -46,7 +38,9 @@ def run(args, dry_run: bool, send_logs: bool, access_token: str):
}
)
run_details = get_run_details(run_name)
return {"run": run_details, "logs": logs}
if send_logs or args["--dry-run"]:
return {"run": run_details, "logs": logs}
return {"run": run_details}
except Exception as exc:
log.error("teuthology.suite.main failed with the error: %s", repr(exc))
raise HTTPException(status_code=500, detail=repr(exc)) from exc
Expand Down
6 changes: 3 additions & 3 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ async def override_get_token():
}

# suite
@patch("teuthology_api.services.suite.teuthology.suite.main")
@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_success(m_get_run_details, m_get_username, m_teuth_suite_main):
def test_suite_run_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", data=json.dumps(mock_suite_args))
assert response.status_code == 200
assert response.json() == {"run": {"id": "7451978", "user": "user1"}, "logs": []}
assert response.json() == {"run": {"id": "7451978", "user": "user1"}}


# make_run_name
Expand Down

0 comments on commit 1b81850

Please sign in to comment.