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 2022/04/14 11:10:53 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request, #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

lordgamez opened a new pull request, #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304

   https://issues.apache.org/jira/browse/MINIFICPP-1322
   
   ----------------------------------------------------------------
   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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

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


[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r852770632


##########
libminifi/test/kafka-tests/PublishKafkaTests.cpp:
##########
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.
+ */
+#include <memory>
+
+#include "../TestBase.h"
+#include "../Catch.h"
+#include "PublishKafka.h"
+#include "SingleInputTestController.h"
+
+namespace {
+
+class PublishKafkaTestFixture {
+ public:
+  PublishKafkaTestFixture();
+
+ protected:
+  std::shared_ptr<minifi::processors::PublishKafka> publish_kafka_processor_;
+  std::shared_ptr<minifi::test::SingleInputTestController> test_controller_;
+};
+
+PublishKafkaTestFixture::PublishKafkaTestFixture()
+  : publish_kafka_processor_(std::make_shared<minifi::processors::PublishKafka>("PublishKafka")),
+    test_controller_(std::make_shared<minifi::test::SingleInputTestController>(publish_kafka_processor_)) {
+  LogTestController::getInstance().setTrace<TestPlan>();
+  LogTestController::getInstance().setTrace<minifi::processors::PublishKafka>();
+}
+
+TEST_CASE_METHOD(PublishKafkaTestFixture, "Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::ClientName, "test_client");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::SeedBrokers, "test_seedbroker");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::QueueBufferMaxMessage, "1000");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::BatchSize, "1500");
+  REQUIRE_THROWS_WITH(test_controller_->trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
+}

Review Comment:
   Good idea, updated in b5c543ddec4c6c9eae0035fc7cf4bd1280725755



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

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


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r850592339


##########
libminifi/test/kafka-tests/PublishKafkaTests.cpp:
##########
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.
+ */
+#include <memory>
+
+#include "../TestBase.h"
+#include "../Catch.h"
+#include "PublishKafka.h"
+#include "SingleInputTestController.h"
+
+namespace {
+
+class PublishKafkaTestFixture {
+ public:
+  PublishKafkaTestFixture();
+
+ protected:
+  std::shared_ptr<minifi::processors::PublishKafka> publish_kafka_processor_;
+  std::shared_ptr<minifi::test::SingleInputTestController> test_controller_;
+};
+
+PublishKafkaTestFixture::PublishKafkaTestFixture()
+  : publish_kafka_processor_(std::make_shared<minifi::processors::PublishKafka>("PublishKafka")),
+    test_controller_(std::make_shared<minifi::test::SingleInputTestController>(publish_kafka_processor_)) {
+  LogTestController::getInstance().setTrace<TestPlan>();
+  LogTestController::getInstance().setTrace<minifi::processors::PublishKafka>();
+}
+
+TEST_CASE_METHOD(PublishKafkaTestFixture, "Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::ClientName, "test_client");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::SeedBrokers, "test_seedbroker");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::QueueBufferMaxMessage, "1000");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::BatchSize, "1500");
+  REQUIRE_THROWS_WITH(test_controller_->trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
+}

Review Comment:
   I would find it simpler to drop the fixture and make the members locals. If more tests are added in the future, they can go in `SECTION`s.
   
   ```suggestion
   namespace org::apache::nifi::minifi::test {
   TEST_CASE("Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
     LogTestController::getInstance().setTrace<TestPlan>();
     LogTestController::getInstance().setTrace<processors::PublishKafka>();
     const auto publish_kafka = std::make_shared<processors::PublishKafka>("PublishKafka");
     publish_kafka->setProperty(processors::PublishKafka::ClientName, "test_client");
     publish_kafka->setProperty(processors::PublishKafka::SeedBrokers, "test_seedbroker");
     publish_kafka->setProperty(processors::PublishKafka::QueueBufferMaxMessage, "1000");
     publish_kafka->setProperty(processors::PublishKafka::BatchSize, "1500");
     SingleInputTestController test_controller(publish_kafka);
     REQUIRE_THROWS_WITH(test_controller.trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
   } 
   //  namespace org::apache::nifi::minifi::processors
   ```



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

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


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r850592339


##########
libminifi/test/kafka-tests/PublishKafkaTests.cpp:
##########
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.
+ */
+#include <memory>
+
+#include "../TestBase.h"
+#include "../Catch.h"
+#include "PublishKafka.h"
+#include "SingleInputTestController.h"
+
+namespace {
+
+class PublishKafkaTestFixture {
+ public:
+  PublishKafkaTestFixture();
+
+ protected:
+  std::shared_ptr<minifi::processors::PublishKafka> publish_kafka_processor_;
+  std::shared_ptr<minifi::test::SingleInputTestController> test_controller_;
+};
+
+PublishKafkaTestFixture::PublishKafkaTestFixture()
+  : publish_kafka_processor_(std::make_shared<minifi::processors::PublishKafka>("PublishKafka")),
+    test_controller_(std::make_shared<minifi::test::SingleInputTestController>(publish_kafka_processor_)) {
+  LogTestController::getInstance().setTrace<TestPlan>();
+  LogTestController::getInstance().setTrace<minifi::processors::PublishKafka>();
+}
+
+TEST_CASE_METHOD(PublishKafkaTestFixture, "Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::ClientName, "test_client");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::SeedBrokers, "test_seedbroker");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::QueueBufferMaxMessage, "1000");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::BatchSize, "1500");
+  REQUIRE_THROWS_WITH(test_controller_->trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
+}

Review Comment:
   I would find it simpler to drop the fixture and make the members locals. If more tests are added in the future, they can go in `SECTION`s.



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

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


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r854112625


##########
extensions/librdkafka/PublishKafka.cpp:
##########
@@ -602,7 +602,13 @@ bool PublishKafka::configureNewConnection(const std::shared_ptr<core::ProcessCon
     }
   }
   value = "";
-  if (context->getProperty(QueueBufferMaxMessage.getName(), value) && !value.empty()) {
+  uint32_t int_val;
+  if (context->getProperty(QueueBufferMaxMessage.getName(), int_val)) {
+    if (int_val < batch_size_) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Invalid configuration: Batch Size cannot be larger than Queue Max Message");

Review Comment:
   were we able to trigger the expected problematic behavior?



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

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


[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304


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

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


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r850592339


##########
libminifi/test/kafka-tests/PublishKafkaTests.cpp:
##########
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.
+ */
+#include <memory>
+
+#include "../TestBase.h"
+#include "../Catch.h"
+#include "PublishKafka.h"
+#include "SingleInputTestController.h"
+
+namespace {
+
+class PublishKafkaTestFixture {
+ public:
+  PublishKafkaTestFixture();
+
+ protected:
+  std::shared_ptr<minifi::processors::PublishKafka> publish_kafka_processor_;
+  std::shared_ptr<minifi::test::SingleInputTestController> test_controller_;
+};
+
+PublishKafkaTestFixture::PublishKafkaTestFixture()
+  : publish_kafka_processor_(std::make_shared<minifi::processors::PublishKafka>("PublishKafka")),
+    test_controller_(std::make_shared<minifi::test::SingleInputTestController>(publish_kafka_processor_)) {
+  LogTestController::getInstance().setTrace<TestPlan>();
+  LogTestController::getInstance().setTrace<minifi::processors::PublishKafka>();
+}
+
+TEST_CASE_METHOD(PublishKafkaTestFixture, "Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::ClientName, "test_client");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::SeedBrokers, "test_seedbroker");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::QueueBufferMaxMessage, "1000");
+  publish_kafka_processor_->setProperty(org::apache::nifi::minifi::processors::PublishKafka::BatchSize, "1500");
+  REQUIRE_THROWS_WITH(test_controller_->trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
+}

Review Comment:
   I would find it simpler to drop the fixture and make the members locals. If more tests are added in the future, they can go in `SECTION`s.
   
   ```suggestion
   namespace org::apache::nifi::minifi::test {
   TEST_CASE("Scheduling should fail when batch size is larger than the max queue message count", "[testPublishKafka]") {
     LogTestController::getInstance().setTrace<TestPlan>();
     LogTestController::getInstance().setTrace<processors::PublishKafka>();
     const auto publish_kafka = std::make_shared<processors::PublishKafka>("PublishKafka");
     publish_kafka->setProperty(processors::PublishKafka::ClientName, "test_client");
     publish_kafka->setProperty(processors::PublishKafka::SeedBrokers, "test_seedbroker");
     publish_kafka->setProperty(processors::PublishKafka::QueueBufferMaxMessage, "1000");
     publish_kafka->setProperty(processors::PublishKafka::BatchSize, "1500");
     SingleInputTestController test_controller(publish_kafka_processor_);
     REQUIRE_THROWS_WITH(test_controller.trigger(""), "Process Schedule Operation: Invalid configuration: Batch Size cannot be larger than Queue Max Message");
   } 
   //  namespace org::apache::nifi::minifi::processors
   ```



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

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


[GitHub] [nifi-minifi-cpp] lordgamez commented on pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
lordgamez commented on PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#issuecomment-1102319190

   > I know this is not new, but since we are touching it anyways, would you mind moving the tests from libminifi/test/kafka-tests to extensions/librdkafka/tests/ ?
   
   Good point, moved it in b5c543ddec4c6c9eae0035fc7cf4bd1280725755


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

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


[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1304: MINIFICPP-1322 PublishKafka queue size and batch size properties should be in sync

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1304:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1304#discussion_r854149448


##########
extensions/librdkafka/PublishKafka.cpp:
##########
@@ -602,7 +602,13 @@ bool PublishKafka::configureNewConnection(const std::shared_ptr<core::ProcessCon
     }
   }
   value = "";
-  if (context->getProperty(QueueBufferMaxMessage.getName(), value) && !value.empty()) {
+  uint32_t int_val;
+  if (context->getProperty(QueueBufferMaxMessage.getName(), int_val)) {
+    if (int_val < batch_size_) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Invalid configuration: Batch Size cannot be larger than Queue Max Message");

Review Comment:
   Yes the misconfiguration issue actually came from a user, that's why this ticket was raised to make it more clear if this case happens.



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

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