-
Notifications
You must be signed in to change notification settings - Fork 5
/
tasks_test.go
590 lines (482 loc) · 20.2 KB
/
tasks_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
package vizzini_test
import (
"encoding/json"
"fmt"
"net"
"net/http"
"regexp"
"strings"
"time"
"github.com/onsi/gomega/ghttp"
"code.cloudfoundry.org/bbs/models"
. "code.cloudfoundry.org/vizzini/matchers"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Tasks", func() {
var task *models.TaskDefinition
BeforeEach(func() {
task = Task()
})
Describe("Creating Tasks", func() {
Context("When the task is well formed (the happy path)", func() {
BeforeEach(func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
})
It("runs the task", func() {
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.TaskGuid).To(Equal(guid))
Expect(task.Failed).To(BeFalse())
Expect(task.Result).To(ContainSubstring("some output"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("when the task guid is malformed", func() {
It("should fail to create", func() {
var badGuid string
badGuid = "abc def"
err := bbsClient.DesireTask(logger, traceID, badGuid, domain, task)
Expect(models.ConvertError(err).Type).To(Equal(models.Error_InvalidRequest))
badGuid = "abc/def"
Expect(bbsClient.DesireTask(logger, traceID, badGuid, domain, task)).NotTo(Succeed())
badGuid = "abc,def"
Expect(bbsClient.DesireTask(logger, traceID, badGuid, domain, task)).NotTo(Succeed())
badGuid = "abc.def"
Expect(bbsClient.DesireTask(logger, traceID, badGuid, domain, task)).NotTo(Succeed())
badGuid = "abc∆def"
Expect(bbsClient.DesireTask(logger, traceID, badGuid, domain, task)).NotTo(Succeed())
})
})
Context("when the task guid is not unique", func() {
It("should fail to create", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
err := bbsClient.DesireTask(logger, traceID, guid, domain, task)
Expect(models.ConvertError(err).Type).To(Equal(models.Error_ResourceExists))
By("even when the domain is different")
Expect(bbsClient.DesireTask(logger, traceID, guid, otherDomain, task)).NotTo(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("when required fields are missing", func() {
It("should fail", func() {
By("not having TaskGuid")
Expect(bbsClient.DesireTask(logger, traceID, "", domain, task)).NotTo(Succeed())
By("not having a domain")
Expect(bbsClient.DesireTask(logger, traceID, guid, "", task)).NotTo(Succeed())
By("not having any actions")
invalidTask := Task()
invalidTask.Action = nil
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, invalidTask)).NotTo(Succeed())
By("not having a rootfs")
invalidTask = Task()
invalidTask.RootFs = ""
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, invalidTask)).NotTo(Succeed())
By("having a malformed rootfs")
invalidTask = Task()
invalidTask.RootFs = "ploop"
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, invalidTask)).NotTo(Succeed())
})
})
Context("when the annotation is too large", func() {
It("should fail", func() {
task.Annotation = strings.Repeat("7", 1024*10+1)
err := bbsClient.DesireTask(logger, traceID, guid, domain, task)
Expect(models.ConvertError(err).Type).To(Equal(models.Error_InvalidRequest))
})
})
Context("Upon failure", func() {
BeforeEach(func() {
task.Action = models.WrapAction(&models.RunAction{
Path: "bash",
Args: []string{"-c", "echo 'some output' > /tmp/bar && exit 1"},
User: "vcap",
})
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
})
It("should be marked as failed and should not return the result file", func() {
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.TaskGuid).To(Equal(guid))
Expect(task.Failed).To(BeTrue())
Expect(task.Result).To(BeEmpty())
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
})
Describe("Specifying environment variables", func() {
BeforeEach(func() {
task.EnvironmentVariables = []*models.EnvironmentVariable{
{Name: "CONTAINER_LEVEL", Value: "A"},
{Name: "OVERRIDE", Value: "B"},
}
task.Action = models.WrapAction(&models.RunAction{
Path: "bash",
Args: []string{"-c", "env > /tmp/bar"},
User: "vcap",
Env: []*models.EnvironmentVariable{
{Name: "ACTION_LEVEL", Value: "C"},
{Name: "OVERRIDE", Value: "D"},
},
})
})
It("should be possible to specify environment variables on both the Task and the RunAction", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.Result).To(ContainSubstring("CONTAINER_LEVEL=A"))
Expect(task.Result).To(ContainSubstring("ACTION_LEVEL=C"))
Expect(task.Result).To(ContainSubstring("OVERRIDE=D"))
Expect(task.Result).NotTo(ContainSubstring("OVERRIDE=B"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Describe("{DOCKER} Creating a Docker-based Task", func() {
BeforeEach(func() {
task.RootFs = "docker:///cloudfoundry/busybox-alice"
task.Action = models.WrapAction(&models.RunAction{
Path: "sh",
Args: []string{"-c", "echo 'down-the-rabbit-hole' > payload && chmod 0400 payload"},
User: "alice",
})
task.ResultFile = "/home/alice/payload"
})
JustBeforeEach(func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
})
It("should succeed", func() {
Eventually(TaskGetter(logger, guid), 120).Should(HaveTaskState(models.Task_Completed), "Docker can be quite slow to spin up....")
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.Failed).To(BeFalse())
Expect(task.Result).To(ContainSubstring("down-the-rabbit-hole"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
Context("with an OCI image", func() {
BeforeEach(func() {
task.RootFs = config.DiegoDockerOCIImageURL
task.Action = models.WrapAction(&models.RunAction{
Path: "sh",
Args: []string{"-c", "echo 'down-the-rabbit-hole' > /payload && chmod 0400 /payload"},
User: "root",
})
task.ResultFile = "/payload"
})
It("should succeed", func() {
Eventually(TaskGetter(logger, guid), 120).Should(HaveTaskState(models.Task_Completed), "Docker can be quite slow to spin up....")
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.Failed).To(BeFalse())
Expect(task.Result).To(ContainSubstring("down-the-rabbit-hole"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
})
Describe("Cancelling tasks", func() {
Context("when the task exists", func() {
var lrpGuid string
BeforeEach(func() {
lrpGuid = NewGuid()
lrp := DesiredLRPWithGuid(lrpGuid)
Expect(bbsClient.DesireLRP(logger, traceID, lrp)).To(Succeed())
Eventually(EndpointCurler("http://" + RouteForGuid(lrpGuid) + "/env")).Should(Equal(http.StatusOK))
incrementCounterRoute := "http://" + RouteForGuid(lrpGuid) + "/counter"
task.EgressRules = []*models.SecurityGroupRule{
{
Protocol: models.AllProtocol,
Destinations: []string{"0.0.0.0/0"},
},
}
task.Action = models.WrapAction(&models.RunAction{
Path: "bash",
Args: []string{"-c", fmt.Sprintf("while true; do curl %s -X POST -d 'body'; sleep 0.05; done", incrementCounterRoute)},
User: "vcap",
})
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
})
It("should cancel the task immediately", func() {
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Running))
By("verifying the counter is being incremented")
Eventually(GraceCounterGetter(lrpGuid)).Should(BeNumerically(">", 2))
Expect(bbsClient.CancelTask(logger, traceID, guid)).To(Succeed())
By("marking the task as completed")
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.State).To(Equal(models.Task_Completed))
Expect(task.Failed).To(BeTrue())
Expect(task.FailureReason).To(Equal("task was cancelled"))
By("actually shutting down the container immediately, it should stop incrementing the counter")
counterAfterCancel, err := GraceCounterGetter(lrpGuid)()
Expect(err).NotTo(HaveOccurred())
time.Sleep(2 * time.Second)
counterAfterSomeTime, err := GraceCounterGetter(lrpGuid)()
Expect(err).NotTo(HaveOccurred())
Expect(counterAfterSomeTime).To(BeNumerically("<", counterAfterCancel+20))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("when the task does not exist", func() {
It("should fail", func() {
Expect(bbsClient.CancelTask(logger, traceID, "floobeedoo")).NotTo(Succeed())
})
})
Context("when the task is already completed", func() {
BeforeEach(func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
})
It("should fail", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).NotTo(Succeed())
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
})
Describe("Getting a task", func() {
Context("when the task exists", func() {
BeforeEach(func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
})
It("should succeed", func() {
Eventually(TaskGetter(logger, guid)).ShouldNot(BeZero())
task, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(task.TaskGuid).To(Equal(guid))
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("when the task does not exist", func() {
It("should error", func() {
task, err := bbsClient.TaskByGuid(logger, traceID, "floobeedoo")
Expect(task).To(BeZero())
Expect(models.ConvertError(err).Type).To(Equal(models.Error_ResourceNotFound))
})
})
})
Describe("Getting All Tasks and Getting Tasks by Domain", func() {
var otherGuids []string
BeforeEach(func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
otherGuids = []string{NewGuid(), NewGuid()}
for _, otherGuid := range otherGuids {
otherTask := Task()
Expect(bbsClient.DesireTask(logger, traceID, otherGuid, otherDomain, otherTask)).To(Succeed())
Eventually(TaskGetter(logger, otherGuid)).Should(HaveTaskState(models.Task_Completed))
}
})
AfterEach(func() {
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
for _, otherGuid := range otherGuids {
Expect(bbsClient.ResolvingTask(logger, traceID, otherGuid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, otherGuid)).To(Succeed())
}
})
It("should fetch tasks in the given domain", func() {
tasksInDomain, err := bbsClient.TasksByDomain(logger, traceID, domain)
Expect(err).NotTo(HaveOccurred())
tasksInOtherDomain, err := bbsClient.TasksByDomain(logger, traceID, otherDomain)
Expect(err).NotTo(HaveOccurred())
Expect(tasksInDomain).To(HaveLen(1))
Expect(tasksInOtherDomain).To(HaveLen(2))
Expect([]string{tasksInOtherDomain[0].TaskGuid, tasksInOtherDomain[1].TaskGuid}).To(ConsistOf(otherGuids))
})
It("should not error if a domain is empty", func() {
tasks, err := bbsClient.TasksByDomain(logger, traceID, "farfignoogan")
Expect(err).NotTo(HaveOccurred())
Expect(tasks).To(BeEmpty())
})
It("should fetch all tasks", func() {
allTasks, err := bbsClient.Tasks(logger, traceID)
Expect(err).NotTo(HaveOccurred())
//if we're running in parallel there may be more than 3 things here!
Expect(len(allTasks)).To(BeNumerically(">=", 3))
taskGuids := []string{}
for _, task := range allTasks {
taskGuids = append(taskGuids, task.TaskGuid)
}
Expect(taskGuids).To(ContainElement(guid))
Expect(taskGuids).To(ContainElement(otherGuids[0]))
Expect(taskGuids).To(ContainElement(otherGuids[1]))
})
})
Describe("Deleting Tasks", func() {
Context("when the task is in the completed state", func() {
It("should be deleted", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
_, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).To(HaveOccurred())
})
})
Context("when the task is not in the completed state", func() {
It("should not be deleted, and should error", func() {
task.Action = models.WrapAction(&models.RunAction{
Path: "bash",
Args: []string{"-c", "sleep 2; echo 'some output' > /tmp/bar"},
User: "vcap",
})
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Running))
err := bbsClient.ResolvingTask(logger, traceID, guid)
Expect(models.ConvertError(err).Type).To(Equal(models.Error_InvalidStateTransition))
_, err = bbsClient.TasksByDomain(logger, traceID, domain)
Expect(err).NotTo(HaveOccurred())
Eventually(TaskGetter(logger, guid)).Should(HaveTaskState(models.Task_Completed))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("when the task does not exist", func() {
It("should not be deleted, and should error", func() {
err := bbsClient.ResolvingTask(logger, traceID, "floobeedoobee")
Expect(models.ConvertError(err).Type).To(Equal(models.Error_ResourceNotFound))
})
})
})
Describe("Registering Completion Callbacks", func() {
var server *ghttp.Server
var port string
var status int
var done chan struct{}
BeforeEach(func() {
status = http.StatusOK
server = ghttp.NewUnstartedServer()
l, err := net.Listen("tcp", "0.0.0.0:0")
Expect(err).NotTo(HaveOccurred())
server.HTTPTestServer.Listener = l
server.HTTPTestServer.Start()
re := regexp.MustCompile(`:(\d+)$`)
port = re.FindStringSubmatch(server.URL())[1]
Expect(port).NotTo(BeZero())
done = make(chan struct{})
server.AppendHandlers(ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/endpoint"),
ghttp.RespondWithPtr(&status, nil),
func(w http.ResponseWriter, req *http.Request) {
var receivedTask models.Task
json.NewDecoder(req.Body).Decode(&receivedTask)
Expect(receivedTask.TaskGuid).To(Equal(guid))
close(done)
},
))
task.CompletionCallbackUrl = "http://" + config.HostAddress + ":" + port + "/endpoint"
})
AfterEach(func() {
server.Close()
})
Context("when the server responds succesfully", func() {
BeforeEach(func() {
status = http.StatusOK
})
It("cleans up the task", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(done).Should(BeClosed())
Eventually(func() bool {
_, err := bbsClient.TaskByGuid(logger, traceID, guid)
return err == nil
}).Should(BeFalse(), "Eventually, the task should be resolved")
})
})
Context("when the server responds in the 4XX range", func() {
BeforeEach(func() {
status = http.StatusNotFound
})
It("nonetheless, cleans up the task", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(done).Should(BeClosed())
Eventually(func() bool {
_, err := bbsClient.TaskByGuid(logger, traceID, guid)
return err == nil
}).Should(BeFalse(), "Eventually, the task should be resolved")
})
})
Context("when the server responds with 503 repeatedly", func() {
var secondDone chan struct{}
BeforeEach(func() {
status = http.StatusServiceUnavailable
secondDone = make(chan struct{})
server.AppendHandlers(ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/endpoint"),
ghttp.RespondWith(http.StatusOK, nil),
func(w http.ResponseWriter, req *http.Request) {
var receivedTask models.Task
json.NewDecoder(req.Body).Decode(&receivedTask)
Expect(receivedTask.TaskGuid).To(Equal(guid))
close(secondDone)
},
))
})
It("should retry", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(done).Should(BeClosed())
Eventually(secondDone).Should(BeClosed())
Eventually(func() bool {
_, err := bbsClient.TaskByGuid(logger, traceID, guid)
return err == nil
}).Should(BeFalse(), "Eventually, the task should be resolved")
})
})
Context("[Regression: #84595244] when there's no room for the Task", func() {
BeforeEach(func() {
task.MemoryMb = 1024 * 1024
})
It("should hit the callback", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(done, taskFailureTimeout).Should(BeClosed())
Eventually(func() bool {
_, err := bbsClient.TaskByGuid(logger, traceID, guid)
return err == nil
}).Should(BeFalse(), "Eventually, the task should be resolved")
})
})
})
Describe("when the Task cannot be allocated", func() {
Context("because it's too large", func() {
BeforeEach(func() {
task.MemoryMb = 1024 * 1024
})
It("should allow creation of the task but should mark the task as failed", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid), taskFailureTimeout).Should(HaveTaskState(models.Task_Completed))
retreivedTask, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(retreivedTask.Failed).To(BeTrue())
Expect(retreivedTask.FailureReason).To(ContainSubstring("insufficient resources"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
Context("because of a stack mismatch", func() {
BeforeEach(func() {
task.RootFs = models.PreloadedRootFS("fruitfs")
})
It("should allow creation of the task but should mark the task as failed", func() {
Expect(bbsClient.DesireTask(logger, traceID, guid, domain, task)).To(Succeed())
Eventually(TaskGetter(logger, guid), taskFailureTimeout).Should(HaveTaskState(models.Task_Completed))
retreivedTask, err := bbsClient.TaskByGuid(logger, traceID, guid)
Expect(err).NotTo(HaveOccurred())
Expect(retreivedTask.Failed).To(BeTrue())
Expect(retreivedTask.FailureReason).To(ContainSubstring("found no compatible cell"))
Expect(bbsClient.ResolvingTask(logger, traceID, guid)).To(Succeed())
Expect(bbsClient.DeleteTask(logger, traceID, guid)).To(Succeed())
})
})
})
})