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

suite: remove "dry_run" query param #48

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading