Skip to content

Commit 03fc08d

Browse files
committed
MINIFICPP-2687 Move Python extension docker tests to modular docker tests
1 parent ff1088c commit 03fc08d

26 files changed

+446
-416
lines changed

behave_framework/src/minifi_test_framework/containers/minifi_container.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ def _fill_default_properties(self):
147147
if self.is_fhs:
148148
self.properties["nifi.flow.configuration.file"] = "/etc/nifi-minifi-cpp/config.yml"
149149
self.properties["nifi.extension.path"] = "/usr/lib64/nifi-minifi-cpp/extensions/*"
150+
self.properties["nifi.python.processor.dir"] = '/var/lib/nifi-minifi-cpp/minifi-python'
150151
else:
151152
self.properties["nifi.flow.configuration.file"] = "./conf/config.yml"
152153
self.properties["nifi.extension.path"] = "../extensions/*"
154+
self.properties["nifi.python.processor.dir"] = '/opt/minifi/minifi-current/minifi-python'
153155
self.properties["nifi.administrative.yield.duration"] = "1 sec"
154156
self.properties["nifi.bored.yield.duration"] = "100 millis"
155157
self.properties["nifi.openssl.fips.support.enable"] = "false"
@@ -248,3 +250,13 @@ def create_debug_bundle(self) -> bool:
248250

249251
(code, _) = self.exec_run(["test", "-f", "/tmp/debug.tar.gz"])
250252
return code == 0
253+
254+
def add_example_python_processors(self):
255+
run_minifi_cmd = '/opt/minifi/minifi-current/bin/minifi.sh run' if not self.is_fhs else '/usr/bin/minifi'
256+
minifi_python_dir_path = '/opt/minifi/minifi-current/minifi-python' if not self.is_fhs else '/var/lib/nifi-minifi-cpp/minifi-python'
257+
minifi_python_examples = '/opt/minifi/minifi-current/minifi-python-examples' if not self.is_fhs else '/usr/share/doc/nifi-minifi-cpp/pythonprocessor-examples'
258+
self.command = f'sh -c "cp -r {minifi_python_examples} {minifi_python_dir_path}/examples && {run_minifi_cmd}"'
259+
260+
def set_default_python_virtualenv_directory(self):
261+
minifi_python_dir_path = '/opt/minifi/minifi-current/minifi-python' if not self.is_fhs else '/var/lib/nifi-minifi-cpp/minifi-python'
262+
self.properties["nifi.python.processor.dir"] = minifi_python_dir_path

behave_framework/src/minifi_test_framework/steps/checking_steps.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def step_impl(context: MinifiTestContext, container_name: str, content: str, dir
4444

4545

4646
@then('a single file with the content "{content}" is placed in the "{directory}" directory in less than {duration}')
47+
@then("a single file with the content '{content}' is placed in the '{directory}' directory in less than {duration}")
4748
def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str):
4849
context.execute_steps(f'then in the "{DEFAULT_MINIFI_CONTAINER_NAME}" container a single file with the content "{content}" is placed in the "{directory}" directory in less than {duration}')
4950

@@ -171,6 +172,16 @@ def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents
171172
context=context)
172173

173174

175+
@then('files with at least these contents "{contents}" are placed in the "{directory}" directory in less than {timeout}')
176+
def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents: str):
177+
timeout_seconds = humanfriendly.parse_timespan(timeout)
178+
new_contents = contents.replace("\\n", "\n")
179+
contents_arr = new_contents.split(",")
180+
assert wait_for_condition(condition=lambda: all([context.containers[DEFAULT_MINIFI_CONTAINER_NAME].directory_contains_file_with_content(directory, content) for content in contents_arr]),
181+
timeout_seconds=timeout_seconds, bail_condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].exited,
182+
context=context)
183+
184+
174185
@then("a file with the JSON content \"{content}\" is placed in the \"{directory}\" directory in less than {duration}")
175186
@then("a file with the JSON content '{content}' is placed in the '{directory}' directory in less than {duration}")
176187
def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str):

