diff --git a/pkg/coordinator/web/api/docs/docs.go b/pkg/coordinator/web/api/docs/docs.go index 164f8e8..94c340d 100644 --- a/pkg/coordinator/web/api/docs/docs.go +++ b/pkg/coordinator/web/api/docs/docs.go @@ -361,6 +361,14 @@ const docTemplate = `{ ], "summary": "Get list of test runs", "operationId": "getTestRuns", + "parameters": [ + { + "type": "string", + "description": "Return test runs for this test ID only", + "name": "test_id", + "in": "query" + } + ], "responses": { "200": { "description": "Success", diff --git a/pkg/coordinator/web/api/docs/swagger.json b/pkg/coordinator/web/api/docs/swagger.json index ba346bf..2748757 100644 --- a/pkg/coordinator/web/api/docs/swagger.json +++ b/pkg/coordinator/web/api/docs/swagger.json @@ -353,6 +353,14 @@ ], "summary": "Get list of test runs", "operationId": "getTestRuns", + "parameters": [ + { + "type": "string", + "description": "Return test runs for this test ID only", + "name": "test_id", + "in": "query" + } + ], "responses": { "200": { "description": "Success", diff --git a/pkg/coordinator/web/api/docs/swagger.yaml b/pkg/coordinator/web/api/docs/swagger.yaml index 0c6d554..aac5201 100644 --- a/pkg/coordinator/web/api/docs/swagger.yaml +++ b/pkg/coordinator/web/api/docs/swagger.yaml @@ -448,6 +448,11 @@ paths: get: description: Returns a list of all test runs. operationId: getTestRuns + parameters: + - description: Return test runs for this test ID only + in: query + name: test_id + type: string produces: - application/json responses: diff --git a/pkg/coordinator/web/api/get_test_api.go b/pkg/coordinator/web/api/get_test_api.go index 9d0d38c..aa16a6c 100644 --- a/pkg/coordinator/web/api/get_test_api.go +++ b/pkg/coordinator/web/api/get_test_api.go @@ -8,13 +8,13 @@ import ( ) type GetTestResponse struct { - ID string `json:"id"` - Source string `json:"source"` - Name string `json:"name"` - Timeout uint64 `json:"timeout"` - Config map[string]any `json:"config"` - ConfigVars map[string]string `json:"configVars"` - Schedule types.TestSchedule `json:"schedule"` + ID string `json:"id"` + Source string `json:"source"` + Name string `json:"name"` + Timeout uint64 `json:"timeout"` + Config map[string]any `json:"config"` + ConfigVars map[string]string `json:"configVars"` + Schedule *types.TestSchedule `json:"schedule"` } // GetTest godoc @@ -64,6 +64,6 @@ func (ah *APIHandler) GetTest(w http.ResponseWriter, r *http.Request) { Timeout: uint64(testConfig.Timeout.Duration.Seconds()), Config: testConfig.Config, ConfigVars: testConfig.ConfigVars, - Schedule: *testConfig.Schedule, + Schedule: testConfig.Schedule, }) } diff --git a/pkg/coordinator/web/api/get_test_runs_api.go b/pkg/coordinator/web/api/get_test_runs_api.go index bcb6651..82f7a35 100644 --- a/pkg/coordinator/web/api/get_test_runs_api.go +++ b/pkg/coordinator/web/api/get_test_runs_api.go @@ -21,6 +21,7 @@ type GetTestRunsResponse struct { // @Tags TestRun // @Description Returns a list of all test runs. // @Produce json +// @Param test_id query string false "Return test runs for this test ID only" // @Success 200 {object} Response{data=[]GetTestRunsResponse} "Success" // @Failure 400 {object} Response "Failure" // @Failure 500 {object} Response "Server Error" @@ -28,10 +29,16 @@ type GetTestRunsResponse struct { func (ah *APIHandler) GetTestRuns(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") + q := r.URL.Query() + filterTestID := q.Get("test_id") testRuns := []*GetTestRunsResponse{} testInstances := append(ah.coordinator.GetTestHistory(), ah.coordinator.GetTestQueue()...) for _, testInstance := range testInstances { + if filterTestID != "" && filterTestID != testInstance.TestID() { + continue + } + testRun := &GetTestRunsResponse{ RunID: testInstance.RunID(), TestID: testInstance.TestID(),