-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-backlog_crash.R
30 lines (30 loc) · 992 Bytes
/
test-backlog_crash.R
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
test_that("backlogged crashed workers relaunch", {
controller <- crew_controller_local(workers = 2L, seconds_idle = Inf)
on.exit(controller$terminate())
controller$start()
controller$push(name = "task-sleep", command = Sys.sleep(10))
controller$push(name = "task-true", command = TRUE)
controller$scale(throttle = FALSE)
for (handle in controller$launcher$workers$handle) {
crew_retry(
~handle$is_alive(),
seconds_interval = 0.01,
seconds_timeout = 60
)
}
controller$wait(mode = "one")
for (handle in controller$launcher$workers$handle) {
handle$kill()
}
for (handle in controller$launcher$workers$handle) {
crew_retry(
~!handle$is_alive(),
seconds_interval = 0.01,
seconds_timeout = 60
)
}
expect_true(controller$wait(seconds_timeout = 20L))
tasks <- controller$collect()
expect_equal(sort(tasks$name), sort(c("task-sleep", "task-true")))
expect_equal(tasks$error, c(NA_character_, NA_character_))
})