worker: define job types as constants
Define supported job type names as constants and use them in all places, instead of string literals. There are multiple benefits of this approach. Using constants removed the room for typos in the string literals. One can use autocompletion in IDE for job types. Using constant makes it easier to find all references where it is used and thus all places that are handling a specific job type.
This commit is contained in:
parent
69b9f115c9
commit
a4e6531565
11 changed files with 119 additions and 102 deletions
|
|
@ -92,7 +92,7 @@ func TestOAuth(t *testing.T) {
|
|||
BasePath: "/api/image-builder-worker/v1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
job, err := client.RequestJob([]string{"osbuild"}, "arch")
|
||||
job, err := client.RequestJob([]string{worker.JobTypeOSBuild}, "arch")
|
||||
require.NoError(t, err)
|
||||
r := strings.NewReader("artifact contents")
|
||||
require.NoError(t, job.UploadArtifact("some-artifact", r))
|
||||
|
|
@ -120,7 +120,7 @@ func TestProxy(t *testing.T) {
|
|||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
job, err := client.RequestJob([]string{"osbuild"}, "arch")
|
||||
job, err := client.RequestJob([]string{worker.JobTypeOSBuild}, "arch")
|
||||
require.NoError(t, err)
|
||||
r := strings.NewReader("artifact contents")
|
||||
require.NoError(t, job.UploadArtifact("some-artifact", r))
|
||||
|
|
|
|||
|
|
@ -28,6 +28,15 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/worker/clienterrors"
|
||||
)
|
||||
|
||||
const (
|
||||
JobTypeOSBuild string = "osbuild"
|
||||
JobTypeOSBuildKoji string = "osbuild-koji"
|
||||
JobTypeKojiInit string = "koji-init"
|
||||
JobTypeKojiFinalize string = "koji-finalize"
|
||||
JobTypeDepsolve string = "depsolve"
|
||||
JobTypeManifestIDOnly string = "manifest-id-only"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
jobs jobqueue.JobQueue
|
||||
logger *log.Logger
|
||||
|
|
@ -101,35 +110,35 @@ func (s *Server) WatchHeartbeats() {
|
|||
}
|
||||
|
||||
func (s *Server) EnqueueOSBuild(arch string, job *OSBuildJob, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("osbuild:"+arch, job, nil, channel)
|
||||
return s.enqueue(JobTypeOSBuild+":"+arch, job, nil, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueOSBuildAsDependency(arch string, job *OSBuildJob, dependencies []uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("osbuild:"+arch, job, dependencies, channel)
|
||||
return s.enqueue(JobTypeOSBuild+":"+arch, job, dependencies, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueOSBuildKoji(arch string, job *OSBuildKojiJob, initID uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("osbuild-koji:"+arch, job, []uuid.UUID{initID}, channel)
|
||||
return s.enqueue(JobTypeOSBuildKoji+":"+arch, job, []uuid.UUID{initID}, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueOSBuildKojiAsDependency(arch string, job *OSBuildKojiJob, manifestID, initID uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("osbuild-koji:"+arch, job, []uuid.UUID{initID, manifestID}, channel)
|
||||
return s.enqueue(JobTypeOSBuildKoji+":"+arch, job, []uuid.UUID{initID, manifestID}, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueKojiInit(job *KojiInitJob, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("koji-init", job, nil, channel)
|
||||
return s.enqueue(JobTypeKojiInit, job, nil, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueKojiFinalize(job *KojiFinalizeJob, initID uuid.UUID, buildIDs []uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("koji-finalize", job, append([]uuid.UUID{initID}, buildIDs...), channel)
|
||||
return s.enqueue(JobTypeKojiFinalize, job, append([]uuid.UUID{initID}, buildIDs...), channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueDepsolve(job *DepsolveJob, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("depsolve", job, nil, channel)
|
||||
return s.enqueue(JobTypeDepsolve, job, nil, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueManifestJobByID(job *ManifestJobByID, parent uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue("manifest-id-only", job, []uuid.UUID{parent}, channel)
|
||||
return s.enqueue(JobTypeManifestIDOnly, job, []uuid.UUID{parent}, channel)
|
||||
}
|
||||
|
||||
func (s *Server) enqueue(jobType string, job interface{}, dependencies []uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
|
|
@ -171,8 +180,8 @@ func (s *Server) OSBuildJobStatus(id uuid.UUID, result *OSBuildJobResult) (*JobS
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(jobType, "osbuild:") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return nil, nil, fmt.Errorf("expected osbuild:*, found %q job instead", jobType)
|
||||
if !strings.HasPrefix(jobType, JobTypeOSBuild+":") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return nil, nil, fmt.Errorf("expected \"%s:*\", found %q job instead", JobTypeOSBuild, jobType)
|
||||
}
|
||||
|
||||
if result.JobError == nil && !status.Finished.IsZero() {
|
||||
|
|
@ -199,8 +208,8 @@ func (s *Server) OSBuildKojiJobStatus(id uuid.UUID, result *OSBuildKojiJobResult
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(jobType, "osbuild-koji:") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return nil, nil, fmt.Errorf("expected \"osbuild-koji:*\", found %q job instead", jobType)
|
||||
if !strings.HasPrefix(jobType, JobTypeOSBuildKoji+":") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return nil, nil, fmt.Errorf("expected \"%s:*\", found %q job instead", JobTypeOSBuildKoji, jobType)
|
||||
}
|
||||
|
||||
if result.JobError == nil && !status.Finished.IsZero() {
|
||||
|
|
@ -222,8 +231,8 @@ func (s *Server) KojiInitJobStatus(id uuid.UUID, result *KojiInitJobResult) (*Jo
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if jobType != "koji-init" {
|
||||
return nil, nil, fmt.Errorf("expected \"koji-init\", found %q job instead", jobType)
|
||||
if jobType != JobTypeKojiInit {
|
||||
return nil, nil, fmt.Errorf("expected %q, found %q job instead", JobTypeKojiInit, jobType)
|
||||
}
|
||||
|
||||
if result.JobError == nil && result.KojiError != "" {
|
||||
|
|
@ -239,8 +248,8 @@ func (s *Server) KojiFinalizeJobStatus(id uuid.UUID, result *KojiFinalizeJobResu
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if jobType != "koji-finalize" {
|
||||
return nil, nil, fmt.Errorf("expected \"koji-finalize\", found %q job instead", jobType)
|
||||
if jobType != JobTypeKojiFinalize {
|
||||
return nil, nil, fmt.Errorf("expected %q, found %q job instead", JobTypeKojiFinalize, jobType)
|
||||
}
|
||||
|
||||
if result.JobError == nil && result.KojiError != "" {
|
||||
|
|
@ -256,8 +265,8 @@ func (s *Server) DepsolveJobStatus(id uuid.UUID, result *DepsolveJobResult) (*Jo
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if jobType != "depsolve" {
|
||||
return nil, nil, fmt.Errorf("expected \"depsolve\", found %q job instead", jobType)
|
||||
if jobType != JobTypeDepsolve {
|
||||
return nil, nil, fmt.Errorf("expected %q, found %q job instead", JobTypeDepsolve, jobType)
|
||||
}
|
||||
|
||||
if result.JobError == nil && result.Error != "" {
|
||||
|
|
@ -277,8 +286,8 @@ func (s *Server) ManifestJobStatus(id uuid.UUID, result *ManifestJobByIDResult)
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
if jobType != "manifest-id-only" {
|
||||
return nil, nil, fmt.Errorf("expected \"manifest-id-only\", found %q job instead", jobType)
|
||||
if jobType != JobTypeManifestIDOnly {
|
||||
return nil, nil, fmt.Errorf("expected %q, found %q job instead", JobTypeManifestIDOnly, jobType)
|
||||
}
|
||||
|
||||
return status, deps, nil
|
||||
|
|
@ -312,8 +321,8 @@ func (s *Server) OSBuildJob(id uuid.UUID, job *OSBuildJob) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(jobType, "osbuild:") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return fmt.Errorf("expected osbuild:*, found %q job instead for job '%s'", jobType, id)
|
||||
if !strings.HasPrefix(jobType, JobTypeOSBuild+":") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return fmt.Errorf("expected %s:*, found %q job instead for job '%s'", JobTypeOSBuild, jobType, id)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(rawArgs, job); err != nil {
|
||||
|
|
@ -330,8 +339,8 @@ func (s *Server) OSBuildKojiJob(id uuid.UUID, job *OSBuildKojiJob) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(jobType, "osbuild-koji:") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return fmt.Errorf("expected osbuild-koji:*, found %q job instead for job '%s'", jobType, id)
|
||||
if !strings.HasPrefix(jobType, JobTypeOSBuildKoji+":") { // Build jobs get automatic arch suffix: Check prefix
|
||||
return fmt.Errorf("expected %s:*, found %q job instead for job '%s'", JobTypeOSBuildKoji, jobType, id)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(rawArgs, job); err != nil {
|
||||
|
|
@ -422,10 +431,10 @@ func (s *Server) requestJob(ctx context.Context, arch string, jobTypes []string,
|
|||
// restriction: arch for osbuild jobs.
|
||||
jts := []string{}
|
||||
for _, t := range jobTypes {
|
||||
if t == "osbuild" || t == "osbuild-koji" {
|
||||
if t == JobTypeOSBuild || t == JobTypeOSBuildKoji {
|
||||
t = t + ":" + arch
|
||||
}
|
||||
if t == "manifest-id-only" {
|
||||
if t == JobTypeManifestIDOnly {
|
||||
return uuid.Nil, uuid.Nil, "", nil, nil, ErrInvalidJobType
|
||||
}
|
||||
jts = append(jts, t)
|
||||
|
|
@ -486,10 +495,10 @@ func (s *Server) requestJob(ctx context.Context, arch string, jobTypes []string,
|
|||
// TODO: Drop the ':$architecture' for metrics too, first prometheus queries for alerts and
|
||||
// dashboards need to be adjusted.
|
||||
prometheus.DequeueJobMetrics(pending, status.Started, jobType, channel)
|
||||
if jobType == "osbuild:"+arch {
|
||||
jobType = "osbuild"
|
||||
} else if jobType == "osbuild-koji:"+arch {
|
||||
jobType = "osbuild-koji"
|
||||
if jobType == JobTypeOSBuild+":"+arch {
|
||||
jobType = JobTypeOSBuild
|
||||
} else if jobType == JobTypeOSBuildKoji+":"+arch {
|
||||
jobType = JobTypeOSBuildKoji
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ func TestCreate(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
test.TestRoute(t, handler, false, "POST", "/api/worker/v1/jobs",
|
||||
fmt.Sprintf(`{"types":["osbuild"],"arch":"%s"}`, test_distro.TestArchName), http.StatusCreated,
|
||||
`{"kind":"RequestJob","href":"/api/worker/v1/jobs","type":"osbuild","args":{"manifest":{"pipeline":{},"sources":{}}}}`, "id", "location", "artifact_location")
|
||||
fmt.Sprintf(`{"types":["%s"],"arch":"%s"}`, worker.JobTypeOSBuild, test_distro.TestArchName), http.StatusCreated,
|
||||
fmt.Sprintf(`{"kind":"RequestJob","href":"/api/worker/v1/jobs","type":"%s","args":{"manifest":{"pipeline":{},"sources":{}}}}`, worker.JobTypeOSBuild), "id", "location", "artifact_location")
|
||||
}
|
||||
|
||||
func TestCancel(t *testing.T) {
|
||||
|
|
@ -148,10 +148,10 @@ func TestCancel(t *testing.T) {
|
|||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, jobId, j)
|
||||
require.Equal(t, "osbuild", typ)
|
||||
require.Equal(t, worker.JobTypeOSBuild, typ)
|
||||
require.NotNil(t, args)
|
||||
require.Nil(t, dynamicArgs)
|
||||
|
||||
|
|
@ -185,10 +185,10 @@ func TestUpdate(t *testing.T) {
|
|||
jobId, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, jobId, j)
|
||||
require.Equal(t, "osbuild", typ)
|
||||
require.Equal(t, worker.JobTypeOSBuild, typ)
|
||||
require.NotNil(t, args)
|
||||
require.Nil(t, dynamicArgs)
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ func TestArgs(t *testing.T) {
|
|||
jobId, err := server.EnqueueOSBuild(arch.Name(), &job, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, _, args, _, err := server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
_, _, _, args, _, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, args)
|
||||
|
||||
|
|
@ -251,10 +251,10 @@ func TestUpload(t *testing.T) {
|
|||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, jobID, j)
|
||||
require.Equal(t, "osbuild", typ)
|
||||
require.Equal(t, worker.JobTypeOSBuild, typ)
|
||||
require.NotNil(t, args)
|
||||
require.Nil(t, dynamicArgs)
|
||||
|
||||
|
|
@ -281,10 +281,10 @@ func TestUploadAlteredBasePath(t *testing.T) {
|
|||
jobID, err := server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
j, token, typ, args, dynamicArgs, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, jobID, j)
|
||||
require.Equal(t, "osbuild", typ)
|
||||
require.Equal(t, worker.JobTypeOSBuild, typ)
|
||||
require.NotNil(t, args)
|
||||
require.Nil(t, dynamicArgs)
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ func TestTimeout(t *testing.T) {
|
|||
}
|
||||
server := newTestServer(t, t.TempDir(), time.Millisecond*10, "/api/image-builder-worker/v1")
|
||||
|
||||
_, _, _, _, _, err = server.RequestJob(context.Background(), arch.Name(), []string{"osbuild"}, []string{""})
|
||||
_, _, _, _, _, err = server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.Equal(t, jobqueue.ErrDequeueTimeout, err)
|
||||
|
||||
test.TestRoute(t, server.Handler(), false, "POST", "/api/image-builder-worker/v1/jobs", `{"arch":"arch","types":["types"]}`, http.StatusNoContent,
|
||||
|
|
@ -321,13 +321,13 @@ func TestRequestJobById(t *testing.T) {
|
|||
jobId, err := server.EnqueueManifestJobByID(&worker.ManifestJobByID{}, depsolveJobId, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
test.TestRoute(t, server.Handler(), false, "POST", "/api/worker/v1/jobs", `{"arch":"arch","types":["manifest-id-only"]}`, http.StatusBadRequest,
|
||||
test.TestRoute(t, server.Handler(), false, "POST", "/api/worker/v1/jobs", fmt.Sprintf(`{"arch":"arch","types":["%s"]}`, worker.JobTypeManifestIDOnly), http.StatusBadRequest,
|
||||
`{"href":"/api/worker/v1/errors/15","kind":"Error","id": "15","code":"IMAGE-BUILDER-WORKER-15"}`, "operation_id", "reason", "message")
|
||||
|
||||
_, _, _, _, _, err = server.RequestJobById(context.Background(), arch.Name(), jobId)
|
||||
require.Error(t, jobqueue.ErrNotPending, err)
|
||||
|
||||
_, token, _, _, _, err := server.RequestJob(context.Background(), arch.Name(), []string{"depsolve"}, []string{""})
|
||||
_, token, _, _, _, err := server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeDepsolve}, []string{""})
|
||||
require.NoError(t, err)
|
||||
|
||||
depsolveJR, err := json.Marshal(worker.DepsolveJobResult{})
|
||||
|
|
@ -338,7 +338,7 @@ func TestRequestJobById(t *testing.T) {
|
|||
j, token, typ, args, dynamicArgs, err := server.RequestJobById(context.Background(), arch.Name(), jobId)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, jobId, j)
|
||||
require.Equal(t, "manifest-id-only", typ)
|
||||
require.Equal(t, worker.JobTypeManifestIDOnly, typ)
|
||||
require.NotNil(t, args)
|
||||
require.NotNil(t, dynamicArgs)
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ func TestMixedOSBuildJob(t *testing.T) {
|
|||
// don't block forever if the jobs weren't added or can't be retrieved
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "x", []string{"osbuild"}, []string{""})
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "x", []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(err)
|
||||
return id, token
|
||||
}
|
||||
|
|
@ -544,7 +544,7 @@ func TestMixedOSBuildKojiJob(t *testing.T) {
|
|||
for idx := uint(0); idx < 2; idx++ {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
_, token, _, _, _, err := server.RequestJob(ctx, "k", []string{"koji-init"}, []string{""})
|
||||
_, token, _, _, _, err := server.RequestJob(ctx, "k", []string{worker.JobTypeKojiInit}, []string{""})
|
||||
require.NoError(err)
|
||||
require.NoError(server.FinishJob(token, nil))
|
||||
}
|
||||
|
|
@ -553,7 +553,7 @@ func TestMixedOSBuildKojiJob(t *testing.T) {
|
|||
// don't block forever if the jobs weren't added or can't be retrieved
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "k", []string{"osbuild-koji"}, []string{""})
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "k", []string{worker.JobTypeOSBuildKoji}, []string{""})
|
||||
require.NoError(err)
|
||||
return id, token
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ func TestDepsolveLegacyErrorConversion(t *testing.T) {
|
|||
depsolveJobId, err := server.EnqueueDepsolve(&worker.DepsolveJob{}, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, _, _, _, err = server.RequestJob(context.Background(), arch.Name(), []string{"depsolve"}, []string{""})
|
||||
_, _, _, _, _, err = server.RequestJob(context.Background(), arch.Name(), []string{worker.JobTypeDepsolve}, []string{""})
|
||||
require.NoError(t, err)
|
||||
|
||||
reason := "Depsolve failed"
|
||||
|
|
@ -722,7 +722,7 @@ func TestMixedOSBuildJobErrors(t *testing.T) {
|
|||
// don't block forever if the jobs weren't added or can't be retrieved
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "x", []string{"osbuild"}, []string{""})
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "x", []string{worker.JobTypeOSBuild}, []string{""})
|
||||
require.NoError(err)
|
||||
return id, token
|
||||
}
|
||||
|
|
@ -832,7 +832,7 @@ func TestMixedOSBuildKojiJobErrors(t *testing.T) {
|
|||
for idx := uint(0); idx < 2; idx++ {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
_, token, _, _, _, err := server.RequestJob(ctx, "k", []string{"koji-init"}, []string{""})
|
||||
_, token, _, _, _, err := server.RequestJob(ctx, "k", []string{worker.JobTypeKojiInit}, []string{""})
|
||||
require.NoError(err)
|
||||
require.NoError(server.FinishJob(token, nil))
|
||||
}
|
||||
|
|
@ -841,7 +841,7 @@ func TestMixedOSBuildKojiJobErrors(t *testing.T) {
|
|||
// don't block forever if the jobs weren't added or can't be retrieved
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "k", []string{"osbuild-koji"}, []string{""})
|
||||
id, token, _, _, _, err := server.RequestJob(ctx, "k", []string{worker.JobTypeOSBuildKoji}, []string{""})
|
||||
require.NoError(err)
|
||||
return id, token
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue