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

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

commit a55d5365789543d45e05d90d35b4b4c18748fb97
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Tue Nov 18 17:06:30 2025 +0100

    MINIFICPP-2682 Move Lua tests to modular docker tests
    
    Closes #2075
    
    Signed-off-by: Ferenc Gerlits <[email protected]>
---
 .../src/minifi_test_framework/minifi/processor.py  |  6 +++++
 .../minifi_test_framework/steps/checking_steps.py  |  7 ++++++
 .../steps/flow_building_steps.py                   |  6 +++++
 docker/RunBehaveTests.sh                           |  3 ++-
 .../cluster/DockerTestDirectoryBindings.py         |  1 -
 extensions/lua/tests/features/environment.py       | 28 ++++++++++++++++++++++
 .../lua/tests}/features/lua_script.feature         |  7 +++---
 .../tests/features/resources}/sleep_forever.lua    |  0
 extensions/lua/tests/features/steps/steps.py       | 19 +++++++++++++++
 9 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/behave_framework/src/minifi_test_framework/minifi/processor.py 
b/behave_framework/src/minifi_test_framework/minifi/processor.py
index d91bedf28..193b8deaf 100644
--- a/behave_framework/src/minifi_test_framework/minifi/processor.py
+++ b/behave_framework/src/minifi_test_framework/minifi/processor.py
@@ -29,10 +29,14 @@ class Processor:
         self.penalization_period: str = penalization_period
         self.properties: dict[str, str] = {}
         self.auto_terminated_relationships: list[str] = []
+        self.max_concurrent_tasks: int | None = None
 
     def add_property(self, property_name: str, property_value: str):
         self.properties[property_name] = property_value
 
+    def set_max_concurrent_tasks(self, max_concurrent_tasks: int):
+        self.max_concurrent_tasks = max_concurrent_tasks
+
     def remove_property(self, property_name: str):
         if property_name in self.properties:
             del self.properties[property_name]
@@ -51,6 +55,8 @@ class Processor:
         }
         if self.auto_terminated_relationships:
             data['auto-terminated relationships list'] = 
self.auto_terminated_relationships
+        if self.max_concurrent_tasks is not None:
+            data['max concurrent tasks'] = self.max_concurrent_tasks
 
         # The YAML format capitalizes 'Properties'
         data['Properties'] = self.properties
diff --git a/behave_framework/src/minifi_test_framework/steps/checking_steps.py 
b/behave_framework/src/minifi_test_framework/steps/checking_steps.py
index 4ae80cfa6..c964aea46 100644
--- a/behave_framework/src/minifi_test_framework/steps/checking_steps.py
+++ b/behave_framework/src/minifi_test_framework/steps/checking_steps.py
@@ -84,6 +84,13 @@ def step_impl(context: MinifiTestContext, message: str, 
duration: str):
                               context=context)
 
 