behave_framework/src/minifi_test_framework/steps/flow_building_steps.py

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,10 @@ def step_impl(context: MinifiTestContext, processor_type: str, property_name: st
7070
context.containers["nifi"].flow_definition.add_processor(processor)
7171

7272

73-
@given('a {processor_type} processor with the name "{processor_name}" in the "{minifi_container_name}" flow')
74-
def step_impl(context: MinifiTestContext, processor_type: str, processor_name: str, minifi_container_name: str):
75-
processor = Processor(processor_type, processor_name)
76-
context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_processor(processor)
77-
78-
7973
@given('a {processor_type} processor with the name "{processor_name}"')
8074
def step_impl(context: MinifiTestContext, processor_type: str, processor_name: str):
81-
context.execute_steps(
82-
f'given a {processor_type} processor with the name "{processor_name}" in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow')
75+
processor = Processor(processor_type, processor_name)
76+
context.get_or_create_default_minifi_container().flow_definition.add_processor(processor)
8377

8478

8579
@given("a {processor_type} processor in the \"{minifi_container_name}\" flow")
@@ -99,17 +93,6 @@ def step_impl(context: MinifiTestContext, processor_type: str):
9993
context.execute_steps(f'given a {processor_type} processor in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow')
10094

10195

102-
@given('the "{property_name}" property of the "{port_name}" port in the "{rpg_name}" remote process group is set to "{property_value}"')
103-
def step_impl(context: MinifiTestContext, property_name: str, port_name: str, rpg_name: str, property_value: str):
104-
rpg = context.get_or_create_minifi_container(DEFAULT_MINIFI_CONTAINER_NAME).flow_definition.get_remote_process_group(rpg_name)
105-
if not rpg:
106-
raise ValueError(f"Remote Process Group with name {rpg_name} not found")
107-
port = rpg.get_input_port(port_name)
108-
if not port:
109-
raise ValueError(f"Remote input port with name {port_name} not found in RPG {rpg_name}")
110-
port.add_property(property_name, property_value)
111-
112-
11396
@given('the "{property_name}" property of the {processor_name} processor is set to "{property_value}" in the "{minifi_container_name}" flow')
11497
def step_impl(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str, minifi_container_name: str):
11598
processor = context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(processor_name)
@@ -149,7 +132,6 @@ def step_impl(context: MinifiTestContext, funnel_name: str):
149132

150133

151134
@step('in the "{minifi_container_name}" flow the "{relationship_name}" relationship of the {source} processor is connected to the {target}')
152-
@step('in the "{minifi_container_name}" flow the "{relationship_name}" relationship of the {source} node is connected to the {target}')
153135
def step_impl(context: MinifiTestContext, relationship_name: str, source: str, target: str, minifi_container_name: str):
154136
connection = Connection(source_name=source, source_relationship=relationship_name, target_name=target)
155137
context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_connection(connection)
@@ -162,17 +144,10 @@ def step_impl(context: MinifiTestContext, relationship_name: str, source: str, t
162144

163145

164146
@step('the "{relationship_name}" relationship of the {source} processor is connected to the {target}')
165-
@step('the "{relationship_name}" relationship of the {source} node is connected to the {target}')
166147
def step_impl(context: MinifiTestContext, relationship_name: str, source: str, target: str):
167148
context.execute_steps(f'given in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow the "{relationship_name}" relationship of the {source} processor is connected to the {target}')
168149

169150

170-
@step("the output port \"{port_name}\" is connected to the {destination_name} processor")
171-
def step_impl(context: MinifiTestContext, port_name: str, destination_name: str):
172-
connection = Connection(source_name=port_name, source_relationship="undefined", target_name=destination_name)
173-
context.get_or_create_minifi_container(DEFAULT_MINIFI_CONTAINER_NAME).flow_definition.add_connection(connection)
174-
175-
176151
@step('the Funnel with the name "{funnel_name}" is connected to the {target}')
177152
def step_impl(context: MinifiTestContext, funnel_name: str, target: str):
178153
connection = Connection(source_name=funnel_name, source_relationship="success", target_name=target)
@@ -370,50 +345,3 @@ def step_impl(context: MinifiTestContext, processor_name):
370345
add_ssl_context_service_for_minifi(context, "minifi_client", use_system_cert_store=True)
371346
processor = context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name)
372347
processor.add_property('SSL Context Service', 'SSLContextService')
373-
374-
375-
@given("a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\" with transport protocol set to \"{transport_protocol}\"")
376-
def step_impl(context: MinifiTestContext, rpg_name: str, address: str, transport_protocol: str):
377-
context.get_or_create_default_minifi_container().flow_definition.add_remote_process_group(address, rpg_name, transport_protocol)
378-
379-
380-
@given("a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\"")
381-
def step_impl(context: MinifiTestContext, rpg_name: str, address: str):
382-
context.execute_steps(f"given a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\" with transport protocol set to \"RAW\"")
383-
384-
385-
@given("an input port with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"")
386-
def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str):
387-
context.get_or_create_default_minifi_container().flow_definition.add_input_port_to_rpg(rpg_name, port_name)
388-
389-
390-
@given("an input port using compression with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"")
391-
def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str):
392-
context.get_or_create_default_minifi_container().flow_definition.add_input_port_to_rpg(rpg_name, port_name, use_compression=True)
393-
394-
395-
@given("an output port with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"")
396-
def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str):
397-
context.get_or_create_default_minifi_container().flow_definition.add_output_port_to_rpg(rpg_name, port_name)
398-
399-
400-
@given("an output port using compression with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"")
401-
def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str):
402-
context.get_or_create_default_minifi_container().flow_definition.add_output_port_to_rpg(rpg_name, port_name, use_compression=True)
403-
404-
405-
@given("a NiFi flow is receiving data from the RemoteProcessGroup named \"{rpg_name}\" in an input port named \"{input_port_name}\" which has the same id as the port named \"{rpg_port_name}\"")
406-
def step_impl(context: MinifiTestContext, input_port_name: str, rpg_port_name: str, rpg_name: str):
407-
input_port_id = context.get_or_create_default_minifi_container().flow_definition.get_input_port_id_of_rpg(rpg_name, rpg_port_name)
408-
context.containers["nifi"].flow_definition.add_input_port(input_port_id, input_port_name)
409-
410-
411-
@given("a NiFi flow is sending data to an output port named \"{port_name}\" with the id of the port named \"{rpg_port_name}\" from the RemoteProcessGroup named \"{rpg_name}\"")
412-
def step_impl(context: MinifiTestContext, port_name: str, rpg_port_name: str, rpg_name: str):
413-
output_port_id = context.get_or_create_default_minifi_container().flow_definition.get_output_port_id_of_rpg(rpg_name, rpg_port_name)
414-
context.containers["nifi"].flow_definition.add_output_port(output_port_id, port_name)
415-
416-
417-
@given("the connection going to {destination} has \"drop empty\" set")
418-
def step_impl(context: MinifiTestContext, destination: str):
419-
context.get_or_create_default_minifi_container().flow_definition.set_drop_empty_for_destination(destination)

docker/RunBehaveTests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,5 @@ exec \
209209
"${docker_dir}/../extensions/lua/tests/features/" \
210210
"${docker_dir}/../extensions/civetweb/tests/features/" \
211211
"${docker_dir}/../extensions/mqtt/tests/features/" \
212-
"${docker_dir}/../extensions/prometheus/tests/features/"
212+
"${docker_dir}/../extensions/prometheus/tests/features/" \
213+
"${docker_dir}/../extensions/python/tests/features/"

0 commit comments

Comments
 (0)