MCPcopy Create free account
hub / github.com/coder/coder / TestAcquirer_UnblockOnCancel

Function TestAcquirer_UnblockOnCancel

coderd/provisionerdserver/acquirer_test.go:290–324  ·  view source on GitHub ↗

TestAcquirer_UnblockOnCancel tests that a canceled call doesn't block a call from the same domain.

(t *testing.T)

Source from the content-addressed store, hash-verified

288// TestAcquirer_UnblockOnCancel tests that a canceled call doesn't block a call
289// from the same domain.
290func TestAcquirer_UnblockOnCancel(t *testing.T) {
291 t.Parallel()
292 fs := newFakeOrderedStore()
293 ps := pubsub.NewInMemory()
294 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
295 defer cancel()
296 logger := testutil.Logger(t)
297
298 pt := []database.ProvisionerType{database.ProvisionerTypeEcho}
299 orgID := uuid.New()
300 worker0 := uuid.New()
301 tags := provisionerdserver.Tags{
302 "environment": "on-prem",
303 }
304 acquiree0 := newTestAcquiree(t, orgID, worker0, pt, tags)
305 worker1 := uuid.New()
306 acquiree1 := newTestAcquiree(t, orgID, worker1, pt, tags)
307 jobID := uuid.New()
308
309 uut := provisionerdserver.NewAcquirer(ctx, logger.Named("acquirer"), fs, ps)
310
311 // queue up 2 responses --- we may not need both, since acquiree0 will
312 // usually cancel before calling, but cancel is async, so it might call.
313 for i := 0; i < 2; i++ {
314 err := fs.sendCtx(ctx, database.ProvisionerJob{ID: jobID}, nil)
315 require.NoError(t, err)
316 }
317
318 ctx0, cancel0 := context.WithCancel(ctx)
319 cancel0()
320 acquiree0.startAcquire(ctx0, uut)
321 acquiree1.startAcquire(ctx, uut)
322 job := acquiree1.success(ctx)
323 require.Equal(t, jobID, job.ID)
324}
325
326func TestAcquirer_MatchTags(t *testing.T) {
327 t.Parallel()

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected