- Roughing in FileSystemLogger - Deleting Scheduler code and associated unit tests as being too complicated for maintenance. - Refactoring namespaces for loggers and executors.
43 lines
1.8 KiB
C++
43 lines
1.8 KiB
C++
#include <iostream>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
#include "catch.hpp"
|
|
|
|
#include "daggy/Utilities.hpp"
|
|
#include "daggy/Serialization.hpp"
|
|
#include "daggy/executors/task/ForkingTaskExecutor.hpp"
|
|
#include "daggy/loggers/dag_run/StdOutLogger.hpp"
|
|
|
|
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"]})"};
|
|
auto params = daggy::parametersFromJSON(testParams);
|
|
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}", "{{TYPE}}"};
|
|
auto allCommands = daggy::expandCommands(cmd, params);
|
|
|
|
REQUIRE(allCommands.size() == 6);
|
|
}
|
|
|
|
SECTION("Skip over unused parameters") {
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name", "TYPE": ["a", "b", "c"]})"};
|
|
auto params = daggy::parametersFromJSON(testParams);
|
|
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}"};
|
|
auto allCommands = daggy::expandCommands(cmd, params);
|
|
|
|
// TYPE isn't used, so it's just |DATE| * |SOURCE|
|
|
REQUIRE(allCommands.size() == 2);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
|
|
daggy::executors::task::ForkingTaskExecutor ex(10);
|
|
daggy::loggers::dag_run::StdOutLogger logger;
|
|
|
|
std::string taskJSON = R"([{"name": "A", "command": ["/bin/echo", "A"], "children": ["C"]}, {"name": "B", "command": ["/bin/echo", "B"], "children": ["C"]},{"name": "C", "command": ["/bin/echo", "C"]}])";
|
|
auto tasks = daggy::tasksFromJSON(taskJSON);
|
|
auto dag = daggy::buildDAGFromTasks(tasks);
|
|
|
|
auto runID = logger.startDAGRun("test_run", tasks);
|
|
daggy::runDAG(runID, tasks, ex, logger, dag);
|
|
} |