diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt
index ed299d8..0701e65 100644
--- a/project/CMakeLists.txt
+++ b/project/CMakeLists.txt
@@ -23,4 +23,9 @@ add_subdirectory(doct-cpp)
configure_file(
${CMAKE_SOURCE_DIR}/doct-cpp/res/demo_flow.json
${CMAKE_BINARY_DIR}/bin/demo_flow.json
- COPYONLY)
\ No newline at end of file
+ COPYONLY)
+
+configure_file(
+ ${CMAKE_SOURCE_DIR}/doct-cpp/res/add_latency_flow.json
+ ${CMAKE_BINARY_DIR}/bin/add_latency_flow.json
+ COPYONLY)
diff --git a/project/doct-cpp/res/add_latency_flow.json b/project/doct-cpp/res/add_latency_flow.json
new file mode 100644
index 0000000..a464147
--- /dev/null
+++ b/project/doct-cpp/res/add_latency_flow.json
@@ -0,0 +1,31 @@
+{
+ "hostname": "host.name",
+ "tasks": [
+ {
+ "type": "TweakerTask",
+ "description": "Positive latency",
+ "mode": "AddLatency",
+ "tweak": 10
+ },
+ {
+ "type": "CollectorTask",
+ "description": "Measure delays",
+ "mode": "Delays",
+ "threshold": 66,
+ "millisecondDuration": 1000
+ },
+ {
+ "type": "TweakerTask",
+ "description": "Negative latency, not allowed but should not crash",
+ "mode": "AddLatency",
+ "tweak": -10
+ },
+ {
+ "type": "CollectorTask",
+ "description": "Measure delays",
+ "mode": "Delays",
+ "threshold": 66,
+ "millisecondDuration": 1000
+ }
+ ]
+}
\ No newline at end of file
diff --git a/project/doct-cpp/src/tweaker_task_runner.cpp b/project/doct-cpp/src/tweaker_task_runner.cpp
index 56b2d79..6def926 100644
--- a/project/doct-cpp/src/tweaker_task_runner.cpp
+++ b/project/doct-cpp/src/tweaker_task_runner.cpp
@@ -4,6 +4,7 @@
#include "tweaker_mode.hpp"
#include <sstream>
+#include <cstdlib>
namespace doWhile::doct
{
@@ -48,6 +49,16 @@ int TweakerTaskRunner::validateAndCorrectTask(data::TweakerTask* task, const std
case TweakerMode::ConsumeMemory:
possibleCorrection = SystemInfo::get(hostname)->getMemoryUsage();
break;
+
+ case TweakerMode::AddLatency:
+ // Ensure positive value
+ possibleCorrection = std::abs(task->tweak);
+ break;
+
+ case TweakerMode::FailRandomAttempts:
+ // Ensure positive value
+ possibleCorrection = std::abs(task->tweak);
+ break;
}
int result = (task->tweak > possibleCorrection) ? possibleCorrection : task->tweak;