Implement a bunch of clang-tidy suggested changes. Remove FilesystemLogger

This commit is contained in:
Ian Roddis
2021-09-22 10:30:27 -03:00
parent 288ce28d29
commit e7b15b3847
25 changed files with 82 additions and 397 deletions

View File

@@ -1,8 +1,6 @@
#include <catch2/catch.hpp>
#include <iostream>
#include "daggy/DAG.hpp"
TEST_CASE("General tests", "[general]")
{
REQUIRE(1 == 1);

View File

@@ -53,14 +53,14 @@ TEST_CASE("dag_traversal", "[dag]")
std::vector<std::pair<int, int>> edges{{0, 6}, {1, 5}, {5, 6}, {6, 7}, {2, 3},
{3, 5}, {4, 7}, {7, 8}, {7, 9}};
for (auto const [from, to] : edges) {
for (const auto &[from, to] : edges) {
dag.addEdge(from, to);
}
SECTION("Basic Traversal")
{
dag.reset();
std::vector<int> visitOrder(N_VERTICES);
std::vector<size_t> visitOrder(N_VERTICES);
size_t i = 0;
while (!dag.allVisited()) {
const auto v = dag.visitNext().value();
@@ -70,7 +70,7 @@ TEST_CASE("dag_traversal", "[dag]")
}
// Ensure visit order is preserved
for (auto const [from, to] : edges) {
for (const auto &[from, to] : edges) {
REQUIRE(visitOrder[from] <= visitOrder[to]);
}
}

View File

@@ -3,7 +3,6 @@
#include <fstream>
#include <iostream>
#include "daggy/loggers/dag_run/FileSystemLogger.hpp"
#include "daggy/loggers/dag_run/OStreamLogger.hpp"
namespace fs = std::filesystem;
@@ -40,26 +39,6 @@ inline DAGRunID testDAGRunInit(DAGRunLogger &logger, const std::string &name,
return runID;
}
/*
TEST_CASE("Filesystem Logger", "[filesystem_logger]") {
const fs::path logRoot{"fs_logger_unit"};
auto cleanup = [&]() {
if (fs::exists(logRoot)) {
fs::remove_all(logRoot);
}
};
//cleanup();
daggy::loggers::dag_run::FileSystemLogger logger(logRoot);
SECTION("DAGRun Starts") {
testDAGRunInit(logger, "init_test", SAMPLE_TASKS);
}
// cleanup();
}
*/
TEST_CASE("ostream_logger", "[ostream_logger]")
{
// cleanup();

View File

@@ -1,4 +1,3 @@
#include <sys/types.h>
#include <unistd.h>
#include <catch2/catch.hpp>

View File

@@ -7,12 +7,12 @@
#include <daggy/executors/task/ForkingTaskExecutor.hpp>
#include <daggy/loggers/dag_run/OStreamLogger.hpp>
#include <filesystem>
#include <fstream>
#include <iostream>
namespace rj = rapidjson;
Pistache::Http::Response REQUEST(std::string url, std::string payload = "")
Pistache::Http::Response REQUEST(const std::string &url,
const std::string &payload = "")
{
Pistache::Http::Experimental::Client client;
client.init();
@@ -28,12 +28,12 @@ Pistache::Http::Response REQUEST(std::string url, std::string payload = "")
request.then(
[&](Pistache::Http::Response rsp) {
ok = true;
response = rsp;
response = std::move(rsp);
},
[&](std::exception_ptr ptr) {
error = true;
try {
std::rethrow_exception(ptr);
std::rethrow_exception(std::move(ptr));
}
catch (std::exception &e) {
msg = e.what();

View File

@@ -18,10 +18,10 @@ TEST_CASE("threadpool", "[threadpool]")
auto tq = std::make_shared<daggy::TaskQueue>();
std::vector<std::future<uint32_t>> res;
for (size_t i = 0; i < 100; ++i)
res.emplace_back(std::move(tq->addTask([&cnt]() {
res.emplace_back(tq->addTask([&cnt]() {
cnt++;
return cnt.load();
})));
}));
tp.addTasks(tq);
for (auto &r : res)
r.get();

View File

@@ -5,7 +5,6 @@
#include <fstream>
#include <iomanip>
#include <iostream>
#include <random>
#include "daggy/Serialization.hpp"
#include "daggy/Utilities.hpp"
@@ -67,7 +66,7 @@ TEST_CASE("dag_runner_order", "[dagrun_order]")
std::stringstream ss;
daggy::loggers::dag_run::OStreamLogger logger(ss);
daggy::TimePoint startTime = daggy::Clock::now();
daggy::TimePoint globalStartTime = daggy::Clock::now();
std::string testParams{
R"({"DATE": ["2021-05-06", "2021-05-07", "2021-05-08", "2021-05-09" ]})"};
@@ -94,11 +93,11 @@ TEST_CASE("dag_runner_order", "[dagrun_order]")
// Ensure the run order
auto rec = logger.getDAGRun(runID);
daggy::TimePoint stopTime = daggy::Clock::now();
daggy::TimePoint globalStopTime = daggy::Clock::now();
std::array<daggy::TimePoint, 5> minTimes;
minTimes.fill(startTime);
minTimes.fill(globalStartTime);
std::array<daggy::TimePoint, 5> maxTimes;
maxTimes.fill(stopTime);
maxTimes.fill(globalStopTime);
for (const auto &[k, v] : rec.taskAttempts) {
size_t idx = k[0] - 65;