fgerlits commented on code in PR #1738:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1738#discussion_r1522907902
##########
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>());
Review Comment:
we still use `gsl::span` in a few places, but I think `std::span` is
preferred in new code:
```suggestion
stream->write(utils::as_span<const std::byte>(std::span(content));
```
##########
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:
just a suggestion, but I think `GENERATE` is more readable for Cartesian
products than `SECTION`:
```suggestion
const auto [check_health, expected_flowfiles] = GENERATE(
std::make_tuple("false", 2),
std::make_tuple("true", 1));
config->set(minifi::Configure::nifi_flow_file_repository_check_health,
check_health);
const auto content_repo = GENERATE(
static_cast<std::shared_ptr<core::ContentRepository>>(std::make_shared<core::repository::FileSystemRepository>()),
static_cast<std::shared_ptr<core::ContentRepository>>(std::make_shared<core::repository::DatabaseContentRepository>()));
```
(this requires `#include "catch2/generators/catch_generators.hpp"`)
--
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]