You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/10/25 07:39:52 UTC
[GitHub] [nifi-minifi-cpp] martinzink commented on a diff in pull request #1439: MINIFICPP-1967 Add batch processing of lines in TailFile
martinzink commented on code in PR #1439:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1439#discussion_r1004113991
##########
extensions/standard-processors/tests/unit/TailFileTests.cpp:
##########
@@ -1847,3 +1847,38 @@ TEST_CASE("TailFile can use an AttributeProviderService", "[AttributeProviderSer
LogTestController::getInstance().reset();
}
+
+TEST_CASE("TailFile honors batch size for maximum lines processed", "[batchSize]") {
+ TestController testController;
+ LogTestController::getInstance().setTrace<minifi::processors::TailFile>();
+ LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+
+ std::shared_ptr<TestPlan> plan = testController.createPlan();
+ std::shared_ptr<core::Processor> tailfile = plan->addProcessor("TailFile", "TailFile");
+ auto logattribute = plan->addProcessor("LogAttribute", "LogAttribute", core::Relationship("success", "description"), true);
+ plan->setProperty(logattribute, org::apache::nifi::minifi::processors::LogAttribute::FlowFilesToLog.getName(), "0");
+
+ auto dir = testController.createTempDirectory();
+ std::stringstream temp_file;
+ temp_file << dir << utils::file::get_separator() << TMP_FILE;
+
+ std::ofstream tmpfile;
+ tmpfile.open(temp_file.str(), std::ios::out | std::ios::binary);
+ for (auto i = 0; i < 20; ++i) {
+ tmpfile << NEW_TAIL_DATA;
+ }
+ tmpfile.close();
+
+ std::stringstream state_file;
+ state_file << dir << utils::file::get_separator() << STATE_FILE;
+
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::FileName.getName(), temp_file.str());
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::Delimiter.getName(), "\n");
+ plan->setProperty(tailfile, org::apache::nifi::minifi::processors::TailFile::BatchSize.getName(), "10");
+
+ testController.runSession(plan);
+
+ REQUIRE(LogTestController::getInstance().contains("Logged 10 flow files"));
Review Comment:
I think it would be better to utilize the https://github.com/apache/nifi-minifi-cpp/blob/main/libminifi/test/SingleProcessorTestController.h then you could directly check the number of flowfiles tailfile generates per trigger, instead of the indirect LogAttribute approach, and this test could be much simpler.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org