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


##########
extensions/rocksdb-repos/tests/RepoTests.cpp:
##########
@@ -781,4 +780,83 @@ TEST_CASE("Content repositories are always running", 
"[TestRepoIsRunning]") {
   REQUIRE(content_repo->isRunning());
 }
 
+std::shared_ptr<minifi::FlowFileRecord> 
createFlowFileWithContent(core::ContentRepository& content_repo, 
std::string_view content) {
+  auto flow_file = std::make_shared<minifi::FlowFileRecord>();
+  const auto content_session = content_repo.createSession();
+  const auto claim = content_session->create();
+  const auto stream = content_session->write(claim);
+
+  stream->write(gsl::make_span(content).as_span<const std::byte>());
+  flow_file->setResourceClaim(claim);
+  flow_file->setSize(stream->size());
+  flow_file->setOffset(0);
+  stream->close();
+  content_session->commit();
+  return flow_file;
+}
+
+void corruptFlowFile(core::FlowFile& ff) {
+  ff.setSize(ff.getSize()*2);
+}
+
+TEST_CASE("FlowFileRepository can filter out too small contents") {
+  LogTestController::getInstance().setDebug<core::ContentRepository>();
+  
LogTestController::getInstance().setDebug<core::repository::FileSystemRepository>();
+  
LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>();
+  TestController testController;
+  const auto ff_dir = testController.createTempDirectory();
+  const auto content_dir = testController.createTempDirectory();
+
+  auto config = std::make_shared<minifi::Configure>();
+  config->set(minifi::Configure::nifi_flowfile_repository_directory_default, 
ff_dir.string());
+  config->set(minifi::Configure::nifi_dbcontent_repository_directory_default, 
content_dir.string());
+  size_t expected_flowfiles = std::numeric_limits<size_t>::max();
+  std::shared_ptr<core::ContentRepository> content_repo;
+
+  SECTION("nifi.flowfile.repository.check.health set to false") {
+    config->set(minifi::Configure::nifi_flow_file_repository_check_health, 
"false");
+    expected_flowfiles = 2;
+    SECTION("FileSystemRepository") {
+      content_repo = 
std::make_shared<core::repository::FileSystemRepository>();
+    }
+    SECTION("RocksDB") {
+      content_repo = 
std::make_shared<core::repository::DatabaseContentRepository>();
+    }
+  }
+  SECTION("nifi.flowfile.repository.check.health set to true") {
+    config->set(minifi::Configure::nifi_flow_file_repository_check_health, 
"true");
+    expected_flowfiles = 1;
+    SECTION("FileSystemRepository") {
+      content_repo = 
std::make_shared<core::repository::FileSystemRepository>();
+    }
+    SECTION("RocksDB") {
+      content_repo = 
std::make_shared<core::repository::DatabaseContentRepository>();
+    }
+  }

Review Comment:
   Oh didnt know about this feature, looks way more clean thanks
   
https://github.com/apache/nifi-minifi-cpp/pull/1738/commits/a804730683686e95180515c36a62d8ba29a81aca



-- 
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-unsubscr...@nifi.apache.org

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

Reply via email to