fgerlits commented on a change in pull request #791:
URL: https://github.com/apache/nifi-minifi-cpp/pull/791#discussion_r439433613



##########
File path: extensions/standard-processors/tests/unit/TailFileTests.cpp
##########
@@ -652,46 +872,606 @@ TEST_CASE("TailFileWithMultileRolledOverFiles", 
"[tailfiletest2]") {
   char format[] = "/tmp/gt.XXXXXX";
   auto dir = testController.createTempDirectory(format);
 
-  // Define test input file
-  std::string in_file(dir);
-  in_file.append("fruits.txt");
+  std::string test_file = dir + utils::file::FileUtils::get_separator() + 
"fruits.log";
 
-  for (int i = 2; 0 <= i; --i) {
-    if (i < 2) {
-      std::this_thread::sleep_for(std::chrono::milliseconds(1000));  // make 
sure the new file gets newer modification time
-    }
-    std::ofstream in_file_stream(in_file + (i > 0 ? std::to_string(i) : ""));
-    for (int j = 0; j <= i; j++) {
-      in_file_stream << "Apple" << DELIM;
-    }
-    in_file_stream.close();
-  }
+  std::ofstream test_file_stream_0(test_file, std::ios::binary);
+  test_file_stream_0 << "Apple" << DELIM << "Orange" << DELIM;
+  test_file_stream_0.flush();
 
   // Build MiNiFi processing graph
   auto tail_file = plan->addProcessor("TailFile", "Tail");
   plan->setProperty(tail_file, processors::TailFile::Delimiter.getName(), 
std::string(1, DELIM));
-  plan->setProperty(tail_file, processors::TailFile::FileName.getName(), 
in_file);
+  plan->setProperty(tail_file, processors::TailFile::FileName.getName(), 
test_file);
   auto log_attr = plan->addProcessor("LogAttribute", "Log", 
core::Relationship("success", "description"), true);
   plan->setProperty(log_attr, 
processors::LogAttribute::FlowFilesToLog.getName(), "0");
-  // Log as many FFs as it can to make sure exactly the expected amount is 
produced
 
-  // Each iteration should go through one file and log all flowfiles
-  for (int i = 2; 0 <= i; --i) {
-    plan->reset();
-    plan->runNextProcessor();  // Tail
-    plan->runNextProcessor();  // Log
+  testController.runSession(plan, true);
+
+  REQUIRE(LogTestController::getInstance().contains("Logged 2 flow files"));
+  REQUIRE(LogTestController::getInstance().contains("key:filename 
value:fruits.0-5.log"));
+  REQUIRE(LogTestController::getInstance().contains("key:filename 
value:fruits.6-12.log"));
+
+  std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
+  test_file_stream_0 << "Pear" << DELIM;
+  test_file_stream_0.close();
+
+  std::string first_rotated_file = dir + 
utils::file::FileUtils::get_separator() + "fruits.0.log";
+  REQUIRE(rename(test_file.c_str(), first_rotated_file.c_str()) == 0);
+
+  std::ofstream test_file_stream_1(test_file, std::ios::binary);
+  test_file_stream_1 << "Pineapple" << DELIM << "Kiwi" << DELIM;
+  test_file_stream_1.close();
+
+  std::string second_rotated_file = dir + 
utils::file::FileUtils::get_separator() + "fruits.1.log";
+  REQUIRE(rename(test_file.c_str(), second_rotated_file.c_str()) == 0);
+
+  std::ofstream test_file_stream_2(test_file, std::ios::binary);
+  test_file_stream_2 << "Apricont" << DELIM;

Review comment:
       An apricont is a type of apricot often depicted in Russian religious 
paintings.  Fixed.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to