TestAcquirer_UnblockOnCancel tests that a canceled call doesn't block a call from the same domain.
(t *testing.T)
| 288 | // TestAcquirer_UnblockOnCancel tests that a canceled call doesn't block a call |
| 289 | // from the same domain. |
| 290 | func 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 | |
| 326 | func TestAcquirer_MatchTags(t *testing.T) { |
| 327 | t.Parallel() |
nothing calls this directly
no test coverage detected