diff --git a/internal/cloudapi/v2/v2_koji_test.go b/internal/cloudapi/v2/v2_koji_test.go index faa08d375..f74c0ec51 100644 --- a/internal/cloudapi/v2/v2_koji_test.go +++ b/internal/cloudapi/v2/v2_koji_test.go @@ -329,6 +329,67 @@ func TestKojiCompose(t *testing.T) { "status": "failure" }`, }, + { + initResult: worker.KojiInitJobResult{ + BuildID: 42, + Token: `"foobar"`, + }, + buildResult: worker.OSBuildKojiJobResult{ + Arch: test_distro.TestArchName, + HostOS: test_distro.TestDistroName, + ImageHash: "browns", + ImageSize: 42, + OSBuildOutput: &osbuild.Result{ + Success: true, + }, + JobResult: worker.JobResult{ + JobError: clienterrors.WorkerClientError( + clienterrors.ErrorManifestDependency, + "Manifest dependency failed", + clienterrors.WorkerClientError( + clienterrors.ErrorDNFOtherError, + "DNF Error", + ), + ), + }, + }, + composeReplyCode: http.StatusCreated, + composeReply: `"href":"/api/image-builder-composer/v2/compose", "kind":"ComposeId"`, + composeStatus: `{ + "kind": "ComposeStatus", + "image_status": { + "error": { + "details": { + "id": 22, + "reason": "DNF Error" + }, + "id": 9, + "reason": "Manifest dependency failed" + }, + "status": "failure", + }, + "image_statuses": [ + { + "error": { + "details": { + "id": 22, + "reason": "Error in depsolve job" + }, + "id": 9, + "reason": "Manifest dependency failed" + }, + "status": "failure" + }, + { + "status": "success" + } + ], + "koji_status": { + "build_id": 42 + }, + "status": "failure" + }`, + }, } for _, c := range cases[2:3] { test.TestRoute(t, handler, false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index f9d90c567..81a748b1a 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -796,6 +796,73 @@ func TestComposeJobError(t *testing.T) { }`, jobId, jobId)) } +func TestComposeDependencyError(t *testing.T) { + srv, wrksrv, _, cancel := newV2Server(t, t.TempDir(), []string{""}, false) + defer cancel() + + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(` + { + "distribution": "%s", + "image_request":{ + "architecture": "%s", + "image_type": "aws", + "repositories": [{ + "baseurl": "somerepo.org", + "rhsm": false + }], + "upload_options": { + "region": "eu-central-1" + } + } + }`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, ` + { + "href": "/api/image-builder-composer/v2/compose", + "kind": "ComposeId" + }`, "id") + + jobId, token, jobType, _, _, err := wrksrv.RequestJob(context.Background(), test_distro.TestArch3Name, []string{"osbuild"}, []string{""}) + require.NoError(t, err) + require.Equal(t, "osbuild", jobType) + + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v", jobId), ``, http.StatusOK, fmt.Sprintf(` + { + "href": "/api/image-builder-composer/v2/composes/%v", + "kind": "ComposeStatus", + "id": "%v", + "image_status": {"status": "building"}, + "status": "pending" + }`, jobId, jobId)) + + jobErr := worker.JobResult{ + JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed"), + } + jobErr.JobError.Details = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error") + jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr}) + require.NoError(t, err) + + err = wrksrv.FinishJob(token, jobResult) + require.NoError(t, err) + test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v", jobId), ``, http.StatusOK, fmt.Sprintf(` + { + "href": "/api/image-builder-composer/v2/composes/%v", + "kind": "ComposeStatus", + "id": "%v", + "image_status": { + "error": { + "details": { + "details": null, + "id": 22, + "reason": "DNF Error" + }, + "id": 9, + "reason": "Manifest dependency failed" + }, + "status": "failure" + }, + "status": "failure" + }`, jobId, jobId)) +} + func TestComposeCustomizations(t *testing.T) { srv, _, _, cancel := newV2Server(t, t.TempDir(), []string{""}, false) defer cancel()