Skip to content

Commit

Permalink
test(scorecard): adjust scorecard report generation expectation (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Dec 17, 2024
1 parent 75b7a81 commit a543918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions internal/test/scorecard/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,14 @@ func (client *RecordingClient) Delete(ctx context.Context, target *Target, recor
return nil
}

func (client *RecordingClient) GenerateReport(ctx context.Context, target *Target, recording *Recording) (map[string]interface{}, error) {
func (client *RecordingClient) RequestReportGeneration(ctx context.Context, target *Target, recording *Recording) (*string, error) {
if len(recording.ReportURL) < 1 {
return nil, fmt.Errorf("report URL is not available")
}

reportURL := client.Base.JoinPath(recording.ReportURL)

header := make(http.Header)
header.Add("Accept", "application/json")

resp, err := SendRequest(ctx, client.Client, http.MethodGet, reportURL.String(), nil, header)
if err != nil {
Expand All @@ -442,13 +441,12 @@ func (client *RecordingClient) GenerateReport(ctx context.Context, target *Targe
return nil, fmt.Errorf("API request failed with status code: %d, response body: %s, and headers:\n%s", resp.StatusCode, ReadError(resp), ReadHeader(resp))
}

report := make(map[string]interface{}, 0)
err = ReadJSON(resp, &report)
report, err := ReadString(resp)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %s", err.Error())
}

return report, nil
return &report, nil
}

func (client *RecordingClient) ListArchives(ctx context.Context, target *Target) ([]Archive, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/test/scorecard/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ func CryostatRecordingTest(bundle *apimanifests.Bundle, namespace string, openSh
}
r.Log += fmt.Sprintf("current list of archives: %+v\n", archives)

report, err := apiClient.Recordings().GenerateReport(context.Background(), target, rec)
reportJobId, err := apiClient.Recordings().RequestReportGeneration(context.Background(), target, rec)
if err != nil {
return r.fail(fmt.Sprintf("failed to generate report for the recording: %s", err.Error()))
}
r.Log += fmt.Sprintf("generated report for the recording %s: %+v\n", rec.Name, report)
r.Log += fmt.Sprintf("report generation job ID for the recording %s: %+v\n", rec.Name, *reportJobId)

// Stop the recording
err = apiClient.Recordings().Stop(context.Background(), target, rec.Id)
Expand Down

0 comments on commit a543918

Please sign in to comment.