martinzink commented on code in PR #1653:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1653#discussion_r1320076615


##########
libminifi/test/unit/SchedulingAgentTests.cpp:
##########
@@ -36,133 +38,167 @@ class CountOnTriggersProcessor : public 
minifi::core::Processor {
   static constexpr bool IsSingleThreaded = false;
   ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
 
-  void onTrigger(core::ProcessContext*, core::ProcessSession*) override {
+  void onTrigger(core::ProcessContext* context, core::ProcessSession*) 
override {
     if (on_trigger_duration_ > 0ms)
       std::this_thread::sleep_for(on_trigger_duration_);
     ++number_of_triggers;
+    if (should_yield_)
+      context->yield();
   }
 
   size_t getNumberOfTriggers() const { return number_of_triggers; }
   void setOnTriggerDuration(std::chrono::steady_clock::duration 
on_trigger_duration) { on_trigger_duration_ = on_trigger_duration; }
+  void setShouldYield(bool should_yield) { should_yield_ = should_yield; }
 
  private:
+  bool should_yield_ = false;
   std::chrono::steady_clock::duration on_trigger_duration_ = 0ms;
   std::atomic<size_t> number_of_triggers = 0;
 };
 
+class SchedulingAgentTestFixture {
+ public:
+  SchedulingAgentTestFixture() {
+    count_proc_->incrementActiveTasks();
+    count_proc_->setScheduledState(core::RUNNING);
 
-TEST_CASE("SchedulingAgentTests", "[SchedulingAgent]") {
-  std::shared_ptr<core::Repository> test_repo = 
std::make_shared<TestThreadedRepository>();
-  std::shared_ptr<core::ContentRepository> content_repo = 
std::make_shared<core::repository::VolatileContentRepository>();
-  auto repo = std::static_pointer_cast<TestThreadedRepository>(test_repo);
-  std::shared_ptr<minifi::FlowController> controller =
-      std::make_shared<TestFlowController>(test_repo, test_repo, content_repo);
-
-  TestController testController;
-  auto test_plan = testController.createPlan();
-  auto controller_services_ = 
std::make_shared<minifi::core::controller::ControllerServiceMap>();
-  auto configuration = std::make_shared<minifi::Configure>();
-  auto controller_services_provider_ = 
std::make_shared<minifi::core::controller::StandardControllerServiceProvider>(controller_services_,
 configuration);
-  utils::ThreadPool thread_pool;
-  auto count_proc = std::make_shared<CountOnTriggersProcessor>("count_proc");
-  count_proc->incrementActiveTasks();
-  count_proc->setScheduledState(core::RUNNING);
-  auto node = std::make_shared<core::ProcessorNode>(count_proc.get());
-  auto context = std::make_shared<core::ProcessContext>(node, nullptr, repo, 
repo, content_repo);
-  std::shared_ptr<core::ProcessSessionFactory> factory = 
std::make_shared<core::ProcessSessionFactory>(context);
-  count_proc->setSchedulingPeriod(125ms);
 #ifdef WIN32
-  utils::dateSetInstall(TZ_DATA_DIR);
+    utils::dateSetInstall(TZ_DATA_DIR);
+    date::set_install(TZ_DATA_DIR);

Review Comment:
   but maybe this should warrant a comment here or in the testutils.cpp for 
future reference



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to