- Checkpointing work on expanding commands.

This commit is contained in:
Ian Roddis
2021-08-20 10:39:39 -03:00
parent 9f90f54b67
commit 1668117566
3 changed files with 62 additions and 15 deletions

View File

@@ -2,6 +2,10 @@
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <catch2/catch.hpp>
#include "daggy/Utilities.hpp"
@@ -9,6 +13,12 @@
#include "daggy/executors/task/ForkingTaskExecutor.hpp"
#include "daggy/loggers/dag_run/OStreamLogger.hpp"
TEST_CASE("String Utilities", "[utilities_string]") {
std::string test = "/this/is/{{A}}/test/{{A}}";
auto res = daggy::globalSub(test, "{{A}}", "hello");
REQUIRE(res == "/this/is/hello/test/hello");
}
TEST_CASE("Parameter Expansion", "[utilities_parameter_expansion]") {
SECTION("Basic expansion") {
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name", "TYPE": ["a", "b", "c"]})"};
@@ -28,6 +38,22 @@ TEST_CASE("Parameter Expansion", "[utilities_parameter_expansion]") {
// TYPE isn't used, so it's just |DATE| * |SOURCE|
REQUIRE(allCommands.size() == 2);
}
SECTION("Expand within a command part") {
std::string testParams{
R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": ["A", "B"], "TYPE": ["a", "b", "c"]})"};
auto params = daggy::parametersFromJSON(testParams);
std::vector<std::string> cmd{"/usr/bin/touch", "/tmp/{{DATE}}_{{SOURCE}}"};
auto result = daggy::expandCommands(cmd, params);
// TYPE isn't used, so it's just |DATE| * |SOURCE|
REQUIRE(result.size() == 4);
for (const auto &command : result) {
std::copy(command.begin(), command.end(), std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
}
}
}
TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
@@ -41,4 +67,4 @@ TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
auto runID = logger.startDAGRun("test_run", tasks);
daggy::runDAG(runID, tasks, ex, logger, dag);
}
}