diff --git a/README.md b/README.md index 234b2e1..d77ad5d 100644 --- a/README.md +++ b/README.md @@ -84,13 +84,12 @@ Returns `{"root": "success", "session": { }}`. 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", @@ -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", - "": ["/teuthology/containerized_node.yaml"] - "--owner": "example", + "": ["/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. diff --git a/src/teuthology_api/routes/suite.py b/src/teuthology_api/routes/suite.py index ab97e9a..13f1905 100644 --- a/src/teuthology_api/routes/suite.py +++ b/src/teuthology_api/routes/suite.py @@ -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) diff --git a/src/teuthology_api/services/suite.py b/src/teuthology_api/services/suite.py index 8f1d0f7..99d2d6d 100644 --- a/src/teuthology_api/services/suite.py +++ b/src/teuthology_api/services/suite.py @@ -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). @@ -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( @@ -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 diff --git a/tests/test_suite.py b/tests/test_suite.py index ac912df..ab2f6f7 100644 --- a/tests/test_suite.py +++ b/tests/test_suite.py @@ -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