This is an automated email from the ASF dual-hosted git repository.
aldrin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 96c4434 MINIFICPP-723: Resolve bug in set property, add a regression
test, and warning to avoid this this in the future
96c4434 is described below
commit 96c4434aecbb745005f616025b5638ea17654d5e
Author: Marc Parisi <[email protected]>
AuthorDate: Sun Jan 27 07:32:40 2019 -0500
MINIFICPP-723: Resolve bug in set property, add a regression test, and
warning to avoid this this in the future
This closes #477.
Signed-off-by: Aldrin Piri <[email protected]>
---
libminifi/src/core/ConfigurableComponent.cpp | 12 +-
.../test/expression-language-tests/CMakeLists.txt | 23 ++++
.../integration/UpdateAttributeIntegrationTest.cpp | 66 +++++++++++
libminifi/test/resources/TestUpdateAttribute.yml | 125 +++++++++++++++++++++
4 files changed, 217 insertions(+), 9 deletions(-)
diff --git a/libminifi/src/core/ConfigurableComponent.cpp
b/libminifi/src/core/ConfigurableComponent.cpp
index ed54b4f..ab1864d 100644
--- a/libminifi/src/core/ConfigurableComponent.cpp
+++ b/libminifi/src/core/ConfigurableComponent.cpp
@@ -144,15 +144,9 @@ bool ConfigurableComponent::setProperty(Property &prop,
PropertyValue &value) {
logger_->log_debug("property name %s value %s and new value is %s",
prop.getName(), new_property.getName(), value,
new_property.getValue().to_string());
return true;
} else {
- if (supportsDynamicProperties()) {
- Property new_property(prop);
- new_property.setValue(value);
- properties_.insert(std::pair<std::string, Property>(prop.getName(),
new_property));
- onPropertyModified({}, new_property);
- return true;
- } else {
- return false;
- }
+ // Should not attempt to update dynamic properties here since the return
code
+ // is relied upon by other classes to determine if the property exists.
+ return false;
}
}
diff --git a/libminifi/test/expression-language-tests/CMakeLists.txt
b/libminifi/test/expression-language-tests/CMakeLists.txt
index d11b310..890931d 100644
--- a/libminifi/test/expression-language-tests/CMakeLists.txt
+++ b/libminifi/test/expression-language-tests/CMakeLists.txt
@@ -37,4 +37,27 @@ FOREACH(testfile ${EXPRESSION_LANGUAGE_TESTS})
add_test(NAME "${testfilename}" COMMAND "${testfilename}"
WORKING_DIRECTORY ${TEST_DIR})
ENDFOREACH()
+
+### integration tests
+
+file(GLOB INT_EXPRESSION_LANGUAGE_TESTS "integration/*.cpp")
+
+SET(INT_EXTENSIONS_TEST_COUNT 0)
+
+FOREACH(testfile ${INT_EXPRESSION_LANGUAGE_TESTS})
+ get_filename_component(testfilename "${testfile}" NAME_WE)
+ add_executable("${testfilename}" "${testfile}")
+ target_include_directories(${testfilename} BEFORE PRIVATE
"${CMAKE_SOURCE_DIR}/extensions/expression-language")
+ createTests("${testfilename}")
+ if (APPLE)
+ target_link_libraries ("${testfilename}" -Wl,-all_load
minifi-expression-language-extensions )
+ else ()
+ target_link_libraries ("${testfilename}" -Wl,--whole-archive
minifi-expression-language-extensions -Wl,--no-whole-archive)
+ endif()
+ MATH(EXPR EXTENSIONS_TEST_COUNT "${INT_EXTENSIONS_TEST_COUNT}+1")
+ENDFOREACH()
+
+
+add_test(NAME UpdateAttributeIntegrationTest COMMAND
UpdateAttributeIntegrationTest "${TEST_RESOURCES}/TestUpdateAttribute.yml"
"${TEST_RESOURCES}/")
+
message("-- Finished building ${EXTENSIONS_TEST_COUNT} expression language
related test file(s)...")
diff --git
a/libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp
b/libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp
new file mode 100644
index 0000000..5ceecab
--- /dev/null
+++
b/libminifi/test/expression-language-tests/integration/UpdateAttributeIntegrationTest.cpp
@@ -0,0 +1,66 @@
+/**
+ *
+ * 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 <sys/stat.h>
+#undef NDEBUG
+#include <cassert>
+#include <utility>
+#include <chrono>
+#include <fstream>
+#include <memory>
+#include <string>
+#include <thread>
+#include <type_traits>
+#include <vector>
+#include <iostream>
+#include <sstream>
+#include "processors/LogAttribute.h"
+#include "../../integration/IntegrationBase.h"
+#include "../../TestBase.h"
+
+class TestHarness : public IntegrationBase {
+ public:
+ TestHarness() {
+ }
+
+ void testSetup() {
+ LogTestController::getInstance().setInfo<minifi::FlowController>();
+ LogTestController::getInstance().setInfo<processors::LogAttribute>();
+ }
+
+ void cleanup() {
+ }
+
+ void runAssertions() {
+ assert(LogTestController::getInstance().contains("key:route_check_attr
value:good"));
+ }
+
+ protected:
+};
+
+int main(int argc, char **argv) {
+ std::string key_dir, test_file_location, url;
+ if (argc > 1) {
+ test_file_location = argv[1];
+ }
+
+ TestHarness harness;
+ harness.run(test_file_location);
+
+ return 0;
+}
diff --git a/libminifi/test/resources/TestUpdateAttribute.yml
b/libminifi/test/resources/TestUpdateAttribute.yml
new file mode 100644
index 0000000..c37f8fe
--- /dev/null
+++ b/libminifi/test/resources/TestUpdateAttribute.yml
@@ -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.
+#
+Flow Controller:
+ name: MiNiFi Flow
+ id: 2438e3c8-015a-1000-79ca-83af40ec1990
+Processors:
+ - name: gn
+ id: 2438e3c8-015a-1000-79ca-83af40ec1991
+ class: org.apache.nifi.processors.standard.GenerateFlowFile
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ penalization period: 30 sec
+ yield period: 1 sec
+ run duration nanos: 0
+ auto-terminated relationships list:
+ Properties:
+ - name: up
+ id: 2438e3c8-015a-1000-79ca-83af40ec1992
+ class: org.apache.nifi.processors.standard.UpdateAttribute
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ penalization period: 30 sec
+ yield period: 1 sec
+ run duration nanos: 0
+ auto-terminated relationships list: failure
+ Properties:
+ route_condition_attr: true
+ - name: roa
+ id: 2438e3c8-015a-1000-79ca-83af40ec1993
+ class: org.apache.nifi.processors.standard.RouteOnAttribute
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ penalization period: 30 sec
+ yield period: 1 sec
+ run duration nanos: 0
+ auto-terminated relationships list: failure
+ Properties:
+ route_matched: ${route_condition_attr}
+ - name: up2
+ id: 2438e3c8-015a-1000-79ca-83af40ec1994
+ class: org.apache.nifi.processors.standard.UpdateAttribute
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ penalization period: 30 sec
+ yield period: 1 sec
+ run duration nanos: 0
+ auto-terminated relationships list: failure
+ Properties:
+ route_check_attr: good
+ - name: la
+ id: 2438e3c8-015a-1000-79ca-83af40ec1995
+ class: org.apache.nifi.processors.standard.LogAttribute
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ penalization period: 30 sec
+ yield period: 1 sec
+ run duration nanos: 0
+ auto-terminated relationships list: success
+ Properties:
+
+Connections:
+ - name: tr1
+ id: 2438e3c8-015a-1000-79ca-83af40ec1997
+ source name: gn
+ source id: 2438e3c8-015a-1000-79ca-83af40ec1991
+ source relationship name: success
+ destination name: up
+ destination id: 2438e3c8-015a-1000-79ca-83af40ec1992
+ max work queue size: 0
+ max work queue data size: 1 MB
+ flowfile expiration: 60 sec
+ - name: tr2
+ id: 2438e3c8-015a-1000-79ca-83af40ec1917
+ source name: up
+ source id: 2438e3c8-015a-1000-79ca-83af40ec1992
+ destination name: roa
+ destination id: 2438e3c8-015a-1000-79ca-83af40ec1993
+ source relationship name: success
+ max work queue size: 0
+ max work queue data size: 1 MB
+ flowfile expiration: 60 sec
+ - name: tr3
+ id: 2438e3c8-015a-1000-79ca-83af40ec1918
+ source name: roa
+ source id: 2438e3c8-015a-1000-79ca-83af40ec1993
+ destination name: up2
+ destination id: 2438e3c8-015a-1000-79ca-83af40ec1994
+ source relationship name: route_matched
+ max work queue size: 0
+ max work queue data size: 1 MB
+ flowfile expiration: 60 sec
+ - name: tr4
+ id: 2438e3c8-015a-1000-79ca-83af40ec1919
+ source name: up2
+ source id: 2438e3c8-015a-1000-79ca-83af40ec1994
+ destination name: la
+ destination id: 2438e3c8-015a-1000-79ca-83af40ec1995
+ source relationship name: success
+ max work queue size: 0
+ max work queue data size: 1 MB
+ flowfile expiration: 60 sec
+
+Remote Processing Groups:
+