TestAcquirer_MultipleSameDomain tests multiple acquirees with the same provisioners and tags
(t *testing.T)
| 68 | |
| 69 | // TestAcquirer_MultipleSameDomain tests multiple acquirees with the same provisioners and tags |
| 70 | func TestAcquirer_MultipleSameDomain(t *testing.T) { |
| 71 | t.Parallel() |
| 72 | fs := newFakeOrderedStore() |
| 73 | ps := pubsub.NewInMemory() |
| 74 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) |
| 75 | defer cancel() |
| 76 | logger := testutil.Logger(t) |
| 77 | uut := provisionerdserver.NewAcquirer(ctx, logger.Named("acquirer"), fs, ps) |
| 78 | |
| 79 | acquirees := make([]*testAcquiree, 0, 10) |
| 80 | jobIDs := make(map[uuid.UUID]bool) |
| 81 | workerIDs := make(map[uuid.UUID]bool) |
| 82 | orgID := uuid.New() |
| 83 | pt := []database.ProvisionerType{database.ProvisionerTypeEcho} |
| 84 | tags := provisionerdserver.Tags{ |
| 85 | "environment": "on-prem", |
| 86 | } |
| 87 | for i := 0; i < 10; i++ { |
| 88 | wID := uuid.New() |
| 89 | workerIDs[wID] = true |
| 90 | a := newTestAcquiree(t, orgID, wID, pt, tags) |
| 91 | acquirees = append(acquirees, a) |
| 92 | a.startAcquire(ctx, uut) |
| 93 | } |
| 94 | for i := 0; i < 10; i++ { |
| 95 | jobID := uuid.New() |
| 96 | jobIDs[jobID] = true |
| 97 | err := fs.sendCtx(ctx, database.ProvisionerJob{ID: jobID}, nil) |
| 98 | require.NoError(t, err) |
| 99 | } |
| 100 | gotJobIDs := make(map[uuid.UUID]bool) |
| 101 | for i := 0; i < 10; i++ { |
| 102 | j := acquirees[i].success(ctx) |
| 103 | gotJobIDs[j.ID] = true |
| 104 | } |
| 105 | require.Equal(t, jobIDs, gotJobIDs) |
| 106 | require.Len(t, fs.overlaps, 0) |
| 107 | gotWorkerCalls := make(map[uuid.UUID]bool) |
| 108 | for _, params := range fs.params { |
| 109 | gotWorkerCalls[params.WorkerID.UUID] = true |
| 110 | } |
| 111 | require.Equal(t, workerIDs, gotWorkerCalls) |
| 112 | } |
| 113 | |
| 114 | // TestAcquirer_WaitsOnNoJobs tests that after a call that returns no jobs, Acquirer waits for a new |
| 115 | // job posting before retrying |
nothing calls this directly
no test coverage detected