MCPcopy Index your code
hub / github.com/coder/coder / TestAcquirer_MultipleSameDomain

Function TestAcquirer_MultipleSameDomain

coderd/provisionerdserver/acquirer_test.go:70–112  ·  view source on GitHub ↗

TestAcquirer_MultipleSameDomain tests multiple acquirees with the same provisioners and tags

(t *testing.T)

Source from the content-addressed store, hash-verified

68
69// TestAcquirer_MultipleSameDomain tests multiple acquirees with the same provisioners and tags
70func 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

Callers

nothing calls this directly

Calls 12

NewInMemoryFunction · 0.92
LoggerFunction · 0.92
NewAcquirerFunction · 0.92
newFakeOrderedStoreFunction · 0.85
newTestAcquireeFunction · 0.85
NamedMethod · 0.80
startAcquireMethod · 0.80
sendCtxMethod · 0.80
successMethod · 0.80
NewMethod · 0.65
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected