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
|
context("BatchJobs mode")
test_that("BatchJobs mode", {
requireNamespace("BatchJobs")
storagedir = tempdir()
# if on lido or SLURM for test, tempdir is not shared and test wih torque wont run
if (BatchJobs::getConfig()$cluster.functions$name %in% c("SLURM", "Torque")) {
storagedir = getwd()
}
parallelStartBatchJobs(storagedir = storagedir)
partest1()
parallelStop()
parallelStartBatchJobs(logging = TRUE, storagedir = storagedir)
expect_warning(partest2(storagedir), "xxx")
parallelStop()
parallelStartBatchJobs(storagedir = storagedir)
partest3()
parallelStop()
parallelStartBatchJobs(storagedir = storagedir)
# we cannot really check that wrong libraries are not loaded on slave here.
# because we only load them during the job. but the error will show up then
partest4(slave.error.test = FALSE)
parallelStop()
parallelStartBatchJobs(storagedir = storagedir)
partest5()
parallelStop()
parallelStartBatchJobs(storagedir = storagedir)
partest6(slave.error.test = FALSE)
parallelStop()
# test that expire generate exceptions
# we can of course only do that on a true batch system
if (BatchJobs::getConfig()$cluster.functions$name %in% c("SLURM", "Torque")) {
parallelStartBatchJobs(storagedir = storagedir, bj.resources = list(walltime = 1))
f = function(i) Sys.sleep(30 * 60)
expect_error(suppressWarnings(parallelMap(f, 1:2)), "expired")
parallelStop()
}
# test that working dir on master is working dir on slave
oldwd = getwd()
bn = "parallelMap_test_temp_dir_123"
newwd = file.path(storagedir, bn)
dir.create(newwd)
setwd(newwd)
parallelStartBatchJobs(storagedir = storagedir)
f = function(i) getwd()
y = parallelMap(f, 1)
parallelStop()
expect_equal(basename(y[[1]]), bn)
setwd(oldwd)
unlink(newwd, recursive = TRUE)
})
|