+@then("the Minifi logs contain the following message: \"{log_message}\" 
{count:d} times after {duration}")
+def step_impl(context, log_message, count, duration):
+    duration_seconds = humanfriendly.parse_timespan(duration)
+    time.sleep(duration_seconds)
+    assert 
context.get_default_minifi_container().get_logs().count(log_message) == count 
or context.get_default_minifi_container().log_app_output()
+
+
 @then("the Minifi logs match the following regex: \"{regex}\" in less than 
{duration}")
 def step_impl(context, regex, duration):
     duration_seconds = humanfriendly.parse_timespan(duration)
diff --git 
a/behave_framework/src/minifi_test_framework/steps/flow_building_steps.py 
b/behave_framework/src/minifi_test_framework/steps/flow_building_steps.py
index e2ac9df50..d780673a4 100644
--- a/behave_framework/src/minifi_test_framework/steps/flow_building_steps.py
+++ b/behave_framework/src/minifi_test_framework/steps/flow_building_steps.py
@@ -256,6 +256,12 @@ def step_impl(context: MinifiTestContext, property_name: 
str, processor_name: st
     processor.add_property(property_name, filtering)
 
 
+@given("the max concurrent tasks attribute of the {processor_name} processor 
is set to {max_concurrent_tasks:d}")
+def step_impl(context, processor_name: str, max_concurrent_tasks: int):
+    processor = 
context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name)
+    processor.set_max_concurrent_tasks(max_concurrent_tasks)
+
+
 @given("the \"{property_name}\" properties of the {processor_name_one} and 
{processor_name_two} processors are set to the same random UUID")
 def step_impl(context, property_name, processor_name_one, processor_name_two):
     uuid_str = str(uuid.uuid4())
diff --git a/docker/RunBehaveTests.sh b/docker/RunBehaveTests.sh
index 65b5d43d5..32a7d7a68 100755
--- a/docker/RunBehaveTests.sh
+++ b/docker/RunBehaveTests.sh
@@ -205,4 +205,5 @@ exec \
     "${docker_dir}/../extensions/elasticsearch/tests/features" \
     "${docker_dir}/../extensions/splunk/tests/features" \
     "${docker_dir}/../extensions/gcp/tests/features" \
-    "${docker_dir}/../extensions/grafana-loki/tests/features"
+    "${docker_dir}/../extensions/grafana-loki/tests/features" \
+    "${docker_dir}/../extensions/lua/tests/features/"
diff --git a/docker/test/integration/cluster/DockerTestDirectoryBindings.py 
b/docker/test/integration/cluster/DockerTestDirectoryBindings.py
index 9834bc524..ac6dc8e63 100644
--- a/docker/test/integration/cluster/DockerTestDirectoryBindings.py
+++ b/docker/test/integration/cluster/DockerTestDirectoryBindings.py
@@ -55,7 +55,6 @@ class DockerTestDirectoryBindings:
         # Add resources
         test_dir = os.environ['TEST_DIRECTORY']  # Based on DockerVerify.sh
         shutil.copytree(test_dir + "/resources/python", 
self.data_directories[self.feature_id]["resources_dir"] + "/python")
-        shutil.copytree(test_dir + "/resources/lua", 
self.data_directories[self.feature_id]["resources_dir"] + "/lua")
         shutil.copytree(test_dir + "/resources/minifi", 
self.data_directories[self.feature_id]["minifi_config_dir"], dirs_exist_ok=True)
         shutil.copytree(test_dir + "/resources/minifi-controller", 
self.data_directories[self.feature_id]["resources_dir"] + "/minifi-controller")
 
diff --git a/extensions/lua/tests/features/environment.py 
b/extensions/lua/tests/features/environment.py
new file mode 100644
index 000000000..a02cce4c3
--- /dev/null
+++ b/extensions/lua/tests/features/environment.py
@@ -0,0 +1,28 @@
+# 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.
+
+import os
+
+from minifi_test_framework.core.hooks import common_before_scenario
+from minifi_test_framework.core.hooks import common_after_scenario
+
+
+def before_scenario(context, scenario):
+    common_before_scenario(context, scenario)
+    context.resource_dir = os.path.join(os.path.dirname(__file__), 'resources')
+
+
+def after_scenario(context, scenario):
+    common_after_scenario(context, scenario)
diff --git a/docker/test/integration/features/lua_script.feature 
b/extensions/lua/tests/features/lua_script.feature
similarity index 85%
rename from docker/test/integration/features/lua_script.feature
rename to extensions/lua/tests/features/lua_script.feature
index 377ab080a..c4c57ba0a 100644
--- a/docker/test/integration/features/lua_script.feature
+++ b/extensions/lua/tests/features/lua_script.feature
@@ -15,16 +15,17 @@
 
 @ENABLE_LUA_SCRIPTING
 Feature: MiNiFi can execute Lua scripts
-  Background:
-    Given the content of "/tmp/output" is monitored
 
   Scenario: ExecuteScript should only allow the number of parallel tasks 
defined by the max concurrent tasks attribute for Lua scripts
     Given a GenerateFlowFile processor with the "File Size" property set to 
"0B"
     And the scheduling period of the GenerateFlowFile processor is set to "500 
ms"
+    And a host resource file "sleep_forever.lua" is bound to the 
"/tmp/resources/lua/sleep_forever.lua" path in the MiNiFi container
     And a ExecuteScript processor with the "Script File" property set to 
"/tmp/resources/lua/sleep_forever.lua"
+    And ExecuteScript is EVENT_DRIVEN
     And the "Script Engine" property of the ExecuteScript processor is set to 
"lua"
     And the max concurrent tasks attribute of the ExecuteScript processor is 
set to 3
     And the "success" relationship of the GenerateFlowFile processor is 
connected to the ExecuteScript
+    And ExecuteScript's success relationship is auto-terminated
 
-    When all instances start up
+    When the MiNiFi instance starts up
     Then the Minifi logs contain the following message: "Sleeping forever" 3 
times after 5 seconds
diff --git a/docker/test/integration/resources/lua/sleep_forever.lua 
b/extensions/lua/tests/features/resources/sleep_forever.lua
similarity index 100%
rename from docker/test/integration/resources/lua/sleep_forever.lua
rename to extensions/lua/tests/features/resources/sleep_forever.lua
diff --git a/extensions/lua/tests/features/steps/steps.py 
b/extensions/lua/tests/features/steps/steps.py
new file mode 100644
index 000000000..90304a7f8
--- /dev/null
+++ b/extensions/lua/tests/features/steps/steps.py
@@ -0,0 +1,19 @@
+# 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.
+
+from minifi_test_framework.steps import checking_steps  # noqa: F401
+from minifi_test_framework.steps import configuration_steps  # noqa: F401
+from minifi_test_framework.steps import core_steps  # noqa: F401
+from minifi_test_framework.steps import flow_building_steps  # noqa: F401

Reply via email to