From 39c7f3bbcd0bc8fb63ecf1c519b7419b91023087 Mon Sep 17 00:00:00 2001 From: wlandau Date: Sun, 28 Jan 2024 08:36:22 -0500 Subject: [PATCH] Save common load tests --- tests/hpc/test-crew_local.R | 35 ++++++++++++++++++++++++++--------- tests/hpc/test-crew_sge.R.R | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 tests/hpc/test-crew_sge.R.R diff --git a/tests/hpc/test-crew_local.R b/tests/hpc/test-crew_local.R index 15323e09..42e0b04d 100644 --- a/tests/hpc/test-crew_local.R +++ b/tests/hpc/test-crew_local.R @@ -82,6 +82,25 @@ tar_test("prevent high-memory data via target objects", { pryr::object_size(self) }) +tar_test("saturated controllers should get tasks", { + # Also watch CPU usage on htop. Should be low. + skip_on_cran() + skip_if_not_installed("crew") + tar_script({ + library(targets) + controller <- crew::crew_controller_local(workers = 2) + tar_option_set(controller = controller) + list( + tar_target(w, Sys.sleep(10)), + tar_target(x, Sys.sleep(10)), + tar_target(y, Sys.sleep(10)), + tar_target(z, Sys.sleep(10)) + ) + }) + tar_make() # All 4 targets should start and the last 2 should be "pending". + expect_equal(tar_outdated(callr_function = NULL), character(0)) +}) + tar_test("heavily parallel workload should run fast", { skip_on_cran() skip_if_not_installed("crew") @@ -120,21 +139,19 @@ tar_test("heavily parallel workload should run fast", { expect_equal(tar_outdated(callr_function = NULL), character(0)) }) -tar_test("saturated controllers should get tasks", { - # Also watch CPU usage on htop. Should be low. +tar_test("crew local with many tasks and many workers", { skip_on_cran() skip_if_not_installed("crew") tar_script({ + library(crew) library(targets) - controller <- crew::crew_controller_local(workers = 2) + controller <- crew_controller_local(workers = 25, tasks_max = 100) tar_option_set(controller = controller) list( - tar_target(w, Sys.sleep(10)), - tar_target(x, Sys.sleep(10)), - tar_target(y, Sys.sleep(10)), - tar_target(z, Sys.sleep(10)) + tar_target(x, seq_len(10000)), + tar_target(y, Sys.sleep(1), pattern = map(x)) ) }) - tar_make() # All 4 targets should start and the last 2 should be "pending". - expect_equal(tar_outdated(callr_function = NULL), character(0)) + tar_make() + expect_equal(tar_outdated(reporter = "forecast"), character(0)) }) diff --git a/tests/hpc/test-crew_sge.R.R b/tests/hpc/test-crew_sge.R.R new file mode 100644 index 00000000..f632da72 --- /dev/null +++ b/tests/hpc/test-crew_sge.R.R @@ -0,0 +1,20 @@ +tar_test("crew SGE with many tasks and many workers", { + skip_on_cran() + skip_if_not_installed("crew.cluster") + tar_script({ + library(crew.cluster) + library(targets) + controller <- crew_controller_sge( + workers = 25, + tasks_max = 100, + script_lines = "module load R/4.2.2" + ) + tar_option_set(controller = controller) + list( + tar_target(x, seq_len(10000)), + tar_target(y, Sys.sleep(1), pattern = map(x)) + ) + }) + tar_make() + expect_equal(tar_outdated(reporter = "forecast"), character(0)) +})