cloudapi/test: add compose dependency error tests
Add depsolve job error dependency test cases for regular composes and koji composes. The error furthest up the chain should be returned in the details field of the job error.
This commit is contained in:
parent
e31fb36d65
commit
2ad11acc2a
2 changed files with 128 additions and 0 deletions
|
|
@ -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(`
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue