TestAcquirer_DifferentDomains tests that acquirees with different tags don't block each other
(t *testing.T)
| 210 | |
| 211 | // TestAcquirer_DifferentDomains tests that acquirees with different tags don't block each other |
| 212 | func TestAcquirer_DifferentDomains(t *testing.T) { |
| 213 | t.Parallel() |
| 214 | fs := newFakeTaggedStore(t) |
| 215 | ps := pubsub.NewInMemory() |
| 216 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) |
| 217 | defer cancel() |
| 218 | logger := testutil.Logger(t) |
| 219 | |
| 220 | orgID := uuid.New() |
| 221 | pt := []database.ProvisionerType{database.ProvisionerTypeEcho} |
| 222 | worker0 := uuid.New() |
| 223 | tags0 := provisionerdserver.Tags{ |
| 224 | "worker": "0", |
| 225 | } |
| 226 | acquiree0 := newTestAcquiree(t, orgID, worker0, pt, tags0) |
| 227 | worker1 := uuid.New() |
| 228 | tags1 := provisionerdserver.Tags{ |
| 229 | "worker": "1", |
| 230 | } |
| 231 | acquiree1 := newTestAcquiree(t, orgID, worker1, pt, tags1) |
| 232 | jobID := uuid.New() |
| 233 | fs.jobs = []database.ProvisionerJob{ |
| 234 | {ID: jobID, Provisioner: database.ProvisionerTypeEcho, Tags: database.StringMap{"worker": "1"}}, |
| 235 | } |
| 236 | |
| 237 | uut := provisionerdserver.NewAcquirer(ctx, logger.Named("acquirer"), fs, ps) |
| 238 | |
| 239 | ctx0, cancel0 := context.WithCancel(ctx) |
| 240 | defer cancel0() |
| 241 | acquiree0.startAcquire(ctx0, uut) |
| 242 | select { |
| 243 | case params := <-fs.params: |
| 244 | require.Equal(t, worker0, params.WorkerID.UUID) |
| 245 | case <-ctx.Done(): |
| 246 | t.Fatal("timed out waiting for call to database from worker0") |
| 247 | } |
| 248 | acquiree0.requireBlocked() |
| 249 | |
| 250 | // worker1 should not be blocked by worker0, as they are different tags |
| 251 | acquiree1.startAcquire(ctx, uut) |
| 252 | job := acquiree1.success(ctx) |
| 253 | require.Equal(t, jobID, job.ID) |
| 254 | |
| 255 | cancel0() |
| 256 | acquiree0.requireCanceled(ctx) |
| 257 | } |
| 258 | |
| 259 | func TestAcquirer_BackupPoll(t *testing.T) { |
| 260 | t.Parallel() |
nothing calls this directly
no test coverage detected