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 2021/05/21 15:35:28 UTC
[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
lordgamez opened a new pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082
Handling the use case when InvokeHTTP processor has no real incoming connection but there is a Retry self-loop, the scheduler should trigger the processor.
Jira ticket: https://issues.apache.org/jira/browse/MINIFICPP-1494
Note: We discussed that renaming the relationships is not an option to avoid introducing a breaking change, only change (1) is implemented
---------------------------------------------------------------------------------------------
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642931510
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
Review comment:
there seems to be a similar class `VerifyRetryInvokeHTTP` in `VerifyInvokeHTTPTests.cpp`, how do the two relate?
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642931271
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
+ public:
+ VerifyHTTPGet(const cmd_args& args, CivetHandler& http_handler)
+ : args_(args),
+ configuration_(std::make_shared<minifi::Configure>()),
+ test_repo_(std::make_shared<TestRepository>()),
+ test_flow_repo_(std::make_shared<TestFlowRepository>()),
+ content_repo_(std::make_shared<core::repository::VolatileContentRepository>()),
+ stream_factory_(minifi::io::StreamFactory::getInstance(configuration_)) {
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
+ LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+
+ setupFlow();
+ setupURL();
+ setupServer(http_handler);
+ controller_->load();
+ }
- std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
- configuration->set(minifi::Configure::nifi_default_directory, args.key_dir);
+ ~VerifyHTTPGet() {
+ controller_->waitUnload(60000);
+ LogTestController::getInstance().reset();
+ }
- std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
- std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
+ void run() {
+ controller_->start();
+ runAssertions();
+ }
- configuration->set(minifi::Configure::nifi_flow_configuration_file, args.test_file);
+ protected:
+ virtual void runAssertions() {
+ assert(org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime(
+ std::chrono::seconds(10),
+ "key:invokehttp.request.url value:" + url_,
+ "key:invokehttp.status.code value:200",
+ "key:flow.id"));
+ }
- std::shared_ptr<minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(configuration);
+ void setupFlow() {
+ configuration_->set(minifi::Configure::nifi_default_directory, args_.key_dir);
+ configuration_->set(minifi::Configure::nifi_flow_configuration_file, args_.test_file);
+ content_repo_->initialize(configuration_);
- std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>();
+ std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
+ new core::YamlConfiguration(test_repo_, test_repo_, content_repo_, stream_factory_, configuration_, args_.test_file));
- content_repo->initialize(configuration);
+ controller_ = std::make_shared<minifi::FlowController>(
+ test_repo_, test_flow_repo_, configuration_, std::move(yaml_ptr), content_repo_, DEFAULT_ROOT_GROUP_NAME, true);
+ }
- std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
- new core::YamlConfiguration(test_repo, test_repo, content_repo, stream_factory, configuration, args.test_file));
- std::shared_ptr<TestRepository> repo = std::static_pointer_cast<TestRepository>(test_repo);
+ void setupURL() {
+ core::YamlConfiguration yaml_config(test_repo_, test_repo_, content_repo_, stream_factory_, configuration_, args_.test_file);
- std::shared_ptr<minifi::FlowController> controller = std::make_shared<minifi::FlowController>(
- test_repo, test_flow_repo, configuration, std::move(yaml_ptr), content_repo, DEFAULT_ROOT_GROUP_NAME, true);
+ std::shared_ptr<core::Processor> proc = yaml_config.getRoot()->findProcessorByName("invoke");
+ assert(proc != nullptr);
- core::YamlConfiguration yaml_config(test_repo, test_repo, content_repo, stream_factory, configuration, args.test_file);
+ const auto inv = std::dynamic_pointer_cast<minifi::processors::InvokeHTTP>(proc);
+ assert(inv != nullptr);
- std::shared_ptr<core::Processor> proc = yaml_config.getRoot()->findProcessorByName("invoke");
- assert(proc != nullptr);
+ inv->getProperty(minifi::processors::InvokeHTTP::URL.getName(), url_);
+ }
+
+ void setupServer(CivetHandler& http_handler) {
Review comment:
there seems to be a similar class `VerifyRetryInvokeHTTP` in `VerifyInvokeHTTPTests.cpp`, how do the two relate?
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r640430620
##########
File path: PROCESSORS.md
##########
@@ -704,6 +704,10 @@ In the list below, the names of required properties appear in bold. Any other pr
| Name | Description |
| - | - |
|success|All files are routed to success|
Review comment:
This is not true, right?
```suggestion
|success|The incoming FlowFile is routed, unchanged, to success if the GET operation succeeded|
```
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644979437
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
martinzink commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r640873051
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
+ public:
+ VerifyHTTPGet(const cmd_args& args, CivetHandler& http_handler)
+ : args_(args)
+ , configuration_(std::make_shared<minifi::Configure>())
+ , test_repo_(std::make_shared<TestRepository>())
+ , test_flow_repo_(std::make_shared<TestFlowRepository>())
+ , content_repo_(std::make_shared<core::repository::VolatileContentRepository>())
+ , stream_factory_(minifi::io::StreamFactory::getInstance(configuration_)) {
Review comment:
very minor, but I feel like the comma should be in the end of the previous lines, to comply with our style guide
https://google.github.io/styleguide/cppguide.html#Constructor_Initializer_Lists
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r656096277
##########
File path: extensions/http-curl/processors/InvokeHTTP.cpp
##########
@@ -123,9 +123,12 @@ const char* InvokeHTTP::REMOTE_DN = "invokehttp.remote.dn";
const char* InvokeHTTP::EXCEPTION_CLASS = "invokehttp.java.exception.class";
const char* InvokeHTTP::EXCEPTION_MESSAGE = "invokehttp.java.exception.message";
-core::Relationship InvokeHTTP::Success("success", "All files are routed to success");
+core::Relationship InvokeHTTP::Success("success", "The original FlowFile will be routed upon success (2xx status codes). "
+ "It will have new attributes detailing the success of the request.");
-core::Relationship InvokeHTTP::RelResponse("response", "Represents a response flowfile");
+core::Relationship InvokeHTTP::RelResponse("response", "A Response FlowFile will be routed upon success (2xx status codes). "
+ "If the 'Output Response Regardless' property is true then the response will be sent "
Review comment:
```suggestion
"If the 'Always Output Response' property is true then the response will be sent "
```
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
adam-markovics commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644741953
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
Review comment:
This can even be accessed using [], since emptiness is checked before.
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
+ assert(stateController);
+ const auto processorController = std::dynamic_pointer_cast<minifi::state::ProcessorController>(stateController);
+ assert(processorController);
+ auto proc = processorController->getProcessor();
+ proc->setProperty(property, value);
+ }
+
+ virtual void setupFlow(const utils::optional<std::string>& flow_yml_path) {
+ testSetup();
+
+ std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
+ std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
+
+ if (flow_yml_path) {
+ configuration->set(minifi::Configure::nifi_flow_configuration_file, *flow_yml_path);
+ }
+ configuration->set("c2.agent.heartbeat.period", "200");
+ std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>();
+ content_repo->initialize(configuration);
+ std::shared_ptr<minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(configuration);
+ std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
Review comment:
Could be make_unique.
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
Review comment:
Is it necessary to increase the ref count of proc?
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642564772
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
+ public:
+ VerifyHTTPGet(const cmd_args& args, CivetHandler& http_handler)
+ : args_(args)
+ , configuration_(std::make_shared<minifi::Configure>())
+ , test_repo_(std::make_shared<TestRepository>())
+ , test_flow_repo_(std::make_shared<TestFlowRepository>())
+ , content_repo_(std::make_shared<core::repository::VolatileContentRepository>())
+ , stream_factory_(minifi::io::StreamFactory::getInstance(configuration_)) {
Review comment:
You are right, that was just some ad-hoc style I was used to. Fixed it in a0f1f41e01915b75f2c3f4ca15162fae9fb587a6
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644979437
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
+ assert(stateController);
+ const auto processorController = std::dynamic_pointer_cast<minifi::state::ProcessorController>(stateController);
+ assert(processorController);
+ auto proc = processorController->getProcessor();
+ proc->setProperty(property, value);
+ }
+
+ virtual void setupFlow(const utils::optional<std::string>& flow_yml_path) {
+ testSetup();
+
+ std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
+ std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
+
+ if (flow_yml_path) {
+ configuration->set(minifi::Configure::nifi_flow_configuration_file, *flow_yml_path);
+ }
+ configuration->set("c2.agent.heartbeat.period", "200");
+ std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>();
+ content_repo->initialize(configuration);
+ std::shared_ptr<minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(configuration);
+ std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644112320
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
Review comment:
I did some refactoring and reused the `VeifyInvokeHTTP` class for the `VerifyHTTPGet` in 13b46dc6e39687ec63bd545127bae8a6012c7327
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r640705010
##########
File path: PROCESSORS.md
##########
@@ -704,6 +704,10 @@ In the list below, the names of required properties appear in bold. Any other pr
| Name | Description |
| - | - |
|success|All files are routed to success|
Review comment:
This is not true, I updated it in ddb119bc9a787d6d5c8600dfd2c7ed22e72da1ed to be on par with the NiFi description.
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642965617
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
Review comment:
I wanted to keep it separate as the `HTTPIntegrationBase` has way more complexity than we need, but I'll check if we could reuse it and reduce any duplications.
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644979882
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
+ assert(stateController);
+ const auto processorController = std::dynamic_pointer_cast<minifi::state::ProcessorController>(stateController);
+ assert(processorController);
+ auto proc = processorController->getProcessor();
+ proc->setProperty(property, value);
+ }
+
+ virtual void setupFlow(const utils::optional<std::string>& flow_yml_path) {
+ testSetup();
+
+ std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
+ std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
+
+ if (flow_yml_path) {
+ configuration->set(minifi::Configure::nifi_flow_configuration_file, *flow_yml_path);
+ }
+ configuration->set("c2.agent.heartbeat.period", "200");
+ std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>();
+ content_repo->initialize(configuration);
+ std::shared_ptr<minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(configuration);
+ std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
Review comment:
Updated in 7f194ba73816ee7fb8464089813e29573106e506
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642948760
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
Review comment:
VerifyInvokeHTTPTests is similar in design, but it has verifications with callbacks for POST requests and only uses yaml configuration files with POST invoke operations.
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r640704122
##########
File path: extensions/librdkafka/tests/ConsumeKafkaTests.cpp
##########
@@ -422,7 +422,7 @@ class ConsumeKafkaContinuousPublishingTest : public ConsumeKafkaTest {
int64_t value;
org::apache::nifi::minifi::core::TimeUnit unit;
REQUIRE(org::apache::nifi::minifi::core::Property::StringToTime(property_string, value, unit));
- int64_t value_as_ms;
+ int64_t value_as_ms = 0;
Review comment:
You are right, it just came up as an error while compiling and I fixed it on the fly. I removed it and will have it in a separate PR.
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r640430620
##########
File path: PROCESSORS.md
##########
@@ -704,6 +704,10 @@ In the list below, the names of required properties appear in bold. Any other pr
| Name | Description |
| - | - |
|success|All files are routed to success|
Review comment:
I think this could be clarified, eg. `All incoming FlowFiles are routed, unchanged, to succes`
##########
File path: extensions/librdkafka/tests/ConsumeKafkaTests.cpp
##########
@@ -422,7 +422,7 @@ class ConsumeKafkaContinuousPublishingTest : public ConsumeKafkaTest {
int64_t value;
org::apache::nifi::minifi::core::TimeUnit unit;
REQUIRE(org::apache::nifi::minifi::core::Property::StringToTime(property_string, value, unit));
- int64_t value_as_ms;
+ int64_t value_as_ms = 0;
Review comment:
this should be in a different pull request, as it is not related to this change
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r642963063
##########
File path: extensions/http-curl/tests/HttpGetIntegrationTest.cpp
##########
@@ -63,78 +62,134 @@ class HttpResponder : public CivetHandler {
}
};
-int main(int argc, char **argv) {
- using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime;
- const cmd_args args = parse_cmdline_args(argc, argv);
+class RetryHttpGetResponder : public CivetHandler {
+ public:
+ bool handleGet(CivetServer* /*server*/, struct mg_connection *conn) override {
+ puts("handle get with retry");
+ mg_printf(conn, "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n");
+ return true;
+ }
+};
- LogTestController::getInstance().setDebug<core::Processor>();
- LogTestController::getInstance().setDebug<core::ProcessSession>();
- LogTestController::getInstance().setDebug<utils::HTTPClient>();
- LogTestController::getInstance().setDebug<minifi::controllers::SSLContextService>();
- LogTestController::getInstance().setDebug<minifi::processors::InvokeHTTP>();
- LogTestController::getInstance().setDebug<minifi::processors::LogAttribute>();
+class VerifyHTTPGet {
Review comment:
could we somehow reuse it (or any of its base classes `VeifyInvokeHTTP`, `HTTPIntegrationBase`) as base class of `VerifyHTTPGet`? they provide some of functionality implemented here (setting up the server, possibly the flow itself)
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r656099994
##########
File path: extensions/http-curl/processors/InvokeHTTP.cpp
##########
@@ -123,9 +123,12 @@ const char* InvokeHTTP::REMOTE_DN = "invokehttp.remote.dn";
const char* InvokeHTTP::EXCEPTION_CLASS = "invokehttp.java.exception.class";
const char* InvokeHTTP::EXCEPTION_MESSAGE = "invokehttp.java.exception.message";
-core::Relationship InvokeHTTP::Success("success", "All files are routed to success");
+core::Relationship InvokeHTTP::Success("success", "The original FlowFile will be routed upon success (2xx status codes). "
+ "It will have new attributes detailing the success of the request.");
-core::Relationship InvokeHTTP::RelResponse("response", "Represents a response flowfile");
+core::Relationship InvokeHTTP::RelResponse("response", "A Response FlowFile will be routed upon success (2xx status codes). "
+ "If the 'Output Response Regardless' property is true then the response will be sent "
Review comment:
Good catch! Fixed in 1445eb3bcdf9367440314d513718e0afa23ee2ee
--
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:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1082: MINIFICPP-1494 Allow InvokeHTTP GET requests without incoming flowfile
Posted by GitBox <gi...@apache.org>.
adam-markovics commented on a change in pull request #1082:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1082#discussion_r644741953
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
Review comment:
This can even be accessed using [], since emptiness is checked before.
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
+ std::string url = scheme + "://localhost:" + getWebPort() + *path_;
+ proc->setProperty(minifi::processors::InvokeHTTP::URL.getName(), url);
+ }
+
+ void setProperty(const std::string& property, const std::string& value) {
+ const auto components = flowController_->getComponents("InvokeHTTP");
+ assert(!components.empty());
+
+ const auto stateController = components.at(0);
+ assert(stateController);
+ const auto processorController = std::dynamic_pointer_cast<minifi::state::ProcessorController>(stateController);
+ assert(processorController);
+ auto proc = processorController->getProcessor();
+ proc->setProperty(property, value);
+ }
+
+ virtual void setupFlow(const utils::optional<std::string>& flow_yml_path) {
+ testSetup();
+
+ std::shared_ptr<core::Repository> test_repo = std::make_shared<TestRepository>();
+ std::shared_ptr<core::Repository> test_flow_repo = std::make_shared<TestFlowRepository>();
+
+ if (flow_yml_path) {
+ configuration->set(minifi::Configure::nifi_flow_configuration_file, *flow_yml_path);
+ }
+ configuration->set("c2.agent.heartbeat.period", "200");
+ std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>();
+ content_repo->initialize(configuration);
+ std::shared_ptr<minifi::io::StreamFactory> stream_factory = minifi::io::StreamFactory::getInstance(configuration);
+ std::unique_ptr<core::FlowConfiguration> yaml_ptr = std::unique_ptr<core::YamlConfiguration>(
Review comment:
Could be make_unique.
##########
File path: extensions/http-curl/tests/VerifyInvokeHTTP.h
##########
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#undef NDEBUG
+#include "TestBase.h"
+#include "HTTPClient.h"
+#include "InvokeHTTP.h"
+#include "processors/LogAttribute.h"
+#include "core/state/ProcessorController.h"
+#include "HTTPIntegrationBase.h"
+
+class VerifyInvokeHTTP : public HTTPIntegrationBase {
+ public:
+ VerifyInvokeHTTP()
+ : HTTPIntegrationBase(6000) {
+ }
+
+ void testSetup() override {
+ LogTestController::getInstance().setDebug<utils::HTTPClient>();
+ LogTestController::getInstance().setDebug<LogTestController>();
+ LogTestController::getInstance().setTrace<minifi::processors::InvokeHTTP>();
+ LogTestController::getInstance().setTrace<minifi::processors::LogAttribute>();
+ LogTestController::getInstance().setDebug<core::Processor>();
+ LogTestController::getInstance().setDebug<core::ProcessSession>();
+ }
+
+ void setUrl(const std::string &url, ServerAwareHandler *handler) override {
+ if (path_) {
+ throw std::logic_error("Url is already set");
+ }
+ std::string port, scheme, path;
+ parse_http_components(url, port, scheme, path);
+ path_ = path;
+ HTTPIntegrationBase::setUrl(url, handler);
+ }
+
+ void setProperties(std::shared_ptr<core::Processor> proc) {
Review comment:
Is it necessary to increase the ref count of proc?
--
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:
users@infra.apache.org