- Adjusting tests so they run without referencing /tmp
This commit is contained in:
@@ -9,7 +9,7 @@ TEST_CASE("Basic Execution", "[forking_executor]") {
|
||||
daggy::executors::task::ForkingTaskExecutor ex(10);
|
||||
|
||||
SECTION("Simple Run") {
|
||||
daggy::Task task{.command{"/usr/bin/echo", "abc", "123"}};
|
||||
daggy::Task task{.command{"/bin/echo", "abc", "123"}};
|
||||
|
||||
auto rec = ex.runCommand(task);
|
||||
|
||||
@@ -24,7 +24,7 @@ TEST_CASE("Basic Execution", "[forking_executor]") {
|
||||
auto rec = ex.runCommand(task);
|
||||
|
||||
REQUIRE(rec.rc == 2);
|
||||
REQUIRE(rec.errorLog == "/usr/bin/expr: syntax error: missing argument after ‘+’\n");
|
||||
REQUIRE(rec.errorLog.find("syntax error:") != std::string::npos);
|
||||
REQUIRE(rec.outputLog.empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ TEST_CASE("Server Basic Endpoints", "[server_basic]") {
|
||||
"taskParameters": { "FILE": [ "A", "B" ] },
|
||||
"tasks": [
|
||||
{ "name": "touch",
|
||||
"command": [ "/usr/bin/touch", "/tmp/{{FILE}}" ]
|
||||
"command": [ "/usr/bin/touch", "dagrun_{{FILE}}" ]
|
||||
},
|
||||
{
|
||||
"name": "cat",
|
||||
"command": [ "/usr/bin/cat", "/tmp/A", "/tmp/B" ],
|
||||
"command": [ "/usr/bin/cat", "dagrun_A", "dagrun_B" ],
|
||||
"parents": [ "touch" ]
|
||||
}
|
||||
]
|
||||
@@ -85,8 +85,9 @@ TEST_CASE("Server Basic Endpoints", "[server_basic]") {
|
||||
|
||||
auto response = REQUEST(baseURL + "/v1/dagrun/", dagRun);
|
||||
REQUIRE(response.code() == Pistache::Http::Code::Ok);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
for (const auto &pth : std::vector<fs::path>{"/tmp/A", "/tmp/B"}) {
|
||||
for (const auto &pth : std::vector<fs::path>{"dagrun_A", "dagrun_B"}) {
|
||||
REQUIRE(fs::exists(pth));
|
||||
fs::remove(pth);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_CASE("Parameter Expansion", "[utilities_parameter_expansion]") {
|
||||
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}}"};
|
||||
std::vector<std::string> cmd{"/usr/bin/touch", "{{DATE}}_{{SOURCE}}"};
|
||||
auto result = daggy::expandCommands(cmd, params);
|
||||
|
||||
// TYPE isn't used, so it's just |DATE| * |SOURCE|
|
||||
@@ -61,7 +61,7 @@ TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
|
||||
daggy::loggers::dag_run::OStreamLogger logger(ss);
|
||||
|
||||
SECTION("Simple execution") {
|
||||
std::string prefix = "/tmp/asdlk_";
|
||||
std::string prefix = "asdlk_";
|
||||
std::string taskJSON = R"([{"name": "A", "command": ["/usr/bin/touch", ")"
|
||||
+ prefix + R"(A"], "children": ["C"]}, {"name": "B", "command": ["/usr/bin/touch", ")"
|
||||
+ prefix + R"(B"], "children": ["C"]}, {"name": "C", "command": ["/usr/bin/touch", ")"
|
||||
@@ -90,23 +90,24 @@ TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
|
||||
}
|
||||
|
||||
SECTION("Recovery from Error") {
|
||||
auto cleanup = []() {
|
||||
// Cleanup
|
||||
std::vector<fs::path> paths{"/tmp/rec_error_A", "/tmp/noexist" };
|
||||
for (const auto & pth : paths) {
|
||||
if (fs::exists(pth)) fs::remove_all(pth);
|
||||
}
|
||||
};
|
||||
auto cleanup = []() {
|
||||
// Cleanup
|
||||
std::vector<fs::path> paths{"rec_error_A", "noexist"};
|
||||
for (const auto &pth : paths) {
|
||||
if (fs::exists(pth)) fs::remove_all(pth);
|
||||
}
|
||||
};
|
||||
|
||||
cleanup();
|
||||
cleanup();
|
||||
|
||||
|
||||
// daggy::loggers::dag_run::OStreamLogger logger(std::cout);
|
||||
|
||||
std::string goodPrefix = "/tmp/rec_error_";
|
||||
std::string badPrefix = "/tmp/noexist/rec_error_";
|
||||
std::string goodPrefix = "rec_error_";
|
||||
std::string badPrefix = "noexist/rec_error_";
|
||||
std::string taskJSON = R"([{"name": "A", "command": ["/usr/bin/touch", ")"
|
||||
+ goodPrefix + R"(A"], "children": ["C"]}, {"name": "B", "command": ["/usr/bin/touch", ")"
|
||||
+ goodPrefix +
|
||||
R"(A"], "children": ["C"]}, {"name": "B", "command": ["/usr/bin/touch", ")"
|
||||
+ badPrefix + R"(B"], "children": ["C"]}, {"name": "C", "command": ["/usr/bin/touch", ")"
|
||||
+ badPrefix + R"(C"]}])";
|
||||
auto tasks = daggy::tasksFromJSON(taskJSON);
|
||||
@@ -119,7 +120,7 @@ TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
|
||||
REQUIRE(!tryDAG.allVisited());
|
||||
|
||||
// Create the missing dir, then continue to run the DAG
|
||||
fs::create_directory("/tmp/noexist");
|
||||
fs::create_directory("noexist");
|
||||
tryDAG.resetRunning();
|
||||
auto endDAG = daggy::runDAG(runID, tasks, ex, logger, tryDAG);
|
||||
|
||||
@@ -131,6 +132,6 @@ TEST_CASE("DAG Runner", "[utilities_dag_runner]") {
|
||||
REQUIRE(record.taskAttempts[1].size() == 2); // B errored and had to be retried
|
||||
REQUIRE(record.taskAttempts[2].size() == 1); // C wasn't run because B errored
|
||||
|
||||
cleanup();
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user