Presets allow users to save teuthology-suite command config with a custom name that can be used again.
This PR includes:
Create presets table using SQLModel and setup database migrations using alembic
Add presets service for ORM queries
Add endpoints for /presets route
Add fixtures to conftest.py
Add tests for /preset endpoints
Add limit for creating presets
Create a request body schema for PresetArgs
For testing this PR,
TEUTHOLOGY_API_SQLITE_URI should be added to the .env file using the format sqlite:////<path>
Containerized Setup: Run the start.sh script in teuthology/docs/docker-compose
Non-containerized Setup:
Create a virtual environment and install the dependencies
Run alembic upgrade head command to migrate the database
Workflow
The create, update and delete endpoints required a user to be logged in. Users can read any stored preset, but cannot modify or delete them.
Creating a Preset
A POST request to the endpoint /presets/add with the following request body:
{
"username": "example",
"name": "test",
"suite": "teuthology:no-ceph",
"cmd": "<SuiteArgs format for /suite endpoint>"
}
Returns the created preset data, along with a preset ID which can be used to modify the preset
A user can only store 10 presets at a time. If they want to delete their oldest preset and store the new one, append ?replace=true to the endpoint
Get a Preset
A GET request to the endpoint /presets?username=<github_username>&name=<preset_name>
Returns the preset in the following format if it exists:
{
"id": 1,
"username": "example",
"name": "test",
"suite": "teuthology:no-ceph",
"cmd": "<SuiteArgs format for /suite endpoint>"
}
Get All Presets of a User
A GET request to the endpoint /presets/list?username=<github_username>
Returns a list of user's presets
Update a Preset
A PUTrequest to the endpoint /presets/edit/<preset_id> with the parameters that need to updated in the preset in the request body
Returns the updated preset contents
Delete a Preset
A DELETE request to the endpoint /presets/delete/<preset_id>
Pulpito-ng Integration
Most of the teuthology commands have default parameters, only some such as suite and branch need to be changed according to the user's need. On the frontend, we can present default values for the command parameters and users can change them accordingly. Once the parameter values are confirmed, they can be sent as a JSON request body to the presets/add endpoint.
A form can be used for taking the input values, along with a checkbox to set the replace query parameter to true, which will delete the user's oldest preset if their count of stored presets is 10.
Description
Presets allow users to save teuthology-suite command config with a custom name that can be used again.
This PR includes:
presets
table using SQLModel and setup database migrations using alembic/presets
routeconftest.py
/preset
endpointsFor testing this PR,
TEUTHOLOGY_API_SQLITE_URI
should be added to the.env
file using the formatsqlite:////<path>
start.sh
script inteuthology/docs/docker-compose
alembic upgrade head
command to migrate the databaseWorkflow
The create, update and delete endpoints required a user to be logged in. Users can read any stored preset, but cannot modify or delete them.
Creating a Preset
POST
request to the endpoint/presets/add
with the following request body:?replace=true
to the endpointGet a Preset
GET
request to the endpoint/presets?username=<github_username>&name=<preset_name>
Get All Presets of a User
GET
request to the endpoint/presets/list?username=<github_username>
Update a Preset
PUT
request to the endpoint/presets/edit/<preset_id>
with the parameters that need to updated in the preset in the request bodyDelete a Preset
A
DELETE
request to the endpoint/presets/delete/<preset_id>
Pulpito-ng Integration
Most of the teuthology commands have default parameters, only some such as
suite
andbranch
need to be changed according to the user's need. On the frontend, we can present default values for the command parameters and users can change them accordingly. Once the parameter values are confirmed, they can be sent as a JSON request body to thepresets/add
endpoint.A form can be used for taking the input values, along with a checkbox to set the
replace
query parameter to true, which will delete the user's oldest preset if their count of stored presets is 10.Checklist