This is an automated email from the ASF dual-hosted git repository.

martinzink pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 128cfde6b MINIFICPP-2954 Fix the flakiness of FetchOPCEventsTests 
(#2313)
128cfde6b is described below

commit 128cfde6b11c1b5445dbb042ef0e92228371a934
Author: Ferenc Gerlits <[email protected]>
AuthorDate: Mon Nov 30 14:10:56 2026 +0100

    MINIFICPP-2954 Fix the flakiness of FetchOPCEventsTests (#2313)
    
    Two fixes:
    - Upgrade open62541 to version 1.5.10 because we need 
https://github.com/open62541/open62541/pull/8491
      Without this, the state of internal UA_Timer instances on different 
threads
      can get mixed up, the event loop locks up and some messages are not 
received
      within the 10s timeout.
    - Make sure that a notification message cannot be split between two 
flowfiles
      If a two-part message got split up into two flowfiles, the test could 
crash
      with an assertion failure (also fixed: now the new REQUIRE fails instead 
of
      a crash).
---
 cmake/Open62541.cmake                            |  4 ++--
 conanfile.py                                     |  2 +-
 extensions/opc/include/OPCCommon.h               |  3 ++-
 extensions/opc/src/OPCCommon.cpp                 | 14 ++++++++++----
 extensions/opc/tests/FetchOPCEventsTests.cpp     |  2 ++
 thirdparty/open62541/all/conandata.yml           |  8 ++++----
 thirdparty/open62541/all/patches/open62541.patch | 24 +++++-------------------
 thirdparty/open62541/config.yml                  |  2 +-
 8 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/cmake/Open62541.cmake b/cmake/Open62541.cmake
index eb58cc0a9..60c3663df 100644
--- a/cmake/Open62541.cmake
+++ b/cmake/Open62541.cmake
@@ -4,7 +4,7 @@
 
 include(FetchContent)
 
-set(OPEN62541_VERSION "v1.5.4" CACHE STRING "" FORCE)
+set(OPEN62541_VERSION "v1.5.10" CACHE STRING "" FORCE)
 set(UA_ENABLE_ENCRYPTION ON CACHE BOOL "" FORCE)
 set(UA_ENABLE_ENCRYPTION_OPENSSL ON CACHE BOOL "" FORCE)
 set(UA_FORCE_WERROR OFF CACHE BOOL "" FORCE)
@@ -17,7 +17,7 @@ set(PC ${Bash_EXECUTABLE}  -c "set -x &&\
 FetchContent_Declare(
     open62541
     URL 
"https://github.com/open62541/open62541/archive/refs/tags/${OPEN62541_VERSION}.tar.gz";
-    URL_HASH 
"SHA256=fb5aafc19c67a91368d1f71d9ee4acf0f4b47a0d65c66db4ed738691828779c7"
+    URL_HASH 
"SHA256=b05e47734e2e39c0b00511ed6dc22e71f1b5bf7864b86280653a5128d171c0ed"
     PATCH_COMMAND "${PC}"
     EXCLUDE_FROM_ALL
     DOWNLOAD_NO_PROGRESS TRUE
diff --git a/conanfile.py b/conanfile.py
index 33bcf4078..0eb185789 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -186,7 +186,7 @@ class MiNiFiCppMain(ConanFile):
         if self.options.enable_all or self.options.enable_kafka:
             self.requires("librdkafka/2.14.2")
         if self.options.enable_all or self.options.enable_opc:
-            self.requires("open62541/1.5.4@minifi/develop")
+            self.requires("open62541/1.5.10@minifi/develop")
         if self.options.enable_all or self.options.enable_bustache:
             self.requires("bustache/0.1.0@minifi/develop")
         if self.options.enable_all or self.options.enable_grpc_for_loki:
diff --git a/extensions/opc/include/OPCCommon.h 
b/extensions/opc/include/OPCCommon.h
index cb4fc53b1..6d0b5281c 100644
--- a/extensions/opc/include/OPCCommon.h
+++ b/extensions/opc/include/OPCCommon.h
@@ -176,7 +176,7 @@ class Client {
     }
   }
 
-  void pushEvent(Event&& event);
+  void flushPendingEvents();
 
   struct EventSubscription {
     UA_UInt32 id = 0;
@@ -187,6 +187,7 @@ class Client {
   std::shared_ptr<core::logging::Logger> logger_;
 
   std::optional<EventSubscription> subscription_;
+  std::vector<Event> pending_events_;  // only accessed from 
FetchOPCEvents::event_thread_, so no locking is necessary
   std::mutex event_queue_mutex_;
   std::deque<Event> event_queue_;
   std::optional<size_t> max_event_queue_size_;
diff --git a/extensions/opc/src/OPCCommon.cpp b/extensions/opc/src/OPCCommon.cpp
index 07f96605b..c8937b982 100644
--- a/extensions/opc/src/OPCCommon.cpp
+++ b/extensions/opc/src/OPCCommon.cpp
@@ -789,7 +789,7 @@ void Client::eventNotificationCallback(UA_Client* 
/*client*/, UA_UInt32 /*sub_id
         client->logger_->log_warn("Failed to convert event field '{}' to 
string, skipping field: {}", name, ex.what());
       }
     }
-    client->pushEvent(std::move(event));
+    client->pending_events_.push_back(std::move(event));
   } catch (const std::exception& ex) {
     client->logger_->log_error("Failed to process an OPC UA event 
notification: {}", ex.what());
   } catch (...) {
@@ -835,9 +835,13 @@ void Client::subscriptionInactivityCallback(UA_Client* 
/*client*/, UA_UInt32 sub
   }
 }
 
-void Client::pushEvent(Event&& event) {
+void Client::flushPendingEvents() {
+  if (pending_events_.empty()) {
+    return;
+  }
   const std::lock_guard<std::mutex> lock(event_queue_mutex_);
-  event_queue_.push_back(std::move(event));
+  std::ranges::move(pending_events_, std::back_inserter(event_queue_));
+  pending_events_.clear();
   while (max_event_queue_size_ && event_queue_.size() > 
*max_event_queue_size_) {
     event_queue_.pop_front();
     ++dropped_event_count_;
@@ -845,7 +849,9 @@ void Client::pushEvent(Event&& event) {
 }
 
 UA_StatusCode Client::processSubscriptionNotifications(UA_UInt32 
timeout_milliseconds) {
-  return UA_Client_run_iterate(client_, timeout_milliseconds);
+  const auto status = UA_Client_run_iterate(client_, timeout_milliseconds);
+  flushPendingEvents();
+  return status;
 }
 
 std::vector<Event> Client::drainEvents() {
diff --git a/extensions/opc/tests/FetchOPCEventsTests.cpp 
b/extensions/opc/tests/FetchOPCEventsTests.cpp
index 4b9e85d0d..a4c506537 100644
--- a/extensions/opc/tests/FetchOPCEventsTests.cpp
+++ b/extensions/opc/tests/FetchOPCEventsTests.cpp
@@ -66,6 +66,8 @@ class FetchOPCEventsTestController {
       expected_document.Parse(expected_contents[i].c_str());
 
       auto array = expected_document.GetArray();
+      REQUIRE(result_document.IsArray());
+      REQUIRE(result_document.Size() == array.Size());
       for (rapidjson::SizeType j = 0; j < array.Size(); ++j) {
         for (const auto& field : array[j].GetObject()) {
           if (field.value == ".*") {
diff --git a/thirdparty/open62541/all/conandata.yml 
b/thirdparty/open62541/all/conandata.yml
index c67854aa9..ceb889c52 100644
--- a/thirdparty/open62541/all/conandata.yml
+++ b/thirdparty/open62541/all/conandata.yml
@@ -3,11 +3,11 @@
 # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under 
one or more contributor license agreements
 
 sources:
-  "1.5.4":
-    url: 
"https://github.com/open62541/open62541/archive/refs/tags/v1.5.4.tar.gz";
-    sha256: "fb5aafc19c67a91368d1f71d9ee4acf0f4b47a0d65c66db4ed738691828779c7"
+  "1.5.10":
+    url: 
"https://github.com/open62541/open62541/archive/refs/tags/v1.5.10.tar.gz";
+    sha256: "b05e47734e2e39c0b00511ed6dc22e71f1b5bf7864b86280653a5128d171c0ed"
 patches:
-  "1.5.4":
+  "1.5.10":
     - patch_file: "patches/open62541.patch"
       patch_description: "Fix compilation issues with Open62541"
       patch_type: "fix"
diff --git a/thirdparty/open62541/all/patches/open62541.patch 
b/thirdparty/open62541/all/patches/open62541.patch
index 7db9674ca..e8db5b9f4 100644
--- a/thirdparty/open62541/all/patches/open62541.patch
+++ b/thirdparty/open62541/all/patches/open62541.patch
@@ -1,5 +1,5 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 89e7d67ae..ebc16a748 100644
+index d635a02..073ab90 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -18,7 +18,7 @@ endif()
@@ -11,7 +11,7 @@ index 89e7d67ae..ebc16a748 100644
  
  find_package(Python3 REQUIRED)
  find_package(Git)
-@@ -588,24 +588,21 @@ endif()
+@@ -597,24 +597,21 @@ endif()
  # Compiler Settings #
  #####################
  
@@ -44,14 +44,14 @@ index 89e7d67ae..ebc16a748 100644
      endif()
  endfunction()
  
-@@ -717,17 +714,6 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID 
STREQUAL "Clang") AND
+@@ -731,17 +728,6 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID 
MATCHES "Clang") AND
          endif()
      endif()
  
 -    # Inter Procedural Optimization / Link Time Optimization (should be same 
as -flto)
 -    # IPO requires too much memory for unit tests
 -    # GCC docu recommends to compile all files with the same options, 
therefore ignore it completely
--    if(NOT UA_BUILD_UNIT_TESTS AND NOT DEFINED 
CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+-    if(NOT UA_DEBUG AND NOT UA_BUILD_UNIT_TESTS AND NOT DEFINED 
CMAKE_INTERPROCEDURAL_OPTIMIZATION)
 -        include(CheckIPOSupported)
 -        check_ipo_supported(RESULT CC_HAS_IPO)
 -        if(CC_HAS_IPO)
@@ -62,7 +62,7 @@ index 89e7d67ae..ebc16a748 100644
      # Linker
      set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by 
default
      if(APPLE)
-@@ -1438,6 +1424,11 @@ else()
+@@ -1528,6 +1514,11 @@ else()
  endif()
  add_library(open62541 $<TARGET_OBJECTS:open62541-object> 
$<TARGET_OBJECTS:open62541-plugins>)
  
@@ -74,17 +74,3 @@ index 89e7d67ae..ebc16a748 100644
  add_dependencies(open62541-object open62541-code-generation)
  add_dependencies(open62541-plugins open62541-code-generation)
  
-diff --git a/arch/posix/eventloop_posix.h b/arch/posix/eventloop_posix.h
-index ce64f374a..c4b69668c 100644
---- a/arch/posix/eventloop_posix.h
-+++ b/arch/posix/eventloop_posix.h
-@@ -277,7 +277,9 @@ typedef int SOCKET;
- 
- #ifndef __ANDROID__
- #ifndef __APPLE__
-+#ifdef __GLIBC__
- #include <bits/stdio_lim.h>
-+#endif
- #endif /* !__APPLE__ */
- #endif /* !__ANDROID__ */
- 
diff --git a/thirdparty/open62541/config.yml b/thirdparty/open62541/config.yml
index 882c6e816..163e2c961 100644
--- a/thirdparty/open62541/config.yml
+++ b/thirdparty/open62541/config.yml
@@ -3,5 +3,5 @@
 # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under 
one or more contributor license agreements
 
 versions:
-  "1.5.4":
+  "1.5.10":
     folder: all

Reply via email to