adamdebreceni commented on code in PR #2059:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2059#discussion_r2660998331
##########
behave_framework/src/minifi_test_framework/steps/checking_steps.py:
##########
@@ -83,16 +84,34 @@ def step_impl(context: MinifiTestContext, message: str,
duration: str):
context=context)
+@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)
+ assert wait_for_condition(condition=lambda: re.search(regex,
context.get_default_minifi_container().get_logs()),
+ timeout_seconds=duration_seconds,
bail_condition=lambda: context.get_default_minifi_container().exited,
+ context=context)
+
+
@step('no errors were generated on the http-proxy regarding "{url}"')
def step_impl(context: MinifiTestContext, url: str):
http_proxy_container = next(container for container in
context.containers.values() if isinstance(container, HttpProxy))
assert http_proxy_container.check_http_proxy_access(url) or
http_proxy_container.log_app_output()
+@then('no files are placed in the "{directory}" directory in {duration} of
running time')
+def step_impl(context, directory, duration):
+ duration_seconds = humanfriendly.parse_timespan(duration)
+ assert check_condition_after_wait(condition=lambda:
context.get_default_minifi_container().get_number_of_files(directory) < 1,
Review Comment:
is the `< 1` intentional?
##########
behave_framework/src/minifi_test_framework/steps/checking_steps.py:
##########
@@ -152,3 +171,28 @@ def step_impl(context: MinifiTestContext, max_increase:
str, duration: str):
time.sleep(time_in_seconds)
final_memory_usage =
context.get_default_minifi_container().get_memory_usage()
assert final_memory_usage - initial_memory_usage <= max_increase_in_bytes
+
+
+@then('after a wait of {duration}, at least {lower_bound:d} and at most
{upper_bound:d} flowfiles are produced and placed in the "{directory}"
directory')
+def step_impl(context, lower_bound, upper_bound, duration, directory):
+ duration_seconds = humanfriendly.parse_timespan(duration)
+ assert check_condition_after_wait(condition=lambda:
context.get_default_minifi_container().get_number_of_files(directory) >=
lower_bound
+ and
context.get_default_minifi_container().get_number_of_files(directory) <=
upper_bound,
+ context=context,
wait_time=duration_seconds)
+
+
+@then('exactly these files are in the "{directory}" directory in less than
{duration}: "{contents}"')
+def step_impl(context, directory, duration, contents):
+ if not contents:
+ context.execute_steps(f'then no files are placed in the "{directory}"
directory in {duration} of running time')
+ return
+ contents_arr = contents.split(",")
+ timeout_in_seconds = humanfriendly.parse_timespan(duration)
+ assert wait_for_condition(condition=lambda:
context.get_default_minifi_container().verify_file_contents(directory,
contents_arr),
+ timeout_seconds=timeout_in_seconds,
bail_condition=lambda: False,
+ context=context)
+
+
+@then('exactly these files are in the "{directory}" directory in less than
{duration}: ""')
Review Comment:
I feel like "exactly" and "in less than" conflict, shouldn't we wait for the
exact amount of time with check_condition_after_wait
##########
behave_framework/src/minifi_test_framework/steps/flow_building_steps.py:
##########
@@ -220,3 +224,30 @@ def step_impl(context: MinifiTestContext, service_name:
str, property_name: str,
controller_service = ControllerService(class_name=service_name,
service_name=service_name)
controller_service.add_property(property_name, property_value)
context.get_or_create_default_minifi_container().flow_definition.controller_services.append(controller_service)
+
+
+@given("the \"{property_name}\" property of the {processor_name} processor is
set to match the attribute \"{attribute_key}\" to \"{attribute_value}\"")
+def step_impl(context: MinifiTestContext, property_name: str, processor_name:
str, attribute_key: str, attribute_value: str):
+ processor =
context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name)
+ if attribute_value == "(not set)":
Review Comment:
I feel like matching an attribute to `(not set)` would mean there is no such
attribute, but it seems we are ignoring the attribute, should we look for
`(ignore)` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]