-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eee4423
commit 57341c0
Showing
6 changed files
with
156 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
library(crew) | ||
library(testthat) | ||
|
||
crew_test("single controller, no tasks", { | ||
for (group in c(FALSE, TRUE)) { | ||
y <- crew_controller_local() | ||
x <- if_any(group, crew_controller_group(y), y) | ||
on.exit({ | ||
x$terminate() | ||
crew_test_sleep() | ||
}) | ||
x$start() | ||
time <- system.time( | ||
expect_true( | ||
x$wait( | ||
mode = "all", | ||
seconds_interval = 5, | ||
seconds_timeout = Inf | ||
) | ||
) | ||
)["elapsed"] | ||
expect_true(time < 1) | ||
time <- system.time( | ||
expect_false( | ||
x$wait( | ||
mode = "one", | ||
seconds_interval = 5, | ||
seconds_timeout = Inf | ||
) | ||
) | ||
)["elapsed"] | ||
expect_true(time < 1) | ||
x$terminate() | ||
crew_test_sleep() | ||
} | ||
}) | ||
|
||
crew_test("single controller, all tasks already done", { | ||
for (group in c(FALSE, TRUE)) { | ||
y <- crew_controller_local() | ||
x <- if_any(group, crew_controller_group(y), y) | ||
on.exit({ | ||
x$terminate() | ||
crew_test_sleep() | ||
}) | ||
x$start() | ||
x$push(TRUE) | ||
x$wait() | ||
for (mode in c("all", "one")) { | ||
time <- system.time( | ||
expect_true( | ||
x$wait( | ||
mode = mode, | ||
seconds_interval = 5, | ||
seconds_timeout = Inf | ||
) | ||
) | ||
)["elapsed"] | ||
expect_true(time < 1) | ||
} | ||
x$terminate() | ||
crew_test_sleep() | ||
} | ||
}) | ||
|
||
crew_test("single controller, one long task, time out", { | ||
for (group in c(FALSE, TRUE)) { | ||
y <- crew_controller_local() | ||
x <- if_any(group, crew_controller_group(y), y) | ||
on.exit({ | ||
x$terminate() | ||
crew_test_sleep() | ||
}) | ||
x$start() | ||
x$push(Sys.sleep(10)) | ||
for (mode in c("all", "one")) { | ||
time <- system.time( | ||
expect_false( | ||
x$wait( | ||
mode = mode, | ||
seconds_interval = 0.1, | ||
seconds_timeout = 0.2 | ||
) | ||
) | ||
)["elapsed"] | ||
expect_true(time < 1) | ||
} | ||
x$terminate() | ||
crew_test_sleep() | ||
} | ||
}) | ||
|
||
crew_test("single controller, one long task, wait all, full wait", { | ||
for (group in c(FALSE, TRUE)) { | ||
for (mode in c("all", "one")) { | ||
y <- crew_controller_local() | ||
x <- if_any(group, crew_controller_group(y), y) | ||
on.exit({ | ||
x$terminate() | ||
crew_test_sleep() | ||
}) | ||
x$start() | ||
x$push(Sys.sleep(5)) | ||
time <- system.time( | ||
expect_true( | ||
x$wait( | ||
mode = mode, | ||
seconds_interval = 0.5, | ||
seconds_timeout = Inf | ||
) | ||
) | ||
)["elapsed"] | ||
expect_true(time > 4) | ||
x$terminate() | ||
crew_test_sleep() | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters