Squashed commit of the following:
commit 8a4e0fb24d191bf1c1009bd4c8800b4adab21f81 Author: Ian Roddis <gitlab@ie2r.com> Date: Tue Oct 5 17:23:21 2021 -0300 Adding support for commandString commit 9055cbde34d2489065b03c25c02a8bea56e42d54 Author: Ian Roddis <gitlab@ie2r.com> Date: Tue Oct 5 17:10:01 2021 -0300 Completing support for environment variables commit 989adef378724bbc9451c5048ea9d1285eebe2f9 Author: Ian Roddis <gitlab@ie2r.com> Date: Tue Oct 5 12:29:31 2021 -0300 Adding environment support to ForkingTaskExecutor
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "daggy/Serialization.hpp"
|
||||
@@ -12,6 +13,20 @@ namespace fs = std::filesystem;
|
||||
|
||||
#ifdef DAGGY_ENABLE_SLURM
|
||||
|
||||
TEST_CASE("slurm environment", "[slurm_env]")
|
||||
{
|
||||
daggy::executors::task::SlurmTaskExecutor ex;
|
||||
|
||||
daggy::ConfigValues defaultJobValues{{"minCPUs", "1"},
|
||||
{"minMemoryMB", "100"},
|
||||
{"minTmpDiskMB", "0"},
|
||||
{"priority", "1"},
|
||||
{"timeLimitSeconds", "200"},
|
||||
{"userID", std::to_string(getuid())},
|
||||
{"workDir", fs::current_path().string()},
|
||||
{"tmpDir", fs::current_path().string()}};
|
||||
}
|
||||
|
||||
TEST_CASE("slurm_execution", "[slurm_executor]")
|
||||
{
|
||||
daggy::executors::task::SlurmTaskExecutor ex;
|
||||
@@ -42,6 +57,62 @@ TEST_CASE("slurm_execution", "[slurm_executor]")
|
||||
REQUIRE(rec.errorLog.empty());
|
||||
}
|
||||
|
||||
SECTION("Simple run with environment")
|
||||
{
|
||||
// Create the shell script
|
||||
auto scriptFile = fs::current_path() / "slurm_simple_env.sh";
|
||||
|
||||
if (fs::exists(scriptFile))
|
||||
fs::remove_all(scriptFile);
|
||||
|
||||
std::ofstream ofh(scriptFile);
|
||||
ofh << "#!/bin/bash\necho \"${DAGGY_TEST_VAR}\"\necho "
|
||||
"\"${DAGGY_TEST_VAR2}\"\n";
|
||||
ofh.close();
|
||||
fs::permissions(scriptFile, fs::perms::owner_all,
|
||||
fs::perm_options::replace);
|
||||
|
||||
std::string valOne = "funky_times";
|
||||
std::string valTwo = "bleep_bloop";
|
||||
|
||||
daggy::Task task{.job{{"command",
|
||||
daggy::executors::task::SlurmTaskExecutor::Command{
|
||||
scriptFile.string()}},
|
||||
{"environment", std::vector<std::string>{
|
||||
"DAGGY_TEST_VAR=" + valOne,
|
||||
"DAGGY_TEST_VAR2=" + valTwo}}}};
|
||||
task.job.merge(defaultJobValues);
|
||||
|
||||
REQUIRE(ex.validateTaskParameters(task.job));
|
||||
|
||||
auto recFuture = ex.execute(0, "command", task);
|
||||
auto rec = recFuture.get();
|
||||
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.outputLog.size() >= 6);
|
||||
REQUIRE(rec.outputLog.find(valOne) != std::string::npos);
|
||||
REQUIRE(rec.outputLog.find(valTwo) != std::string::npos);
|
||||
REQUIRE(rec.errorLog.empty());
|
||||
|
||||
if (fs::exists(scriptFile))
|
||||
fs::remove_all(scriptFile);
|
||||
}
|
||||
|
||||
SECTION("Simple Run using commandString")
|
||||
{
|
||||
daggy::Task task{.job{{"commandString", R"(/usr/bin/echo "abc 123")"}}};
|
||||
task.job.merge(defaultJobValues);
|
||||
|
||||
REQUIRE(ex.validateTaskParameters(task.job));
|
||||
|
||||
auto recFuture = ex.execute(0, "command", task);
|
||||
auto rec = recFuture.get();
|
||||
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.outputLog.size() >= 6);
|
||||
REQUIRE(rec.errorLog.empty());
|
||||
}
|
||||
|
||||
SECTION("Error Run")
|
||||
{
|
||||
daggy::Task task{
|
||||
|
||||
Reference in New Issue
Block a user