szaszm commented on a change in pull request #1173:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1173#discussion_r707243044
##########
File path: extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
##########
@@ -306,3 +291,97 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
REQUIRE(true == LogTestController::getInstance().contains("Exiting because
method is POST"));
LogTestController::getInstance().reset();
}
+
+TEST_CASE("HTTPTestsPenalizeNoRetry", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
Review comment:
This is a single statement. It should be on one line in this case, but
in general it can be separated with a new line + continuation indentation (+4
spaces or aligned) if it's too long.
##########
File path: extensions/http-curl/processors/InvokeHTTP.cpp
##########
@@ -443,6 +447,7 @@ void InvokeHTTP::route(const
std::shared_ptr<core::FlowFile> &request, const std
} else {
if (request != nullptr) {
if (penalize_no_retry_) {
+ logger_->log_debug("Flowfile has been penalized");
session->penalize(request);
}
Review comment:
ProcessSession::penalize already produces a log message, so I think this
is unnecessary.
##########
File path: extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
##########
@@ -306,3 +291,97 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
REQUIRE(true == LogTestController::getInstance().contains("Exiting because
method is POST"));
LogTestController::getInstance().reset();
}
+
+TEST_CASE("HTTPTestsPenalizeNoRetry", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
+
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GenerateFlowFile>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ListenHTTP>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::core::ProcessSession>();
+
+ std::shared_ptr<core::Processor>
+ listenhttp =
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
Review comment:
Same here
##########
File path: docker/test/integration/features/http.feature
##########
@@ -8,7 +8,6 @@ Feature: Sending data using InvokeHTTP to a receiver using
ListenHTTP
Scenario: A MiNiFi instance transfers data to another MiNiFi instance with
message body
Given a GetFile processor with the "Input Directory" property set to
"/tmp/input"
- And the "Keep Source File" property of the GetFile processor is set to
"true"
Review comment:
Are these removed because the input files are not used anymore and just
to keep things simple? Or was there an actual problem due to processing the
same file multiple time? Or what is the reason for this change?
##########
File path: extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
##########
@@ -306,3 +291,97 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
REQUIRE(true == LogTestController::getInstance().contains("Exiting because
method is POST"));
LogTestController::getInstance().reset();
}
+
+TEST_CASE("HTTPTestsPenalizeNoRetry", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
+
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GenerateFlowFile>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ListenHTTP>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::core::ProcessSession>();
+
+ std::shared_ptr<core::Processor>
+ listenhttp =
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
+ listenhttp->initialize();
+ std::shared_ptr<core::ProcessorNode> node =
std::make_shared<core::ProcessorNode>(listenhttp);
+ std::shared_ptr<core::ProcessContext> context =
std::make_shared<core::ProcessContext>(node, nullptr, repo, repo, content_repo);
+
context->setProperty(org::apache::nifi::minifi::processors::ListenHTTP::BasePath,
"/testytesttest");
+
context->setProperty(org::apache::nifi::minifi::processors::ListenHTTP::Port,
"8681");
+ auto session = std::make_shared<core::ProcessSession>(context);
+ std::shared_ptr<core::ProcessSessionFactory> factory =
std::make_shared<core::ProcessSessionFactory>(context);
+ listenhttp->setScheduledState(core::ScheduledState::RUNNING);
+ listenhttp->onSchedule(context, factory);
+ listenhttp->onTrigger(context, session);
+
+ std::shared_ptr<TestPlan> plan = testController.createPlan();
+ std::shared_ptr<core::Processor> genfile =
plan->addProcessor("GenerateFlowFile", "genfile");
+ std::shared_ptr<core::Processor> invokehttp =
plan->addProcessor("InvokeHTTP", "invokehttp", core::Relationship("success",
"description"), true);
+
+ plan->setProperty(invokehttp,
org::apache::nifi::minifi::processors::InvokeHTTP::Method.getName(), "GET");
+ plan->setProperty(invokehttp,
org::apache::nifi::minifi::processors::InvokeHTTP::URL.getName(),
"http://localhost:8681/testytesttest");
+
+ SECTION("with penalize on no retry set to true") {
+ plan->setProperty(invokehttp,
+
org::apache::nifi::minifi::processors::InvokeHTTP::PenalizeOnNoRetry.getName(),
+ "true");
+ invokehttp->setAutoTerminatedRelationships({InvokeHTTP::RelFailure,
InvokeHTTP::RelNoRetry, InvokeHTTP::RelResponse,
+ InvokeHTTP::RelRetry});
+ testController.runSession(plan, true);
+
+ REQUIRE(LogTestController::getInstance().contains("Flowfile has been
penalized"));
+ } SECTION("with penalize on no retry set to false") {
+ plan->setProperty(invokehttp,
+
org::apache::nifi::minifi::processors::InvokeHTTP::PenalizeOnNoRetry.getName(),
+ "false");
+ invokehttp->setAutoTerminatedRelationships({InvokeHTTP::RelFailure,
InvokeHTTP::RelNoRetry, InvokeHTTP::RelResponse,
+ InvokeHTTP::RelRetry});
+ testController.runSession(plan, true);
+
+ REQUIRE_FALSE(LogTestController::getInstance().contains("Flowfile has been
penalized"));
+ }
+}
+
+TEST_CASE("HTTPTestsPutResponseBodyinAttribute", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+ std::string url = "http://localhost:8681/testytesttest";
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
+
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GenerateFlowFile>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ListenHTTP>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::core::ProcessSession>();
+
+ std::shared_ptr<core::Processor>
+ listenhttp =
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>
("listenhttp");
Review comment:
same here
##########
File path: extensions/http-curl/tests/unit/InvokeHTTPTests.cpp
##########
@@ -306,3 +291,97 @@ TEST_CASE("HTTPTestsPostNoResourceClaim", "[httptest1]") {
REQUIRE(true == LogTestController::getInstance().contains("Exiting because
method is POST"));
LogTestController::getInstance().reset();
}
+
+TEST_CASE("HTTPTestsPenalizeNoRetry", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
+ std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>();
+
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::GenerateFlowFile>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::ListenHTTP>();
+
LogTestController::getInstance().setTrace<org::apache::nifi::minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::core::ProcessSession>();
+
+ std::shared_ptr<core::Processor>
+ listenhttp =
std::make_shared<org::apache::nifi::minifi::processors::ListenHTTP>("listenhttp");
+ listenhttp->initialize();
+ std::shared_ptr<core::ProcessorNode> node =
std::make_shared<core::ProcessorNode>(listenhttp);
+ std::shared_ptr<core::ProcessContext> context =
std::make_shared<core::ProcessContext>(node, nullptr, repo, repo, content_repo);
+
context->setProperty(org::apache::nifi::minifi::processors::ListenHTTP::BasePath,
"/testytesttest");
+
context->setProperty(org::apache::nifi::minifi::processors::ListenHTTP::Port,
"8681");
+ auto session = std::make_shared<core::ProcessSession>(context);
+ std::shared_ptr<core::ProcessSessionFactory> factory =
std::make_shared<core::ProcessSessionFactory>(context);
+ listenhttp->setScheduledState(core::ScheduledState::RUNNING);
+ listenhttp->onSchedule(context, factory);
+ listenhttp->onTrigger(context, session);
+
+ std::shared_ptr<TestPlan> plan = testController.createPlan();
+ std::shared_ptr<core::Processor> genfile =
plan->addProcessor("GenerateFlowFile", "genfile");
+ std::shared_ptr<core::Processor> invokehttp =
plan->addProcessor("InvokeHTTP", "invokehttp", core::Relationship("success",
"description"), true);
+
+ plan->setProperty(invokehttp,
org::apache::nifi::minifi::processors::InvokeHTTP::Method.getName(), "GET");
+ plan->setProperty(invokehttp,
org::apache::nifi::minifi::processors::InvokeHTTP::URL.getName(),
"http://localhost:8681/testytesttest");
+
+ SECTION("with penalize on no retry set to true") {
+ plan->setProperty(invokehttp,
+
org::apache::nifi::minifi::processors::InvokeHTTP::PenalizeOnNoRetry.getName(),
+ "true");
+ invokehttp->setAutoTerminatedRelationships({InvokeHTTP::RelFailure,
InvokeHTTP::RelNoRetry, InvokeHTTP::RelResponse,
+ InvokeHTTP::RelRetry});
+ testController.runSession(plan, true);
+
+ REQUIRE(LogTestController::getInstance().contains("Flowfile has been
penalized"));
+ } SECTION("with penalize on no retry set to false") {
+ plan->setProperty(invokehttp,
+
org::apache::nifi::minifi::processors::InvokeHTTP::PenalizeOnNoRetry.getName(),
+ "false");
+ invokehttp->setAutoTerminatedRelationships({InvokeHTTP::RelFailure,
InvokeHTTP::RelNoRetry, InvokeHTTP::RelResponse,
+ InvokeHTTP::RelRetry});
+ testController.runSession(plan, true);
+
+ REQUIRE_FALSE(LogTestController::getInstance().contains("Flowfile has been
penalized"));
+ }
+}
+
+TEST_CASE("HTTPTestsPutResponseBodyinAttribute", "[httptest1]") {
+ TestController testController;
+ using processors::InvokeHTTP;
+ std::string url = "http://localhost:8681/testytesttest";
+
+ std::shared_ptr<core::ContentRepository>
+ content_repo =
std::make_shared<core::repository::VolatileContentRepository>();
Review comment:
same here
--
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]