Adding environment interpolation for noop, forking, and slurm executors

This commit is contained in:
Ian Roddis
2021-11-13 12:09:51 -04:00
parent c0315b4f0b
commit 14d0ef4a3f
6 changed files with 119 additions and 27 deletions

View File

@@ -13,7 +13,7 @@ namespace fs = std::filesystem;
#ifdef DAGGY_ENABLE_SLURM
TEST_CASE("slurm environment", "[slurm_env]")
TEST_CASE("slurm environment", "[slurm][slurm_env]")
{
daggy::executors::task::SlurmTaskExecutor ex;
@@ -27,7 +27,7 @@ TEST_CASE("slurm environment", "[slurm_env]")
{"tmpDir", fs::current_path().string()}};
}
TEST_CASE("slurm_execution", "[slurm_executor]")
TEST_CASE("slurm_execution", "[slurm][slurm_executor]")
{
daggy::executors::task::SlurmTaskExecutor ex;
@@ -65,23 +65,36 @@ TEST_CASE("slurm_execution", "[slurm_executor]")
if (fs::exists(scriptFile))
fs::remove_all(scriptFile);
std::string valOne = "funky_times";
std::string valTwo = "bleep_bloop";
std::string valThree = "SOME-DATE";
std::string testParams{R"({"DATE": ")" + valThree + R"("})"};
auto params = daggy::configFromJSON(testParams);
std::ofstream ofh(scriptFile);
ofh << "#!/bin/bash\necho \"${DAGGY_TEST_VAR}\"\necho "
"\"${DAGGY_TEST_VAR2}\"\n";
ofh << R"(#!/bin/bash
echo "${DAGGY_TEST_VAR}"
echo "${DAGGY_TEST_VAR2}"
echo "${DATE}"
)";
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 rawTask{.job{
{"command",
daggy::executors::task::SlurmTaskExecutor::Command{
scriptFile.string()}},
{"environment", std::vector<std::string>{"DAGGY_TEST_VAR=" + valOne,
"DAGGY_TEST_VAR2=" + valTwo,
"DATE={{DATE}}"}}}};
rawTask.job.merge(defaultJobValues);
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);
auto tasks =
daggy::expandTaskSet(daggy::TaskSet{{"cmd", rawTask}}, ex, params);
REQUIRE(tasks.size() == 1);
auto task = tasks.at("cmd_0");
REQUIRE(ex.validateTaskParameters(task.job));
@@ -92,6 +105,7 @@ TEST_CASE("slurm_execution", "[slurm_executor]")
REQUIRE(rec.outputLog.size() >= 6);
REQUIRE(rec.outputLog.find(valOne) != std::string::npos);
REQUIRE(rec.outputLog.find(valTwo) != std::string::npos);
REQUIRE(rec.outputLog.find(valThree) != std::string::npos);
REQUIRE(rec.errorLog.empty());
if (fs::exists(scriptFile))