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 2020/08/31 14:55:04 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #874: Minificpp 1325 - Refactor and test YAML connection parsing

szaszm commented on a change in pull request #874:
URL: https://github.com/apache/nifi-minifi-cpp/pull/874#discussion_r480185712



##########
File path: extensions/standard-processors/tests/unit/YamlConnectionParserTest.cpp
##########
@@ -0,0 +1,200 @@
+/**
+ *
+ * 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 "core/yaml/YamlConnectionParser.h"
+
+#include "core/yaml/YamlConfiguration.h"
+#include "TailFile.h"
+#include "TestBase.h"
+#include "utils/TestUtils.h"
+
+namespace {
+
+using org::apache::nifi::minifi::core::yaml::YamlConnectionParser;
+using org::apache::nifi::minifi::core::YamlConfiguration;
+using RetryFlowFile = org::apache::nifi::minifi::processors::TailFile;
+
+TEST_CASE("Connections components are parsed from yaml.", "[YamlConfiguration]") {
+  const std::shared_ptr<logging::Logger> logger = logging::LoggerFactory<YamlConfiguration>::getLogger();
+  core::ProcessGroup parent(core::ProcessGroupType::ROOT_PROCESS_GROUP, "root");
+  gsl::not_null<core::ProcessGroup*> parent_ptr{ &parent };
+
+  SECTION("Source relationships are read") {
+    const auto connection = std::make_shared<minifi::Connection>(nullptr, nullptr, "name");
+    std::string serialized_yaml;
+    std::vector<std::string> expectations;
+    SECTION("Single relationship name") {
+      serialized_yaml = std::string { "source relationship name: success\n" };
+      expectations = { "success" };
+    }
+    SECTION("List of relationship names") {
+      serialized_yaml = std::string {
+          "source relationship names:\n"
+          "- success\n"
+          "- failure\n"
+          "- something_else\n" };
+      expectations = { "success", "failure", "something_else" };
+    }
+    YAML::Node connection_node = YAML::Load(serialized_yaml);
+    YamlConnectionParser yaml_connection_parser(connection_node, "test_node", parent_ptr, logger);
+    yaml_connection_parser.configureConnectionSourceRelationshipsFromYaml(connection);
+    const std::set<core::Relationship>& relationships = connection->getRelationships();
+    REQUIRE(expectations.size() == relationships.size());
+    for (const auto& expected_relationship_name : expectations) {
+      const auto relationship_name_matches = [&] (const core::Relationship& relationship) { return expected_relationship_name == relationship.getName(); };
+      const std::size_t relationship_count = std::count_if(relationships.cbegin(), relationships.cend(), relationship_name_matches);
+      REQUIRE(1 == relationship_count);
+    }
+  }
+  SECTION("Queue size limits are read") {
+    YAML::Node connection_node = YAML::Load(std::string {
+        "max work queue size: 231\n"
+        "max work queue data size: 12 MB\n" });
+    YamlConnectionParser yaml_connection_parser(connection_node, "test_node", parent_ptr, logger);
+    REQUIRE(231 == yaml_connection_parser.getWorkQueueSizeFromYaml());
+    REQUIRE(12582912 == yaml_connection_parser.getWorkQueueDataSizeFromYaml());  // 12 * 1024 * 1024 B

Review comment:
       Please remember the Apache motto "Community Over Code". (from https://www.apache.org/theapacheway/)
   Good code is high priority but keeping a healthy community is higher. We should be open to constructive criticism, but also accept when we cannot reach a consensus and not sacrifice the community morale on the altar of tiny technical disagreements.
   
   My decision making preference is: consensus > healthy debate > majority vote.




----------------------------------------------------------------
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