From b5a4fdb82234f6cc408ed40ebbd95d8c14ef18e7 Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Tue, 18 Nov 2025 17:06:30 +0100 Subject: [PATCH 1/2] MINIFICPP-2682 Move Lua tests to modular docker tests --- .../minifi_test_framework/minifi/processor.py | 6 ++++ .../steps/checking_steps.py | 7 +++++ .../steps/flow_building_steps.py | 6 ++++ .../cluster/DockerTestDirectoryBindings.py | 1 - extensions/lua/tests/features/environment.py | 28 +++++++++++++++++++ .../lua/tests}/features/lua_script.feature | 7 +++-- .../features/resources}/sleep_forever.lua | 0 extensions/lua/tests/features/steps/steps.py | 19 +++++++++++++ 8 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 extensions/lua/tests/features/environment.py rename {docker/test/integration => extensions/lua/tests}/features/lua_script.feature (85%) rename {docker/test/integration/resources/lua => extensions/lua/tests/features/resources}/sleep_forever.lua (100%) create mode 100644 extensions/lua/tests/features/steps/steps.py diff --git a/behave_framework/src/minifi_test_framework/minifi/processor.py b/behave_framework/src/minifi_test_framework/minifi/processor.py index d91bedf289..193b8deaf4 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 @@ def __init__(self, class_name: str, proc_name: str, scheduling_strategy: str = " 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 @@ def to_yaml_dict(self) -> dict: } 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 4ae80cfa63..c964aea465 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 e2ac9df508..d780673a45 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/test/integration/cluster/DockerTestDirectoryBindings.py b/docker/test/integration/cluster/DockerTestDirectoryBindings.py index 9834bc5249..ac6dc8e632 100644 --- a/docker/test/integration/cluster/DockerTestDirectoryBindings.py +++ b/docker/test/integration/cluster/DockerTestDirectoryBindings.py @@ -55,7 +55,6 @@ def create_new_data_directories(self): # 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 0000000000..a02cce4c33 --- /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 377ab080a6..c4c57ba0aa 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 0000000000..90304a7f8a --- /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 From eaa861df71fb4501f7399a027ab5840621a61f56 Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Wed, 7 Jan 2026 15:45:12 +0100 Subject: [PATCH 2/2] Review update --- docker/RunBehaveTests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/RunBehaveTests.sh b/docker/RunBehaveTests.sh index 65b5d43d5e..32a7d7a68e 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/"