This is an automated email from the ASF dual-hosted git repository. martinzink pushed a commit to branch apache-rusty-2 in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 01a82a3764989ff11047a9c047b1569638b6a5fb Author: Martin Zink <[email protected]> AuthorDate: Wed Mar 25 17:30:31 2026 +0100 MINIFICPP-2758 Rename step_impls in minifi behave --- .../src/minifi_behave/steps/checking_steps.py | 66 ++++++------- .../src/minifi_behave/steps/configuration_steps.py | 12 +-- .../src/minifi_behave/steps/core_steps.py | 54 +++++----- .../src/minifi_behave/steps/flow_building_steps.py | 110 ++++++++++----------- extensions/aws/tests/features/steps/steps.py | 18 ++-- extensions/azure/tests/features/steps/steps.py | 16 +-- extensions/couchbase/tests/features/steps/steps.py | 10 +- .../elasticsearch/tests/features/steps/steps.py | 18 ++-- extensions/gcp/tests/features/steps/steps.py | 6 +- .../grafana-loki/tests/features/steps/steps.py | 14 +-- extensions/kafka/tests/features/steps/steps.py | 18 ++-- .../kubernetes/tests/features/steps/steps.py | 6 +- extensions/mqtt/tests/features/steps/steps.py | 12 +-- extensions/opc/tests/features/steps/steps.py | 8 +- .../prometheus/tests/features/steps/steps.py | 14 +-- extensions/python/tests/features/steps/steps.py | 4 +- extensions/splunk/tests/features/steps/steps.py | 8 +- extensions/sql/tests/features/steps/steps.py | 6 +- .../features/steps/minifi_controller_steps.py | 24 ++--- .../tests/features/steps/steps.py | 24 ++--- 20 files changed, 224 insertions(+), 224 deletions(-) diff --git a/behave_framework/src/minifi_behave/steps/checking_steps.py b/behave_framework/src/minifi_behave/steps/checking_steps.py index fea80a18f..5bec54f5a 100644 --- a/behave_framework/src/minifi_behave/steps/checking_steps.py +++ b/behave_framework/src/minifi_behave/steps/checking_steps.py @@ -26,7 +26,7 @@ from minifi_behave.core.minifi_test_context import DEFAULT_MINIFI_CONTAINER_NAME @then('a file with the content "{content}" is placed on the path "{path}" in less than {duration}') -def step_impl(context: MinifiTestContext, content: str, path: str, duration: str): +def verify_file_content_on_path(context: MinifiTestContext, content: str, path: str, duration: str): new_content = content.replace("\\n", "\n") timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( @@ -35,7 +35,7 @@ def step_impl(context: MinifiTestContext, content: str, path: str, duration: str @then('in the "{container_name}" container a single file with the content "{content}" is placed in the "{directory}" directory in less than {duration}') -def step_impl(context: MinifiTestContext, container_name: str, content: str, directory: str, duration: str): +def verify_single_file_content_in_container_directory(context: MinifiTestContext, container_name: str, content: str, directory: str, duration: str): new_content = content.replace("\\n", "\n") timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( @@ -45,12 +45,12 @@ def step_impl(context: MinifiTestContext, container_name: str, content: str, dir @then('a single file with the content "{content}" is placed in the "{directory}" directory in less than {duration}') @then("a single file with the content '{content}' is placed in the '{directory}' directory in less than {duration}") -def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str): +def verify_single_file_content_in_directory(context: MinifiTestContext, content: str, directory: str, duration: str): 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}') @then('in the "{container_name}" container at least one file with the content "{content}" is placed in the "{directory}" directory in less than {duration}') -def step_impl(context: MinifiTestContext, container_name: str, content: str, directory: str, duration: str): +def verify_at_least_one_file_content_in_container_directory(context: MinifiTestContext, container_name: str, content: str, directory: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[container_name].directory_contains_file_with_content(directory, content), @@ -59,36 +59,36 @@ def step_impl(context: MinifiTestContext, container_name: str, content: str, dir @then('at least one file with the content "{content}" is placed in the "{directory}" directory in less than {duration}') @then("at least one file with the content '{content}' is placed in the '{directory}' directory in less than {duration}") -def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str): +def verify_at_least_one_file_content_in_directory(context: MinifiTestContext, content: str, directory: str, duration: str): context.execute_steps(f'then in the "{DEFAULT_MINIFI_CONTAINER_NAME}" container at least one file with the content "{content}" is placed in the "{directory}" directory in less than {duration}') @then("the logs of the '{container}' container do not contain the following message: '{message}' after {duration}") @then('the logs of the "{container}" container do not contain the following message: "{message}" after {duration}') -def step_impl(context: MinifiTestContext, container: str, message: str, duration: str): +def verify_container_logs_do_not_contain_message(context: MinifiTestContext, container: str, message: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) time.sleep(duration_seconds) assert message not in context.containers[container].get_logs() or log_due_to_failure(context) @then('the Minifi logs do not contain the following message: "{message}" after {duration}') -def step_impl(context: MinifiTestContext, message: str, duration: str): +def verify_minifi_logs_do_not_contain_message(context: MinifiTestContext, message: str, duration: str): context.execute_steps(f'then the logs of the "{DEFAULT_MINIFI_CONTAINER_NAME}" container do not contain the following message: "{message}" after {duration}') @then("the Minifi logs do not contain errors") -def step_impl(context: MinifiTestContext): +def verify_minifi_logs_do_not_contain_errors(context: MinifiTestContext): assert "[error]" not in context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_logs() or log_due_to_failure(context) @then("the Minifi logs do not contain warnings") -def step_impl(context: MinifiTestContext): +def verify_minifi_logs_do_not_contain_warnings(context: MinifiTestContext): assert "[warning]" not in context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_logs() or log_due_to_failure(context) @then("the logs of the '{container}' container contain the following message: '{message}' in less than {duration}") @then('the logs of the "{container}" container contain the following message: "{message}" in less than {duration}') -def step_impl(context: MinifiTestContext, container: str, message: str, duration: str): +def verify_container_logs_contain_message(context: MinifiTestContext, container: str, message: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition(condition=lambda: message in context.containers[container].get_logs(), timeout_seconds=duration_seconds, bail_condition=lambda: context.containers[container].exited, @@ -97,19 +97,19 @@ def step_impl(context: MinifiTestContext, container: str, message: str, duration @then("the Minifi logs contain the following message: '{message}' in less than {duration}") @then('the Minifi logs contain the following message: "{message}" in less than {duration}') -def step_impl(context: MinifiTestContext, message: str, duration: str): +def verify_minifi_logs_contain_message(context: MinifiTestContext, message: str, duration: str): context.execute_steps(f'then the logs of the "{DEFAULT_MINIFI_CONTAINER_NAME}" container contain the following message: "{message}" in less than {duration}') @then("the Minifi logs contain the following message: \"{log_message}\" {count:d} times after {duration}") -def step_impl(context, log_message, count, duration): +def verify_minifi_logs_contain_message_multiple_times(context, log_message, count, duration): duration_seconds = humanfriendly.parse_timespan(duration) time.sleep(duration_seconds) assert context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_logs().count(log_message) == count or log_due_to_failure(context) @then("the Minifi logs match the following regex: \"{regex}\" in less than {duration}") -def step_impl(context, regex, duration): +def verify_minifi_logs_match_regex(context, regex, duration): duration_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition(condition=lambda: re.search(regex, context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_logs()), timeout_seconds=duration_seconds, bail_condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].exited, @@ -117,26 +117,26 @@ def step_impl(context, regex, duration): @step('no errors were generated on the http-proxy regarding "{url}"') -def step_impl(context: MinifiTestContext, url: str): +def verify_no_errors_on_http_proxy(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('in the "{container}" container no files are placed in the "{directory}" directory in {duration} of running time') -def step_impl(context, container, directory, duration): +def verify_no_files_in_container_directory(context, container, directory, duration): duration_seconds = humanfriendly.parse_timespan(duration) assert check_condition_after_wait(condition=lambda: context.containers[container].get_number_of_files(directory) == 0, context=context, wait_time=duration_seconds) @then('no files are placed in the "{directory}" directory in {duration} of running time') -def step_impl(context, directory, duration): +def verify_no_files_in_directory(context, directory, duration): context.execute_steps(f'then in the "{DEFAULT_MINIFI_CONTAINER_NAME}" container no files are placed in the "{directory}" directory in {duration} of running time') @then('{num:d} files are placed in the "{directory}" directory in less than {duration}') @then('{num:d} file is placed in the "{directory}" directory in less than {duration}') -def step_impl(context: MinifiTestContext, num: int, directory: str, duration: str): +def verify_number_of_files_in_directory(context: MinifiTestContext, num: int, directory: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) if num == 0: context.execute_steps(f'then no files are placed in the "{directory}" directory in {duration} of running time') @@ -148,7 +148,7 @@ def step_impl(context: MinifiTestContext, num: int, directory: str, duration: st @then('at least {num:d} files are placed in the "{directory}" directory in less than {duration}') @then('at least {num:d} file is placed in the "{directory}" directory in less than {duration}') -def step_impl(context: MinifiTestContext, num: int, directory: str, duration: str): +def verify_at_least_number_of_files_in_directory(context: MinifiTestContext, num: int, directory: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition(condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_number_of_files(directory) >= num, timeout_seconds=duration_seconds, bail_condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].exited, @@ -157,7 +157,7 @@ def step_impl(context: MinifiTestContext, num: int, directory: str, duration: st @then('at least one file in "{directory}" content match the following regex: "{regex_str}" in less than {duration}') @then('the content of at least one file in the "{directory}" directory matches the \'{regex_str}\' regex in less than {duration}') -def step_impl(context: MinifiTestContext, directory: str, regex_str: str, duration: str): +def verify_file_content_matches_regex_in_directory(context: MinifiTestContext, directory: str, regex_str: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].directory_contains_file_with_regex(directory, regex_str), @@ -166,7 +166,7 @@ def step_impl(context: MinifiTestContext, directory: str, regex_str: str, durati @then('files with contents "{content_one}" and "{content_two}" are placed in the "{directory}" directory in less than {timeout}') @then("files with contents '{content_one}' and '{content_two}' are placed in the '{directory}' directory in less than {timeout}") -def step_impl(context: MinifiTestContext, directory: str, timeout: str, content_one: str, content_two: str): +def verify_files_with_two_contents_in_directory(context: MinifiTestContext, directory: str, timeout: str, content_one: str, content_two: str): timeout_seconds = humanfriendly.parse_timespan(timeout) c1 = content_one.replace("\\n", "\n") c2 = content_two.replace("\\n", "\n") @@ -177,7 +177,7 @@ def step_impl(context: MinifiTestContext, directory: str, timeout: str, content_ @then('files with contents "{contents}" are placed in the "{directory}" directory in less than {timeout}') -def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents: str): +def verify_files_with_contents_in_directory(context: MinifiTestContext, directory: str, timeout: str, contents: str): timeout_seconds = humanfriendly.parse_timespan(timeout) new_contents = contents.replace("\\n", "\n") contents_arr = new_contents.split(",") @@ -187,7 +187,7 @@ def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents @then('files with at least these contents "{contents}" are placed in the "{directory}" directory in less than {timeout}') -def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents: str): +def verify_files_with_at_least_contents_in_directory(context: MinifiTestContext, directory: str, timeout: str, contents: str): timeout_seconds = humanfriendly.parse_timespan(timeout) new_contents = contents.replace("\\n", "\n") contents_arr = new_contents.split(",") @@ -198,7 +198,7 @@ def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents @then("a file with the JSON content \"{content}\" is placed in the \"{directory}\" directory in less than {duration}") @then("a file with the JSON content '{content}' is placed in the '{directory}' directory in less than {duration}") -def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str): +def verify_file_with_json_content_in_directory(context: MinifiTestContext, content: str, directory: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].verify_path_with_json_content(directory, content), @@ -206,7 +206,7 @@ def step_impl(context: MinifiTestContext, content: str, directory: str, duration @then('MiNiFi\'s memory usage does not increase by more than {max_increase} after {duration}') -def step_impl(context: MinifiTestContext, max_increase: str, duration: str): +def verify_minifi_memory_usage_increase(context: MinifiTestContext, max_increase: str, duration: str): time_in_seconds = humanfriendly.parse_timespan(duration) max_increase_in_bytes = humanfriendly.parse_size(max_increase) initial_memory_usage = context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_memory_usage() @@ -217,7 +217,7 @@ def step_impl(context: MinifiTestContext, max_increase: str, duration: str): @then("at least one file with the JSON content \"{content}\" is placed in the \"{directory}\" directory in less than {duration}") @then("at least one file with the JSON content '{content}' is placed in the '{directory}' directory in less than {duration}") -def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str): +def verify_at_least_one_file_with_json_content_in_directory(context: MinifiTestContext, content: str, directory: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].directory_contains_file_with_json_content(directory, content), @@ -225,15 +225,15 @@ def step_impl(context: MinifiTestContext, content: str, directory: str, duration @then('after a wait of {duration}, at least {lower_bound:d} and at most {upper_bound:d} files are produced and placed in the "{directory}" directory') -def step_impl(context: MinifiTestContext, lower_bound: int, upper_bound: int, duration: str, directory: str): +def verify_file_count_bounds_in_directory(context: MinifiTestContext, lower_bound: int, upper_bound: int, duration: str, directory: str): duration_seconds = humanfriendly.parse_timespan(duration) assert check_condition_after_wait(condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_number_of_files(directory) >= lower_bound - and context.containers[DEFAULT_MINIFI_CONTAINER_NAME].get_number_of_files(directory) <= upper_bound, + and context.containers[DEFAULT_MINIFI_CONTAINER_NAME].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: MinifiTestContext, directory: str, duration: str, contents: str): +def verify_exact_files_in_directory(context: MinifiTestContext, directory: str, duration: str, contents: str): if not contents: context.execute_steps(f'then no files are placed in the "{directory}" directory in {duration} of running time') return @@ -245,12 +245,12 @@ def step_impl(context: MinifiTestContext, directory: str, duration: str, content @then('exactly these files are in the "{directory}" directory in less than {duration}: ""') -def step_impl(context, directory, duration): +def verify_empty_files_string_in_directory(context, directory, duration): context.execute_steps(f'then no files are placed in the "{directory}" directory in {duration} of running time') @then("at least one empty file is placed in the \"{directory}\" directory in less than {duration}") -def step_impl(context: MinifiTestContext, directory: str, duration: str): +def verify_at_least_one_empty_file_in_directory(context: MinifiTestContext, directory: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[DEFAULT_MINIFI_CONTAINER_NAME].directory_contains_empty_file(directory), @@ -258,7 +258,7 @@ def step_impl(context: MinifiTestContext, directory: str, duration: str): @then("in the \"{container_name}\" container at least one empty file is placed in the \"{directory}\" directory in less than {duration}") -def step_impl(context: MinifiTestContext, container_name: str, directory: str, duration: str): +def verify_at_least_one_empty_file_in_container_directory(context: MinifiTestContext, container_name: str, directory: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition( condition=lambda: context.containers[container_name].directory_contains_empty_file(directory), @@ -266,7 +266,7 @@ def step_impl(context: MinifiTestContext, container_name: str, directory: str, d @then("in the \"{container_name}\" container at least one file with minimum size of \"{size}\" is placed in the \"{directory}\" directory in less than {duration}") -def step_impl(context: MinifiTestContext, container_name: str, directory: str, size: str, duration: str): +def verify_file_with_minimum_size_in_container_directory(context: MinifiTestContext, container_name: str, directory: str, size: str, duration: str): timeout_in_seconds = humanfriendly.parse_timespan(duration) size_in_bytes = humanfriendly.parse_size(size) assert wait_for_condition( @@ -275,6 +275,6 @@ def step_impl(context: MinifiTestContext, container_name: str, directory: str, s @then("at least one file with minimum size of \"{size}\" is placed in the \"{directory}\" directory in less than {duration}") -def step_impl(context: MinifiTestContext, directory: str, size: str, duration: str): +def verify_file_with_minimum_size_in_directory(context: MinifiTestContext, directory: str, size: str, duration: str): context.execute_steps( f'Then in the "{DEFAULT_MINIFI_CONTAINER_NAME}" container at least one file with minimum size of "{size}" is placed in the "{directory}" directory in less than {duration}') diff --git a/behave_framework/src/minifi_behave/steps/configuration_steps.py b/behave_framework/src/minifi_behave/steps/configuration_steps.py index 553ef018a..48a1a8f5c 100644 --- a/behave_framework/src/minifi_behave/steps/configuration_steps.py +++ b/behave_framework/src/minifi_behave/steps/configuration_steps.py @@ -25,30 +25,30 @@ from minifi_behave.containers.minifi_protocol import fetch_flow_config_from_flow @step('MiNiFi configuration "{config_key}" is set to "{config_value}"') -def step_impl(context: MinifiTestContext, config_key: str, config_value: str): +def set_minifi_config_property(context: MinifiTestContext, config_key: str, config_value: str): context.get_or_create_default_minifi_container().set_property(config_key, config_value) @step("log metrics publisher is enabled in MiNiFi") -def step_impl(context: MinifiTestContext): +def enable_minifi_log_metrics_publisher(context: MinifiTestContext): enable_log_metrics_publisher(context.get_or_create_default_minifi_container()) @step('log property "{log_property_key}" is set to "{log_property_value}"') -def step_impl(context: MinifiTestContext, log_property_key: str, log_property_value: str): +def set_minifi_log_property(context: MinifiTestContext, log_property_key: str, log_property_value: str): context.get_or_create_default_minifi_container().set_log_property(log_property_key, log_property_value) @given("OpenSSL FIPS mode is enabled in MiNiFi") -def step_impl(context: MinifiTestContext): +def enable_minifi_openssl_fips_mode(context: MinifiTestContext): enable_openssl_fips_mode(context.get_or_create_default_minifi_container()) @given("flow configuration path is set up in flow url property") -def step_impl(context: MinifiTestContext): +def setup_flow_config_path_in_url(context: MinifiTestContext): fetch_flow_config_from_flow_url(context.get_or_create_default_minifi_container(), context.scenario_id) @given("SSL properties are set in MiNiFi") -def step_impl(context: MinifiTestContext): +def set_minifi_ssl_properties(context: MinifiTestContext): set_up_ssl_properties(context.get_or_create_default_minifi_container()) diff --git a/behave_framework/src/minifi_behave/steps/core_steps.py b/behave_framework/src/minifi_behave/steps/core_steps.py index 6fa544db1..28391cf09 100644 --- a/behave_framework/src/minifi_behave/steps/core_steps.py +++ b/behave_framework/src/minifi_behave/steps/core_steps.py @@ -34,20 +34,20 @@ from minifi_behave.core.minifi_test_context import DEFAULT_MINIFI_CONTAINER_NAME @when("both instances start up") @when("all instances start up") -def step_impl(context: MinifiTestContext): +def start_all_instances(context: MinifiTestContext): for container in context.containers.values(): assert container.deploy(context) logging.debug("All instances started up") @when("the MiNiFi instance starts up") -def step_impl(context: MinifiTestContext): +def start_minifi_instance(context: MinifiTestContext): assert context.get_or_create_default_minifi_container().deploy(context) logging.debug("MiNiFi instance started up") @step('a directory at "{directory}" has a file with the size "{size}"') -def step_impl(context: MinifiTestContext, directory: str, size: str): +def create_file_with_size_in_directory(context: MinifiTestContext, directory: str, size: str): size = humanfriendly.parse_size(size) content = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(size)) dirs = context.get_or_create_default_minifi_container().dirs @@ -72,127 +72,127 @@ def __add_directory_with_file_to_container(context: MinifiTestContext, directory @step('a directory at "{directory}" has a file with the content "{content}" in the "{flow_name}" flow') @step("a directory at '{directory}' has a file with the content '{content}' in the '{flow_name}' flow") -def step_impl(context: MinifiTestContext, directory: str, content: str, flow_name: str): +def create_file_with_content_in_directory_for_flow(context: MinifiTestContext, directory: str, content: str, flow_name: str): __add_directory_with_file_to_container(context, directory, str(uuid.uuid4()), content, flow_name) @step('a directory at "{directory}" has a file with the content "{content}"') @step("a directory at '{directory}' has a file with the content '{content}'") -def step_impl(context: MinifiTestContext, directory: str, content: str): +def create_file_with_content_in_directory(context: MinifiTestContext, directory: str, content: str): context.execute_steps(f'given a directory at "{directory}" has a file with the content "{content}" in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @step('a directory at "{directory}" has a file "{file_name}" with the content "{content}"') -def step_impl(context: MinifiTestContext, directory: str, file_name: str, content: str): +def create_file_with_name_and_content_in_directory(context: MinifiTestContext, directory: str, file_name: str, content: str): __add_directory_with_file_to_container(context, directory, file_name, content, DEFAULT_MINIFI_CONTAINER_NAME) @step('a file with filename "{file_name}" and content "{content}" is present in "{path}"') -def step_impl(context: MinifiTestContext, file_name: str, content: str, path: str): +def file_with_name_and_content_present_in_path(context: MinifiTestContext, file_name: str, content: str, path: str): new_content = content.replace("\\n", "\n") context.get_or_create_default_minifi_container().files.append(File(os.path.join(path, file_name), new_content)) @given('a file with the content "{content}" is present in "{path}" in the "{container_name}" flow') -def step_impl(context: MinifiTestContext, content: str, path: str, container_name: str): +def file_with_content_present_in_path_for_flow(context: MinifiTestContext, content: str, path: str, container_name: str): new_content = content.replace("\\n", "\n") context.get_or_create_minifi_container(container_name).files.append(File(os.path.join(path, str(uuid.uuid4())), new_content)) @given('a file with the content "{content}" is present in "{path}"') @given("a file with the content '{content}' is present in '{path}'") -def step_impl(context: MinifiTestContext, content: str, path: str): +def file_with_content_present_in_path(context: MinifiTestContext, content: str, path: str): context.execute_steps(f"given a file with the content \"{content}\" is present in \"{path}\" in the \"{DEFAULT_MINIFI_CONTAINER_NAME}\" flow") @when('a file with the content "{content}" is placed in "{path}" in the "{container_name}" flow') -def step_impl(context: MinifiTestContext, content: str, path: str, container_name: str): +def place_file_with_content_in_path_for_flow(context: MinifiTestContext, content: str, path: str, container_name: str): new_content = content.replace("\\n", "\n") context.containers[container_name].add_file_to_running_container(new_content, path) @when('a file with the content "{content}" is placed in "{path}"') -def step_impl(context: MinifiTestContext, content: str, path: str): +def place_file_with_content_in_path(context: MinifiTestContext, content: str, path: str): context.execute_steps(f"when a file with the content \"{content}\" is placed in \"{path}\" in the \"{DEFAULT_MINIFI_CONTAINER_NAME}\" flow") @given("an empty file is present in \"{path}\"") -def step_impl(context, path): +def empty_file_present_in_path(context, path): context.get_or_create_default_minifi_container().files.append(File(os.path.join(path, str(uuid.uuid4())), "")) @given('a host resource file "{filename}" is bound to the "{container_path}" path in the MiNiFi container "{container_name}"') -def step_impl(context: MinifiTestContext, filename: str, container_path: str, container_name: str): +def bind_host_resource_file_to_container_path_for_container(context: MinifiTestContext, filename: str, container_path: str, container_name: str): path = os.path.join(context.resource_dir, filename) context.get_or_create_minifi_container(container_name).add_host_file(path, container_path) @given('a host resource file "{filename}" is bound to the "{container_path}" path in the MiNiFi container') -def step_impl(context: MinifiTestContext, filename: str, container_path: str): +def bind_host_resource_file_to_container_path(context: MinifiTestContext, filename: str, container_path: str): context.execute_steps(f"given a host resource file \"{filename}\" is bound to the \"{container_path}\" path in the MiNiFi container \"{DEFAULT_MINIFI_CONTAINER_NAME}\"") @step("after {duration} have passed") @step("after {duration} has passed") -def step_impl(context: MinifiTestContext, duration: str): +def wait_duration(context: MinifiTestContext, duration: str): time.sleep(humanfriendly.parse_timespan(duration)) @when("MiNiFi is stopped") -def step_impl(context: MinifiTestContext): +def stop_minifi(context: MinifiTestContext): context.get_or_create_default_minifi_container().stop() @when("the \"{container_name}\" flow is stopped") -def step_impl(context: MinifiTestContext, container_name: str): +def stop_flow(context: MinifiTestContext, container_name: str): context.get_or_create_minifi_container(container_name).stop() @when("MiNiFi is restarted") -def step_impl(context: MinifiTestContext): +def restart_minifi(context: MinifiTestContext): context.get_or_create_default_minifi_container().restart() @when("the \"{container_name}\" flow is restarted") -def step_impl(context: MinifiTestContext, container_name: str): +def restart_flow(context: MinifiTestContext, container_name: str): context.get_or_create_minifi_container(container_name).restart() @when("the \"{container_name}\" flow is started") -def step_impl(context: MinifiTestContext, container_name: str): +def start_flow(context: MinifiTestContext, container_name: str): context.get_or_create_minifi_container(container_name).start() @when("the \"{container_name}\" flow is killed") -def step_impl(context: MinifiTestContext, container_name: str): +def kill_flow(context: MinifiTestContext, container_name: str): context.get_or_create_minifi_container(container_name).kill() @step("the http proxy server is set up") -def step_impl(context: MinifiTestContext): +def setup_http_proxy(context: MinifiTestContext): context.containers["http-proxy"] = HttpProxy(context) @step("a NiFi container is set up") -def step_impl(context: MinifiTestContext): +def setup_nifi_container(context: MinifiTestContext): context.containers["nifi"] = NifiContainer(context) @step("a NiFi container is set up with SSL enabled") -def step_impl(context: MinifiTestContext): +def setup_nifi_container_with_ssl(context: MinifiTestContext): context.containers["nifi"] = NifiContainer(context, use_ssl=True) @when('NiFi is started') -def step_impl(context): +def start_nifi(context): assert context.containers["nifi"].deploy(context) or context.containers["nifi"].log_app_output() @step("{duration} later") -def step_impl(context: MinifiTestContext, duration: str): +def wait_duration_later(context: MinifiTestContext, duration: str): time.sleep(humanfriendly.parse_timespan(duration)) @step("the MiNiFi deployment timeout is set to {timeout_seconds:d} seconds") -def step_impl(context: MinifiTestContext, timeout_seconds: int): +def set_minifi_deployment_timeout(context: MinifiTestContext, timeout_seconds: int): context.get_or_create_default_minifi_container().set_deploy_timeout_seconds(timeout_seconds) diff --git a/behave_framework/src/minifi_behave/steps/flow_building_steps.py b/behave_framework/src/minifi_behave/steps/flow_building_steps.py index 979434421..a4ef8ef92 100644 --- a/behave_framework/src/minifi_behave/steps/flow_building_steps.py +++ b/behave_framework/src/minifi_behave/steps/flow_building_steps.py @@ -29,12 +29,12 @@ from minifi_behave.minifi.processor import Processor @given("a MiNiFi CPP server with yaml config") -def step_impl(context: MinifiTestContext): +def minifi_cpp_server_with_yaml_config(context: MinifiTestContext): pass # TODO(lordgamez): Needs to be implemented after JSON config is set to be default @given("a transient MiNiFi flow with a LogOnDestructionProcessor processor") -def step_impl(context: MinifiTestContext): +def transient_flow_with_logondestructionprocessor(context: MinifiTestContext): context.get_or_create_default_minifi_container().command = ["/bin/sh", "-c", "timeout 10s ./bin/minifi.sh run && sleep 100"] context.get_or_create_default_minifi_container().flow_definition.add_processor( Processor("LogOnDestructionProcessor", "LogOnDestructionProcessor")) @@ -42,64 +42,64 @@ def step_impl(context: MinifiTestContext): @given( 'a {processor_type} processor with the name "{processor_name}" and the "{property_name}" property set to "{property_value}"') -def step_impl(context: MinifiTestContext, processor_type: str, processor_name: str, property_name: str, - property_value: str): +def processor_with_name_and_property(context: MinifiTestContext, processor_type: str, processor_name: str, property_name: str, + property_value: str): processor = Processor(processor_type, processor_name) processor.add_property(property_name, property_value) context.get_or_create_default_minifi_container().flow_definition.add_processor(processor) @step('a {processor_type} processor with the "{property_name}" property set to "{property_value}"') -def step_impl(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str): +def processor_with_property(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str): context.execute_steps( f'Given a {processor_type} processor with the name "{processor_type}" and the "{property_name}" property set to "{property_value}"') @step('a {processor_type} processor with the "{property_name}" property set to "{property_value}" in the "{minifi_container_name}" flow') -def step_impl(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str, minifi_container_name: str): +def processor_with_property_in_minifi_flow(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str, minifi_container_name: str): processor = Processor(processor_type, processor_type) processor.add_property(property_name, property_value) context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_processor(processor) @step('a {processor_type} processor with the "{property_name}" property set to "{property_value}" in the NiFi flow') -def step_impl(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str): +def processor_with_property_in_nifi_flow(context: MinifiTestContext, processor_type: str, property_name: str, property_value: str): processor = Processor(processor_type, processor_type) processor.add_property(property_name, property_value) context.containers["nifi"].flow_definition.add_processor(processor) @given('a {processor_type} processor with the name "{processor_name}" in the "{minifi_container_name}" flow') -def step_impl(context: MinifiTestContext, processor_type: str, processor_name: str, minifi_container_name: str): +def processor_with_name_in_minifi_flow(context: MinifiTestContext, processor_type: str, processor_name: str, minifi_container_name: str): processor = Processor(processor_type, processor_name) context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_processor(processor) @given('a {processor_type} processor with the name "{processor_name}"') -def step_impl(context: MinifiTestContext, processor_type: str, processor_name: str): +def processor_with_name(context: MinifiTestContext, processor_type: str, processor_name: str): context.execute_steps( f'given a {processor_type} processor with the name "{processor_name}" in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @given("a {processor_type} processor in the \"{minifi_container_name}\" flow") -def step_impl(context: MinifiTestContext, processor_type: str, minifi_container_name: str): +def processor_in_minifi_flow(context: MinifiTestContext, processor_type: str, minifi_container_name: str): processor = Processor(processor_type, processor_type) context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_processor(processor) @given("a {processor_type} processor in the NiFi flow") -def step_impl(context: MinifiTestContext, processor_type: str): +def processor_in_nifi_flow(context: MinifiTestContext, processor_type: str): processor = Processor(processor_type, processor_type) context.containers["nifi"].flow_definition.add_processor(processor) @given("a {processor_type} processor") -def step_impl(context: MinifiTestContext, processor_type: str): +def processor_setup(context: MinifiTestContext, processor_type: str): context.execute_steps(f'given a {processor_type} processor in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @given('the "{property_name}" property of the "{port_name}" port in the "{rpg_name}" remote process group is set to "{property_value}"') -def step_impl(context: MinifiTestContext, property_name: str, port_name: str, rpg_name: str, property_value: str): +def set_property_of_port_in_rpg(context: MinifiTestContext, property_name: str, port_name: str, rpg_name: str, property_value: str): rpg = context.get_or_create_minifi_container(DEFAULT_MINIFI_CONTAINER_NAME).flow_definition.get_remote_process_group(rpg_name) if not rpg: raise ValueError(f"Remote Process Group with name {rpg_name} not found") @@ -110,7 +110,7 @@ def step_impl(context: MinifiTestContext, property_name: str, port_name: str, rp @given('the "{property_name}" property of the {processor_name} processor is set to "{property_value}" in the "{minifi_container_name}" flow') -def step_impl(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str, minifi_container_name: str): +def set_property_of_processor_in_minifi_flow(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str, minifi_container_name: str): processor = context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(processor_name) if property_value == "(not set)": processor.remove_property(property_name) @@ -119,7 +119,7 @@ def step_impl(context: MinifiTestContext, property_name: str, processor_name: st @given('the "{property_name}" property of the {processor_name} processor is set to "{property_value}" in the NiFi flow') -def step_impl(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str): +def set_property_of_processor_in_nifi_flow(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str): processor = context.containers["nifi"].flow_definition.get_processor(processor_name) if property_value == "(not set)": processor.remove_property(property_name) @@ -128,13 +128,13 @@ def step_impl(context: MinifiTestContext, property_name: str, processor_name: st @given('the "{property_name}" property of the {processor_name} processor is set to "{property_value}"') -def step_impl(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str): +def set_property_of_processor(context: MinifiTestContext, property_name: str, processor_name: str, property_value: str): context.execute_steps( f'given the "{property_name}" property of the {processor_name} processor is set to "{property_value}" in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @step('the "{property_name}" property of the {controller_name} controller service is set to "{property_value}"') -def step_impl(context: MinifiTestContext, property_name: str, controller_name: str, property_value: str): +def set_property_of_controller_service(context: MinifiTestContext, property_name: str, controller_name: str, property_value: str): controller_service = context.get_or_create_default_minifi_container().flow_definition.get_controller_service(controller_name) if property_value == "(not set)": controller_service.remove_property(property_name) @@ -143,106 +143,106 @@ def step_impl(context: MinifiTestContext, property_name: str, controller_name: s @step('a Funnel with the name "{funnel_name}" is set up') -def step_impl(context: MinifiTestContext, funnel_name: str): +def setup_funnel(context: MinifiTestContext, funnel_name: str): context.get_or_create_default_minifi_container().flow_definition.add_funnel(Funnel(funnel_name)) @step('in the "{minifi_container_name}" flow the "{relationship_name}" relationship of the {source} processor is connected to the {target}') @step('in the "{minifi_container_name}" flow the "{relationship_name}" relationship of the {source} node is connected to the {target}') -def step_impl(context: MinifiTestContext, relationship_name: str, source: str, target: str, minifi_container_name: str): +def connect_relationship_in_minifi_flow(context: MinifiTestContext, relationship_name: str, source: str, target: str, minifi_container_name: str): connection = Connection(source_name=source, source_relationship=relationship_name, target_name=target) context.get_or_create_minifi_container(minifi_container_name).flow_definition.add_connection(connection) @step('in the NiFi flow the "{relationship_name}" relationship of the {source} processor is connected to the {target}') -def step_impl(context: MinifiTestContext, relationship_name: str, source: str, target: str): +def connect_relationship_in_nifi_flow(context: MinifiTestContext, relationship_name: str, source: str, target: str): connection = Connection(source_name=source, source_relationship=relationship_name, target_name=target) context.containers["nifi"].flow_definition.add_connection(connection) @step('the "{relationship_name}" relationship of the {source} processor is connected to the {target}') @step('the "{relationship_name}" relationship of the {source} node is connected to the {target}') -def step_impl(context: MinifiTestContext, relationship_name: str, source: str, target: str): +def connect_relationship(context: MinifiTestContext, relationship_name: str, source: str, target: str): 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}') @step("the output port \"{port_name}\" is connected to the {destination_name} processor") -def step_impl(context: MinifiTestContext, port_name: str, destination_name: str): +def connect_output_port_to_processor(context: MinifiTestContext, port_name: str, destination_name: str): connection = Connection(source_name=port_name, source_relationship="undefined", target_name=destination_name) context.get_or_create_minifi_container(DEFAULT_MINIFI_CONTAINER_NAME).flow_definition.add_connection(connection) @step('the Funnel with the name "{funnel_name}" is connected to the {target}') -def step_impl(context: MinifiTestContext, funnel_name: str, target: str): +def connect_funnel_to_target(context: MinifiTestContext, funnel_name: str, target: str): connection = Connection(source_name=funnel_name, source_relationship="success", target_name=target) context.get_or_create_default_minifi_container().flow_definition.add_connection(connection) @step("{processor_name}'s {relationship} relationship is auto-terminated in the \"{minifi_container_name}\" flow") -def step_impl(context: MinifiTestContext, processor_name: str, relationship: str, minifi_container_name: str): +def auto_terminate_relationship_in_minifi_flow(context: MinifiTestContext, processor_name: str, relationship: str, minifi_container_name: str): context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(processor_name).auto_terminated_relationships.append( relationship) @step("{processor_name}'s {relationship} relationship is auto-terminated in the NiFi flow") -def step_impl(context: MinifiTestContext, processor_name: str, relationship: str): +def auto_terminate_relationship_in_nifi_flow(context: MinifiTestContext, processor_name: str, relationship: str): context.containers["nifi"].flow_definition.get_processor(processor_name).auto_terminated_relationships.append(relationship) @step("{processor_name}'s {relationship} relationship is auto-terminated") @step("the \"{relationship}\" relationship of the {processor_name} processor is auto-terminated") -def step_impl(context: MinifiTestContext, processor_name: str, relationship: str): +def auto_terminate_relationship(context: MinifiTestContext, processor_name: str, relationship: str): context.execute_steps(f'given {processor_name}\'s {relationship} relationship is auto-terminated in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @given("a transient MiNiFi flow is set up") -def step_impl(context: MinifiTestContext): +def setup_transient_minifi_flow(context: MinifiTestContext): context.get_or_create_default_minifi_container().command = ["/bin/sh", "-c", "timeout 10s ./bin/minifi.sh run && sleep 100"] @step('the scheduling period of the {processor_name} processor is set to "{duration_str}" in the "{minifi_container_name}" flow') -def step_impl(context: MinifiTestContext, processor_name: str, duration_str: str, minifi_container_name: str): +def set_scheduling_period_in_minifi_flow(context: MinifiTestContext, processor_name: str, duration_str: str, minifi_container_name: str): context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(processor_name).scheduling_period = duration_str @step('the scheduling period of the {processor_name} processor is set to "{duration_str}" in the NiFi flow') -def step_impl(context: MinifiTestContext, processor_name: str, duration_str: str, minifi_container_name: str): +def set_scheduling_period_in_nifi_flow(context: MinifiTestContext, processor_name: str, duration_str: str, minifi_container_name: str): context.containers["nifi"].flow_definition.get_processor(processor_name).scheduling_period = duration_str @step('the scheduling period of the {processor_name} processor is set to "{duration_str}"') -def step_impl(context: MinifiTestContext, processor_name: str, duration_str: str): +def set_scheduling_period(context: MinifiTestContext, processor_name: str, duration_str: str): context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name).scheduling_period = duration_str @given("parameter context name is set to '{context_name}'") -def step_impl(context: MinifiTestContext, context_name: str): +def set_parameter_context_name(context: MinifiTestContext, context_name: str): context.get_or_create_default_minifi_container().flow_definition.parameter_contexts.append(ParameterContext(context_name)) @step( "a non-sensitive parameter in the flow config called '{parameter_name}' with the value '{parameter_value}' in the parameter context '{context_name}'") -def step_impl(context: MinifiTestContext, parameter_name: str, parameter_value: str, context_name: str): +def add_non_sensitive_parameter(context: MinifiTestContext, parameter_name: str, parameter_value: str, context_name: str): parameter_context = context.get_or_create_default_minifi_container().flow_definition.get_parameter_context(context_name) parameter_context.parameters.append(Parameter(parameter_name, parameter_value, False)) @given("these processor properties are set in the \"{minifi_container_name}\" flow") -def step_impl(context: MinifiTestContext, minifi_container_name: str): +def set_processor_properties_in_minifi_flow(context: MinifiTestContext, minifi_container_name: str): for row in context.table: processor = context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(row["processor name"]) processor.add_property(row["property name"], row["property value"]) @given("these processor properties are set") -def step_impl(context: MinifiTestContext): +def set_processor_properties(context: MinifiTestContext): for row in context.table: processor = context.get_or_create_default_minifi_container().flow_definition.get_processor(row["processor name"]) processor.add_property(row["property name"], row["property value"]) @step("the processors are connected up as described here") -def step_impl(context: MinifiTestContext): +def connect_processors_from_table(context: MinifiTestContext): for row in context.table: source_proc_name = row["source name"] dest_proc_name = row["destination name"] @@ -257,18 +257,18 @@ def step_impl(context: MinifiTestContext): @step("{processor_name} is EVENT_DRIVEN in the \"{minifi_container_name}\" flow") -def step_impl(context: MinifiTestContext, processor_name: str, minifi_container_name: str): +def set_processor_event_driven_in_minifi_flow(context: MinifiTestContext, processor_name: str, minifi_container_name: str): processor = context.get_or_create_minifi_container(minifi_container_name).flow_definition.get_processor(processor_name) processor.scheduling_strategy = "EVENT_DRIVEN" @step("{processor_name} is EVENT_DRIVEN") -def step_impl(context: MinifiTestContext, processor_name: str): +def set_processor_event_driven(context: MinifiTestContext, processor_name: str): context.execute_steps(f'given {processor_name} is EVENT_DRIVEN in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @step("{processor_name} is TIMER_DRIVEN with {scheduling_period} scheduling period") -def step_impl(context: MinifiTestContext, processor_name: str, scheduling_period: int): +def set_processor_timer_driven(context: MinifiTestContext, processor_name: str, scheduling_period: int): processor = context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name) processor.scheduling_strategy = "TIMER_DRIVEN" processor.scheduling_period = scheduling_period @@ -276,20 +276,20 @@ def step_impl(context: MinifiTestContext, processor_name: str, scheduling_period @given("a {service_name} controller service is set up") @given("an {service_name} controller service is set up") -def step_impl(context: MinifiTestContext, service_name: str): +def setup_controller_service(context: MinifiTestContext, service_name: str): controller_service = ControllerService(class_name=service_name, service_name=service_name) context.get_or_create_default_minifi_container().flow_definition.controller_services.append(controller_service) @given('a {service_name} controller service is set up and the "{property_name}" property set to "{property_value}"') -def step_impl(context: MinifiTestContext, service_name: str, property_name: str, property_value: str): +def setup_controller_service_with_property(context: MinifiTestContext, service_name: str, property_name: str, property_value: 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): +def set_processor_property_to_match_attribute(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)": # Ignore filtering @@ -302,13 +302,13 @@ def step_impl(context: MinifiTestContext, property_name: str, processor_name: st @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): +def set_processor_max_concurrent_tasks(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): +def set_processors_properties_to_same_uuid(context, property_name, processor_name_one, processor_name_two): uuid_str = str(uuid.uuid4()) context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name_one).add_property(property_name, uuid_str) context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name_two).add_property(property_name, uuid_str) @@ -330,67 +330,67 @@ def add_ssl_context_service_for_minifi(context: MinifiTestContext, cert_name: st @given("an ssl context service is set up") -def step_impl(context: MinifiTestContext): +def setup_ssl_context_service(context: MinifiTestContext): add_ssl_context_service_for_minifi(context, "minifi_client") @given("an ssl context service is set up for {processor_name}") @given("an ssl context service with a manual CA cert file is set up for {processor_name}") -def step_impl(context, processor_name): +def setup_ssl_context_service_for_processor(context, processor_name): add_ssl_context_service_for_minifi(context, "minifi_client") processor = context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name) processor.add_property('SSL Context Service', 'SSLContextService') @given("an ssl context service using the system CA cert store is set up for {processor_name}") -def step_impl(context: MinifiTestContext, processor_name): +def setup_ssl_context_service_system_ca_for_processor(context: MinifiTestContext, processor_name): add_ssl_context_service_for_minifi(context, "minifi_client", use_system_cert_store=True) processor = context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name) processor.add_property('SSL Context Service', 'SSLContextService') @given("a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\" with transport protocol set to \"{transport_protocol}\"") -def step_impl(context: MinifiTestContext, rpg_name: str, address: str, transport_protocol: str): +def open_rpg_with_transport_protocol(context: MinifiTestContext, rpg_name: str, address: str, transport_protocol: str): context.get_or_create_default_minifi_container().flow_definition.add_remote_process_group(address, rpg_name, transport_protocol) @given("a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\"") -def step_impl(context: MinifiTestContext, rpg_name: str, address: str): +def open_rpg(context: MinifiTestContext, rpg_name: str, address: str): context.execute_steps(f"given a RemoteProcessGroup node with name \"{rpg_name}\" is opened on \"{address}\" with transport protocol set to \"RAW\"") @given("an input port with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"") -def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str): +def create_input_port_on_rpg(context: MinifiTestContext, port_name: str, rpg_name: str): context.get_or_create_default_minifi_container().flow_definition.add_input_port_to_rpg(rpg_name, port_name) @given("an input port using compression with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"") -def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str): +def create_input_port_with_compression_on_rpg(context: MinifiTestContext, port_name: str, rpg_name: str): context.get_or_create_default_minifi_container().flow_definition.add_input_port_to_rpg(rpg_name, port_name, use_compression=True) @given("an output port with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"") -def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str): +def create_output_port_on_rpg(context: MinifiTestContext, port_name: str, rpg_name: str): context.get_or_create_default_minifi_container().flow_definition.add_output_port_to_rpg(rpg_name, port_name) @given("an output port using compression with name \"{port_name}\" is created on the RemoteProcessGroup named \"{rpg_name}\"") -def step_impl(context: MinifiTestContext, port_name: str, rpg_name: str): +def create_output_port_with_compression_on_rpg(context: MinifiTestContext, port_name: str, rpg_name: str): context.get_or_create_default_minifi_container().flow_definition.add_output_port_to_rpg(rpg_name, port_name, use_compression=True) @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}\"") -def step_impl(context: MinifiTestContext, input_port_name: str, rpg_port_name: str, rpg_name: str): +def nifi_receive_from_rpg_input_port(context: MinifiTestContext, input_port_name: str, rpg_port_name: str, rpg_name: str): input_port_id = context.get_or_create_default_minifi_container().flow_definition.get_input_port_id_of_rpg(rpg_name, rpg_port_name) context.containers["nifi"].flow_definition.add_input_port(input_port_id, input_port_name) @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}\"") -def step_impl(context: MinifiTestContext, port_name: str, rpg_port_name: str, rpg_name: str): +def nifi_send_to_rpg_output_port(context: MinifiTestContext, port_name: str, rpg_port_name: str, rpg_name: str): output_port_id = context.get_or_create_default_minifi_container().flow_definition.get_output_port_id_of_rpg(rpg_name, rpg_port_name) context.containers["nifi"].flow_definition.add_output_port(output_port_id, port_name) @given("the connection going to {destination} has \"drop empty\" set") -def step_impl(context: MinifiTestContext, destination: str): +def set_drop_empty_for_connection(context: MinifiTestContext, destination: str): context.get_or_create_default_minifi_container().flow_definition.set_drop_empty_for_destination(destination) diff --git a/extensions/aws/tests/features/steps/steps.py b/extensions/aws/tests/features/steps/steps.py index cc3afb54f..ab1094046 100644 --- a/extensions/aws/tests/features/steps/steps.py +++ b/extensions/aws/tests/features/steps/steps.py @@ -35,7 +35,7 @@ from containers.kinesis_server_container import KinesisServerContainer @step('a {processor_name} processor set up to communicate with an s3 server') @step('a {processor_name} processor set up to communicate with the same s3 server') -def step_impl(context: MinifiTestContext, processor_name: str): +def setup_s3_processor(context: MinifiTestContext, processor_name: str): processor = Processor(processor_name, processor_name) processor.add_property('Object Key', 'test_object_key') processor.add_property('Bucket', 'test_bucket') @@ -51,27 +51,27 @@ def step_impl(context: MinifiTestContext, processor_name: str): @step('the s3 server starts up') -def step_impl(context: MinifiTestContext): +def start_s3_server(context: MinifiTestContext): context.containers["s3-server"] = S3ServerContainer(context) assert context.containers["s3-server"].deploy(context) @step('the object on the s3 server is "{object_data}"') -def step_impl(context: MinifiTestContext, object_data: str): +def verify_s3_object_data(context: MinifiTestContext, object_data: str): s3_server_container = context.containers["s3-server"] assert isinstance(s3_server_container, S3ServerContainer) assert s3_server_container.check_s3_server_object_data(object_data) @step('the object content type on the s3 server is "{content_type}" and the object metadata matches use metadata') -def step_impl(context: MinifiTestContext, content_type: str): +def verify_s3_object_content_type_and_metadata(context: MinifiTestContext, content_type: str): s3_server_container = context.containers["s3-server"] assert isinstance(s3_server_container, S3ServerContainer) assert s3_server_container.check_s3_server_object_metadata(content_type) @step("the object bucket on the s3 server is empty in less than 10 seconds") -def step_impl(context): +def verify_s3_bucket_empty(context): s3_server_container = context.containers["s3-server"] assert isinstance(s3_server_container, S3ServerContainer) assert wait_for_condition( @@ -80,7 +80,7 @@ def step_impl(context): @step("the object on the s3 server is present and matches the original hash") -def step_impl(context): +def verify_s3_object_hash_matches(context): s3_server_container = context.containers["s3-server"] assert isinstance(s3_server_container, S3ServerContainer) @@ -94,7 +94,7 @@ def computeMD5hash(my_string): @step('there is a 6MB file at the "/tmp/input" directory and we keep track of the hash of that') -def step_impl(context): +def create_6mb_file_and_track_hash(context): size = humanfriendly.parse_size("6MB") content = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(size)) new_dir = Directory("/tmp/input") @@ -104,10 +104,10 @@ def step_impl(context): @step("a kinesis server is set up in correspondence with the PutKinesisStream") -def step_impl(context): +def setup_kinesis_server(context): context.containers["kinesis-server"] = KinesisServerContainer(context) @then("there is a record on the kinesis server with \"{record_data}\"") -def step_impl(context, record_data): +def verify_kinesis_record_data(context, record_data): assert context.containers["kinesis-server"].check_kinesis_server_record_data(record_data) or log_due_to_failure(context) diff --git a/extensions/azure/tests/features/steps/steps.py b/extensions/azure/tests/features/steps/steps.py index 539465a6c..25409d427 100644 --- a/extensions/azure/tests/features/steps/steps.py +++ b/extensions/azure/tests/features/steps/steps.py @@ -29,7 +29,7 @@ from containers.azure_server_container import AzureServerContainer @step("a {processor_name} processor set up to communicate with an Azure blob storage") -def step_impl(context: MinifiTestContext, processor_name: str): +def setup_azure_blob_storage_processor(context: MinifiTestContext, processor_name: str): processor = Processor(processor_name, processor_name) hostname = f"http://azure-storage-server-{context.scenario_id}" processor.add_property('Container Name', 'test-container') @@ -41,41 +41,41 @@ def step_impl(context: MinifiTestContext, processor_name: str): @step("an Azure storage server is set up") -def step_impl(context): +def setup_azure_storage_server(context): context.containers["azure-storage-server"] = AzureServerContainer(context) assert context.containers["azure-storage-server"].deploy(context) @then('the object on the Azure storage server is "{object_data}"') -def step_impl(context: MinifiTestContext, object_data: str): +def verify_azure_storage_server_data(context: MinifiTestContext, object_data: str): azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) assert azure_server_container.check_azure_storage_server_data(object_data) @step('test blob "{blob_name}" with the content "{data}" is created on Azure blob storage') -def step_impl(context: MinifiTestContext, blob_name: str, data: str): +def create_test_blob_with_content(context: MinifiTestContext, blob_name: str, data: str): azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) assert azure_server_container.add_test_blob(blob_name, content=data) @step('test blob "{blob_name}" is created on Azure blob storage') -def step_impl(context: MinifiTestContext, blob_name: str): +def create_test_blob(context: MinifiTestContext, blob_name: str): azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) assert azure_server_container.add_test_blob(blob_name) @step('test blob "{blob_name}" is created on Azure blob storage with a snapshot') -def step_impl(context: MinifiTestContext, blob_name: str): +def create_test_blob_with_snapshot(context: MinifiTestContext, blob_name: str): azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) assert azure_server_container.add_test_blob(blob_name, with_snapshot=True) @then("the Azure blob storage becomes empty in {timeout_str}") -def step_impl(context: MinifiTestContext, timeout_str: str): +def verify_azure_blob_storage_is_empty(context: MinifiTestContext, timeout_str: str): timeout_in_seconds = humanfriendly.parse_timespan(timeout_str) azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) @@ -87,7 +87,7 @@ def step_impl(context: MinifiTestContext, timeout_str: str): @then("the blob and snapshot count becomes 1 in {timeout_str}") -def step_impl(context: MinifiTestContext, timeout_str: str): +def verify_blob_and_snapshot_count(context: MinifiTestContext, timeout_str: str): timeout_in_seconds = humanfriendly.parse_timespan(timeout_str) azure_server_container = context.containers["azure-storage-server"] assert isinstance(azure_server_container, AzureServerContainer) diff --git a/extensions/couchbase/tests/features/steps/steps.py b/extensions/couchbase/tests/features/steps/steps.py index d9e62a959..9f0edeffc 100644 --- a/extensions/couchbase/tests/features/steps/steps.py +++ b/extensions/couchbase/tests/features/steps/steps.py @@ -26,13 +26,13 @@ from containers.couchbase_server_container import CouchbaseServerContainer @step("a Couchbase server is started") -def step_impl(context: MinifiTestContext): +def start_couchbase_server(context: MinifiTestContext): context.containers["couchbase-server"] = CouchbaseServerContainer(context) assert context.containers["couchbase-server"].deploy(context) @step("a CouchbaseClusterService controller service is set up to communicate with the Couchbase server") -def step_impl(context: MinifiTestContext): +def setup_couchbase_cluster_service(context: MinifiTestContext): controller_service = ControllerService(class_name="CouchbaseClusterService", service_name="CouchbaseClusterService") controller_service.add_property("Connection String", f"couchbase://couchbase-server-{context.scenario_id}") controller_service.add_property("User Name", "Administrator") @@ -41,7 +41,7 @@ def step_impl(context: MinifiTestContext): @step("a CouchbaseClusterService is set up using SSL connection") -def step_impl(context): +def setup_couchbase_cluster_service_ssl(context): ssl_context_service = ControllerService(class_name="SSLContextService", service_name="SSLContextService") ssl_context_service.add_property("CA Certificate", "/tmp/resources/root_ca.crt") context.get_or_create_default_minifi_container().flow_definition.controller_services.append(ssl_context_service) @@ -54,7 +54,7 @@ def step_impl(context): @step("a CouchbaseClusterService is setup up using mTLS authentication") -def step_impl(context: MinifiTestContext): +def setup_couchbase_cluster_service_mtls(context: MinifiTestContext): add_ssl_context_service_for_minifi(context, "clientuser") controller_service = ControllerService(class_name="CouchbaseClusterService", service_name="CouchbaseClusterService") controller_service.add_property("Connection String", f"couchbases://couchbase-server-{context.scenario_id}") @@ -63,5 +63,5 @@ def step_impl(context: MinifiTestContext): @then("a document with id \"{doc_id}\" in bucket \"{bucket_name}\" is present with data '{data}' of type \"{data_type}\" in Couchbase") -def step_impl(context, doc_id: str, bucket_name: str, data: str, data_type: str): +def verify_couchbase_document_data(context, doc_id: str, bucket_name: str, data: str, data_type: str): assert context.containers["couchbase-server"].is_data_present_in_couchbase(doc_id, bucket_name, data, data_type) or log_due_to_failure(context) diff --git a/extensions/elasticsearch/tests/features/steps/steps.py b/extensions/elasticsearch/tests/features/steps/steps.py index 32e82d34f..bae56d5fc 100644 --- a/extensions/elasticsearch/tests/features/steps/steps.py +++ b/extensions/elasticsearch/tests/features/steps/steps.py @@ -28,14 +28,14 @@ from containers.opensearch_container import OpensearchContainer @step('an Elasticsearch server is set up and running') @step('an Elasticsearch server is set up and a single document is present with "preloaded_id" in "my_index"') @step('an Elasticsearch server is set up and a single document is present with "preloaded_id" in "my_index" with "value1" in "field1"') -def step_impl(context: MinifiTestContext): +def setup_elasticsearch_server(context: MinifiTestContext): context.containers["elasticsearch"] = ElasticsearchContainer(context) assert context.containers["elasticsearch"].deploy(context) assert context.containers["elasticsearch"].create_doc_elasticsearch("my_index", "preloaded_id") or context.containers["elasticsearch"].log_app_output() @given('an ElasticsearchCredentialsControllerService is set up with Basic Authentication') -def step_impl(context: MinifiTestContext): +def setup_elasticsearch_credentials_service_basic_auth(context: MinifiTestContext): controller_service = ControllerService(class_name="ElasticsearchCredentialsControllerService", service_name="ElasticsearchCredentialsControllerService") controller_service.add_property("Username", "elastic") controller_service.add_property("Password", "password") @@ -43,7 +43,7 @@ def step_impl(context: MinifiTestContext): @given('an ElasticsearchCredentialsControllerService is set up with ApiKey') -def step_impl(context: MinifiTestContext): +def setup_elasticsearch_credentials_service_api_key(context: MinifiTestContext): controller_service = ControllerService(class_name="ElasticsearchCredentialsControllerService", service_name="ElasticsearchCredentialsControllerService") api_key = context.containers["elasticsearch"].elastic_generate_apikey() controller_service.add_property("API Key", api_key) @@ -51,19 +51,19 @@ def step_impl(context: MinifiTestContext): @then('Elasticsearch has a document with "{doc_id}" in "{index}" that has "{value}" set in "{field}"') -def step_impl(context: MinifiTestContext, doc_id: str, index: str, value: str, field: str): +def verify_elasticsearch_document_field_value(context: MinifiTestContext, doc_id: str, index: str, value: str, field: str): assert context.containers["elasticsearch"].check_elastic_field_value(index_name=index, doc_id=doc_id, field_name=field, field_value=value) or log_due_to_failure(context) @then("Elasticsearch is empty") -def step_impl(context): +def verify_elasticsearch_is_empty(context): assert context.containers["elasticsearch"].is_elasticsearch_empty() or log_due_to_failure(context) @given('an Opensearch server is set up and running') @given('an Opensearch server is set up and a single document is present with "preloaded_id" in "my_index"') @given('an Opensearch server is set up and a single document is present with "preloaded_id" in "my_index" with "value1" in "field1"') -def step_impl(context): +def setup_opensearch_server(context): context.containers["opensearch"] = OpensearchContainer(context) context.containers["opensearch"].deploy(context) context.containers["opensearch"].add_elastic_user_to_opensearch() @@ -71,10 +71,10 @@ def step_impl(context): @then('Opensearch has a document with "{doc_id}" in "{index}" that has "{value}" set in "{field}"') -def step_impl(context: MinifiTestContext, doc_id: str, index: str, value: str, field: str): +def verify_opensearch_document_field_value(context: MinifiTestContext, doc_id: str, index: str, value: str, field: str): assert context.containers["opensearch"].check_elastic_field_value(index_name=index, doc_id=doc_id, field_name=field, field_value=value) or log_due_to_failure(context) @then("Opensearch is empty") -def step_impl(context): - assert context.containers["opensearch"].is_elasticsearch_empty() or log_due_to_failure(context) +def verify_opensearch_is_empty(context): + assert context.containers["opensearch"].is_elasticsearch_empty() or log_due_to_failure(context) \ No newline at end of file diff --git a/extensions/gcp/tests/features/steps/steps.py b/extensions/gcp/tests/features/steps/steps.py index 87c5e3e63..b2e9308ec 100644 --- a/extensions/gcp/tests/features/steps/steps.py +++ b/extensions/gcp/tests/features/steps/steps.py @@ -26,16 +26,16 @@ from containers.fake_gcs_server_container import FakeGcsServerContainer @step("a Google Cloud storage server is set up") @step("a Google Cloud storage server is set up with some test data") @step('a Google Cloud storage server is set up and a single object with contents "preloaded data" is present') -def step_impl(context: MinifiTestContext): +def setup_gcs_server(context: MinifiTestContext): context.containers["fake-gcs-server"] = FakeGcsServerContainer(context) assert context.containers["fake-gcs-server"].deploy(context) @then('an object with the content \"{content}\" is present in the Google Cloud storage') -def step_imp(context: MinifiTestContext, content: str): +def verify_gcs_object_content(context: MinifiTestContext, content: str): assert context.containers["fake-gcs-server"].check_google_cloud_storage(content) or log_due_to_failure(context) @then("the test bucket of Google Cloud Storage is empty") -def step_impl(context: MinifiTestContext): +def verify_gcs_bucket_is_empty(context: MinifiTestContext): assert context.containers["fake-gcs-server"].is_gcs_bucket_empty() or log_due_to_failure(context) diff --git a/extensions/grafana-loki/tests/features/steps/steps.py b/extensions/grafana-loki/tests/features/steps/steps.py index 1a225fa3f..0ab076923 100644 --- a/extensions/grafana-loki/tests/features/steps/steps.py +++ b/extensions/grafana-loki/tests/features/steps/steps.py @@ -25,39 +25,39 @@ from containers.reverse_proxy_container import ReverseProxyContainer @step("a Grafana Loki server is set up") -def step_impl(context: MinifiTestContext): +def setup_grafana_loki_server(context: MinifiTestContext): context.containers["grafana-loki-server"] = GrafanaLokiContainer(context, GrafanaLokiOptions()) @step("a Grafana Loki server is set up with multi-tenancy enabled") -def step_impl(context: MinifiTestContext): +def setup_grafana_loki_server_multitenant(context: MinifiTestContext): context.containers["grafana-loki-server"] = GrafanaLokiContainer(context, GrafanaLokiOptions(enable_multi_tenancy=True)) @step("a Grafana Loki server with SSL is set up") -def step_impl(context: MinifiTestContext): +def setup_grafana_loki_server_ssl(context: MinifiTestContext): context.containers["grafana-loki-server"] = GrafanaLokiContainer(context, GrafanaLokiOptions(enable_ssl=True)) @then("\"{lines}\" lines are published to the Grafana Loki server in less than {timeout_seconds:d} seconds") @then("\"{lines}\" line is published to the Grafana Loki server in less than {timeout_seconds:d} seconds") -def step_impl(context, lines: str, timeout_seconds: int): +def verify_lines_published_to_loki(context, lines: str, timeout_seconds: int): assert context.containers["grafana-loki-server"].are_lines_present(lines, timeout_seconds, ssl=False) or log_due_to_failure(context) @then("\"{lines}\" lines are published to the \"{tenant_id}\" tenant on the Grafana Loki server in less than {timeout_seconds:d} seconds") @then("\"{lines}\" line is published to the \"{tenant_id}\" tenant on the Grafana Loki server in less than {timeout_seconds:d} seconds") -def step_impl(context, lines: str, timeout_seconds: int, tenant_id: str): +def verify_lines_published_to_loki_tenant(context, lines: str, timeout_seconds: int, tenant_id: str): assert context.containers["grafana-loki-server"].are_lines_present(lines, timeout_seconds, ssl=False, tenant_id=tenant_id) or log_due_to_failure(context) @then("\"{lines}\" lines are published using SSL to the Grafana Loki server in less than {timeout_seconds:d} seconds") @then("\"{lines}\" line is published using SSL to the Grafana Loki server in less than {timeout_seconds:d} seconds") -def step_impl(context, lines: str, timeout_seconds: int): +def verify_lines_published_to_loki_ssl(context, lines: str, timeout_seconds: int): assert context.containers["grafana-loki-server"].are_lines_present(lines, timeout_seconds, ssl=True) or log_due_to_failure(context) # Nginx reverse proxy @step('a reverse proxy is set up to forward requests to the Grafana Loki server') -def step_impl(context): +def setup_reverse_proxy_for_loki(context): context.containers["reverse-proxy"] = ReverseProxyContainer(context) diff --git a/extensions/kafka/tests/features/steps/steps.py b/extensions/kafka/tests/features/steps/steps.py index 40ab7a5a1..372988ee8 100644 --- a/extensions/kafka/tests/features/steps/steps.py +++ b/extensions/kafka/tests/features/steps/steps.py @@ -28,12 +28,12 @@ from containers.kafka_server_container import KafkaServer @step("a Kafka server is set up") -def step_impl(context): +def setup_kafka_server(context): context.containers["kafka-server"] = KafkaServer(context) @step("ConsumeKafka processor is set up to communicate with that server") -def step_impl(context): +def setup_consume_kafka_processor(context): consume_kafka = Processor("ConsumeKafka", "ConsumeKafka") consume_kafka.add_property("Kafka Brokers", f"kafka-server-{context.scenario_id}:9092") consume_kafka.add_property("Topic Names", "ConsumeKafkaTest") @@ -49,7 +49,7 @@ def step_impl(context): @step("PublishKafka processor is set up to communicate with that server") -def step_impl(context): +def setup_publish_kafka_processor(context): publish_kafka = Processor("PublishKafka", "PublishKafka") publish_kafka.add_property("Known Brokers", f"kafka-server-{context.scenario_id}:9092") publish_kafka.add_property("Client Name", "minifi-client") @@ -63,28 +63,28 @@ def step_impl(context): @step("the Kafka server is started") -def step_impl(context: MinifiTestContext): +def start_kafka_server(context: MinifiTestContext): kafka_server_container = context.containers["kafka-server"] assert isinstance(kafka_server_container, KafkaServer) assert kafka_server_container.deploy(context) @step('the topic "{topic_name}" is initialized on the kafka broker') -def step_impl(context: MinifiTestContext, topic_name: str): +def initialize_kafka_topic(context: MinifiTestContext, topic_name: str): kafka_server_container = context.containers["kafka-server"] assert isinstance(kafka_server_container, KafkaServer) assert kafka_server_container.create_topic(topic_name=topic_name) or kafka_server_container.log_app_output() @when('a message with content "{message}" is published to the "{topic_name}" topic') -def step_impl(context: MinifiTestContext, message: str, topic_name: str): +def publish_message_to_topic(context: MinifiTestContext, message: str, topic_name: str): kafka_server_container = context.containers["kafka-server"] assert isinstance(kafka_server_container, KafkaServer) assert kafka_server_container.produce_message(topic_name=topic_name, message=message) or kafka_server_container.log_app_output() @step('a message with content "{message}" is published to the "{topic_name}" topic with key "{key}"') -def step_impl(context: MinifiTestContext, message: str, topic_name: str, key: str): +def publish_message_with_key_to_topic(context: MinifiTestContext, message: str, topic_name: str, key: str): kafka_server_container = context.containers["kafka-server"] assert isinstance(kafka_server_container, KafkaServer) assert kafka_server_container.produce_message_with_key(topic_name=topic_name, message=message, message_key=key) or kafka_server_container.log_app_output() @@ -207,8 +207,8 @@ def wait_for_consumer_registration(context): @when("the Kafka consumer is reregistered in kafka broker") -def wait_for_consumer_registration(context): +def wait_for_consumer_reregistration(context): assert context.containers["kafka-server"].wait_for_kafka_consumer_to_be_registered(2) or context.containers["kafka-server"].log_app_output() # After the consumer is registered there is still some time needed for consumer-broker synchronization # Unfortunately there are no additional log messages that could be checked for this - time.sleep(2) + time.sleep(2) \ No newline at end of file diff --git a/extensions/kubernetes/tests/features/steps/steps.py b/extensions/kubernetes/tests/features/steps/steps.py index 61697c586..b153cadb0 100644 --- a/extensions/kubernetes/tests/features/steps/steps.py +++ b/extensions/kubernetes/tests/features/steps/steps.py @@ -33,7 +33,7 @@ def __ensure_kubernetes_cluster(context: MinifiTestContext): @given("a {processor_type} processor in a Kubernetes cluster") @given("a {processor_type} processor in the Kubernetes cluster") -def step_impl(context: MinifiTestContext, processor_type: str): +def setup_processor_in_kubernetes_cluster(context: MinifiTestContext, processor_type: str): __ensure_kubernetes_cluster(context) processor = Processor(class_name=processor_type, proc_name=processor_type) context.get_or_create_default_minifi_container().flow_definition.add_processor(processor) @@ -49,11 +49,11 @@ def __set_up_the_kubernetes_controller_service(context: MinifiTestContext, proce @given("the {processor_name} processor has a {service_property_name} which is a Kubernetes Controller Service") @given("the {processor_name} processor has an {service_property_name} which is a Kubernetes Controller Service") -def step_impl(context: MinifiTestContext, processor_name: str, service_property_name: str): +def setup_kubernetes_controller_service_for_processor(context: MinifiTestContext, processor_name: str, service_property_name: str): __set_up_the_kubernetes_controller_service(context, processor_name, service_property_name, {}) @given("the {processor_name} processor has a {service_property_name} which is a Kubernetes Controller Service with the \"{property_name}\" property set to \"{property_value}\"") @given("the {processor_name} processor has an {service_property_name} which is a Kubernetes Controller Service with the \"{property_name}\" property set to \"{property_value}\"") -def step_impl(context: MinifiTestContext, processor_name: str, service_property_name: str, property_name: str, property_value: str): +def setup_kubernetes_controller_service_with_property_for_processor(context: MinifiTestContext, processor_name: str, service_property_name: str, property_name: str, property_value: str): __set_up_the_kubernetes_controller_service(context, processor_name, service_property_name, {property_name: property_value}) diff --git a/extensions/mqtt/tests/features/steps/steps.py b/extensions/mqtt/tests/features/steps/steps.py index 625037fe4..1bce835ae 100644 --- a/extensions/mqtt/tests/features/steps/steps.py +++ b/extensions/mqtt/tests/features/steps/steps.py @@ -28,7 +28,7 @@ from containers.mqtt_broker_container import MqttBrokerContainer @given("a {processor_name} processor set up to communicate with an MQTT broker instance in the \"{container_name}\" flow") -def step_impl(context: MinifiTestContext, processor_name: str, container_name: str): +def setup_mqtt_processor_in_flow(context: MinifiTestContext, processor_name: str, container_name: str): processor = Processor(processor_name, processor_name) processor.add_property('Broker URI', f'mqtt-broker-{context.scenario_id}:1883') processor.add_property('Topic', 'testtopic') @@ -43,18 +43,18 @@ def step_impl(context: MinifiTestContext, processor_name: str, container_name: s @given("a {processor_name} processor set up to communicate with an MQTT broker instance") -def step_impl(context: MinifiTestContext, processor_name: str): +def setup_mqtt_processor(context: MinifiTestContext, processor_name: str): context.execute_steps(f'given a {processor_name} processor set up to communicate with an MQTT broker instance in the "{DEFAULT_MINIFI_CONTAINER_NAME}" flow') @step("an MQTT broker is started") -def step_impl(context: MinifiTestContext): +def start_mqtt_broker(context: MinifiTestContext): context.containers["mqtt-broker"] = MqttBrokerContainer(context) assert context.containers["mqtt-broker"].deploy(context) @then('the MQTT broker has a log line matching "{log_line_regex}"') -def step_impl(context: MinifiTestContext, log_line_regex: str): +def verify_mqtt_broker_log_line_matches(context: MinifiTestContext, log_line_regex: str): assert wait_for_condition( condition=lambda: re.search(log_line_regex, context.containers["mqtt-broker"].get_logs()), timeout_seconds=60, @@ -63,7 +63,7 @@ def step_impl(context: MinifiTestContext, log_line_regex: str): @then('the MQTT broker has {log_count:d} log lines matching "{log_line_regex}"') -def step_impl(context: MinifiTestContext, log_count: int, log_line_regex: str): +def verify_mqtt_broker_log_line_count_matches(context: MinifiTestContext, log_count: int, log_line_regex: str): assert wait_for_condition( condition=lambda: len(re.findall(log_line_regex, context.containers["mqtt-broker"].get_logs())) == log_count, timeout_seconds=60, @@ -72,5 +72,5 @@ def step_impl(context: MinifiTestContext, log_count: int, log_line_regex: str): @when("a test message \"{message}\" is published to the MQTT broker on topic \"{topic}\"") -def step_impl(context: MinifiTestContext, message: str, topic: str): +def publish_test_message_to_mqtt_broker(context: MinifiTestContext, message: str, topic: str): assert context.containers["mqtt-broker"].publish_mqtt_message(topic, message) diff --git a/extensions/opc/tests/features/steps/steps.py b/extensions/opc/tests/features/steps/steps.py index 22a077123..0dcd61c89 100644 --- a/extensions/opc/tests/features/steps/steps.py +++ b/extensions/opc/tests/features/steps/steps.py @@ -32,17 +32,17 @@ from containers.opc_ua_server_container import OPCUAServerContainer @step("an OPC UA server is set up") -def step_impl(context: MinifiTestContext): +def setup_opcua_server(context: MinifiTestContext): context.containers["opcua-server"] = OPCUAServerContainer(context) @step("an OPC UA server is set up with access control") -def step_impl(context: MinifiTestContext): +def setup_opcua_server_with_access_control(context: MinifiTestContext): context.containers["opcua-server-access"] = OPCUAServerContainer(context, command=["/opt/open62541/examples/access_control_server"]) @then("the OPC UA server logs contain the following message: \"{log_message}\" in less than {duration}") -def step_impl(context, log_message, duration): +def verify_opcua_server_logs_contain_message(context, log_message, duration): timeout_seconds = humanfriendly.parse_timespan(duration) opcua_container = context.containers["opcua-server"] assert isinstance(opcua_container, OPCUAServerContainer) @@ -76,7 +76,7 @@ def _copy_file_from_docker_image(image_name: str, file_path: str, output_path: s @given('the OPC UA server certificate files are placed in the "{directory}" directory in the MiNiFi container "{container_name}"') -def step_impl(context: MinifiTestContext, directory: str, container_name: str): +def place_opcua_certificate_files_in_minifi_container(context: MinifiTestContext, directory: str, container_name: str): if not hasattr(context, "opcua_cert_temp_dir"): context.opcua_cert_temp_dir = tempfile.TemporaryDirectory() _copy_file_from_docker_image(OPCUAServerContainer.OPC_SERVER_IMAGE, "/opt/open62541/pki/created/server_cert.der", os.path.join(context.opcua_cert_temp_dir.name, "server_cert.der")) diff --git a/extensions/prometheus/tests/features/steps/steps.py b/extensions/prometheus/tests/features/steps/steps.py index 2f3aedcb2..eb27aecb7 100644 --- a/extensions/prometheus/tests/features/steps/steps.py +++ b/extensions/prometheus/tests/features/steps/steps.py @@ -24,32 +24,32 @@ from containers.prometheus_container import PrometheusContainer @step('a Prometheus server is set up') -def step_impl(context: MinifiTestContext): +def setup_prometheus_server(context: MinifiTestContext): context.containers["prometheus"] = PrometheusContainer(context) @step("a Prometheus server is set up with SSL") -def step_impl(context: MinifiTestContext): +def setup_prometheus_server_with_ssl(context: MinifiTestContext): context.containers["prometheus"] = PrometheusContainer(context, ssl=True) @then("\"{metric_class}\" are published to the Prometheus server in less than {timeout_seconds:d} seconds") @then("\"{metric_class}\" is published to the Prometheus server in less than {timeout_seconds:d} seconds") -def step_impl(context: MinifiTestContext, metric_class: str, timeout_seconds: int): +def verify_metric_class_published_to_prometheus(context: MinifiTestContext, metric_class: str, timeout_seconds: int): assert wait_for_condition( condition=lambda: context.containers["prometheus"].check_metric_class_on_prometheus(metric_class), timeout_seconds=timeout_seconds, bail_condition=lambda: context.containers["prometheus"].exited, context=context) @then("\"{metric_class}\" processor metric is published to the Prometheus server in less than {timeout_seconds:d} seconds for \"{processor_name}\" processor") -def step_impl(context: MinifiTestContext, metric_class: str, timeout_seconds: int, processor_name: str): +def verify_processor_metric_published_to_prometheus(context: MinifiTestContext, metric_class: str, timeout_seconds: int, processor_name: str): assert wait_for_condition( condition=lambda: context.containers["prometheus"].check_processor_metric_on_prometheus(metric_class, processor_name), timeout_seconds=timeout_seconds, bail_condition=lambda: context.containers["prometheus"].exited, context=context) @then("all Prometheus metric types are only defined once") -def step_impl(context: MinifiTestContext): +def verify_all_prometheus_metric_types_defined_once(context: MinifiTestContext): assert context.containers["prometheus"].check_all_metric_types_defined_once() @@ -62,12 +62,12 @@ def _enable_prometheus(context: MinifiTestContext): @given("Prometheus is enabled in MiNiFi") -def step_impl(context: MinifiTestContext): +def enable_prometheus_in_minifi(context: MinifiTestContext): _enable_prometheus(context) @given("Prometheus with SSL is enabled in MiNiFi") -def step_impl(context: MinifiTestContext): +def enable_prometheus_with_ssl_in_minifi(context: MinifiTestContext): _enable_prometheus(context) context.get_or_create_default_minifi_container().set_property("nifi.metrics.publisher.PrometheusMetricsPublisher.certificate", "/tmp/resources/minifi_merged_cert.crt") context.get_or_create_default_minifi_container().set_property("nifi.metrics.publisher.PrometheusMetricsPublisher.ca.certificate", "/tmp/resources/root_ca.crt") diff --git a/extensions/python/tests/features/steps/steps.py b/extensions/python/tests/features/steps/steps.py index 12f850e64..6b0dc4a47 100644 --- a/extensions/python/tests/features/steps/steps.py +++ b/extensions/python/tests/features/steps/steps.py @@ -94,12 +94,12 @@ RUN wget {parse_document_url} --directory-prefix={minifi_python_dir}/nifi_python @given("the example MiNiFi python processors are present") -def step_impl(context: MinifiTestContext): +def add_example_minifi_python_processors(context: MinifiTestContext): context.get_or_create_default_minifi_container().add_example_python_processors() @given("python with langchain is installed on the MiNiFi agent {install_mode}") -def step_impl(context, install_mode): +def install_python_with_langchain(context, install_mode): client: docker.DockerClient = docker.from_env() is_fhs = 'MINIFI_INSTALLATION_TYPE=FHS' in str(client.images.get(context.minifi_container_image).history()) minifi_python_venv_parent = '/var/lib/nifi-minifi-cpp' if is_fhs else '/opt/minifi/minifi-current' diff --git a/extensions/splunk/tests/features/steps/steps.py b/extensions/splunk/tests/features/steps/steps.py index e375fed91..c89a32955 100644 --- a/extensions/splunk/tests/features/steps/steps.py +++ b/extensions/splunk/tests/features/steps/steps.py @@ -24,23 +24,23 @@ from containers.splunk_container import SplunkContainer @step("a Splunk HEC is set up and running") -def step_impl(context: MinifiTestContext): +def setup_splunk_hec(context: MinifiTestContext): context.containers["splunk"] = SplunkContainer(context) assert context.containers["splunk"].deploy(context) assert context.containers["splunk"].enable_splunk_hec_indexer('splunk_hec_token') or context.containers["splunk"].log_app_output() @then('an event is registered in Splunk HEC with the content \"{content}\"') -def step_imp(context, content): +def verify_splunk_event_content(context, content): assert context.containers["splunk"].check_splunk_event(content) or log_due_to_failure(context) @then('an event is registered in Splunk HEC with the content \"{content}\" with \"{source}\" set as source and \"{source_type}\" set as sourcetype and \"{host}\" set as host') -def step_imp(context, content, source, source_type, host): +def verify_splunk_event_with_attributes(context, content, source, source_type, host): attr = {"source": source, "sourcetype": source_type, "host": host} assert context.containers["splunk"].check_splunk_event_with_attributes(content, attr) or log_due_to_failure(context) @step("SSL is enabled for the Splunk HEC and the SSL context service is set up for PutSplunkHTTP and QuerySplunkIndexingStatus") -def step_impl(context): +def enable_splunk_hec_ssl(context): assert context.containers["splunk"].enable_splunk_hec_ssl() or context.containers["splunk"].log_app_output() diff --git a/extensions/sql/tests/features/steps/steps.py b/extensions/sql/tests/features/steps/steps.py index ba509c427..92b95d22b 100644 --- a/extensions/sql/tests/features/steps/steps.py +++ b/extensions/sql/tests/features/steps/steps.py @@ -29,7 +29,7 @@ from containers.postgress_server_container import PostgresContainer @given("an ODBCService is setup up for {processor_name} with the name \"{service_name}\"") -def step_impl(context: MinifiTestContext, processor_name: str, service_name: str): +def setup_odbc_service_for_processor(context: MinifiTestContext, processor_name: str, service_name: str): odb_service = ControllerService(class_name="ODBCService", service_name=service_name) postgres_server_hostname = f"postgres-server-{context.scenario_id}" odb_service.add_property("Connection String", f"Driver={{PostgreSQL ANSI}};Server={postgres_server_hostname};Port=5432;Database=postgres;Uid=postgres;Pwd=password;") @@ -39,12 +39,12 @@ def step_impl(context: MinifiTestContext, processor_name: str, service_name: str @step("a PostgreSQL server is set up") -def step_impl(context): +def setup_postgresql_server(context): context.containers["postgres-server"] = PostgresContainer(context) @then('the query "{query}" returns {rows:d} rows in less than {timeout_str} on the PostgreSQL server') -def step_impl(context, query: str, rows: int, timeout_str: str): +def verify_postgresql_query_results(context, query: str, rows: int, timeout_str: str): timeout_seconds = humanfriendly.parse_timespan(timeout_str) postgres_container = context.containers["postgres-server"] assert isinstance(postgres_container, PostgresContainer) diff --git a/extensions/standard-processors/tests/features/steps/minifi_controller_steps.py b/extensions/standard-processors/tests/features/steps/minifi_controller_steps.py index e8d4fe4c6..f4dca56f8 100644 --- a/extensions/standard-processors/tests/features/steps/minifi_controller_steps.py +++ b/extensions/standard-processors/tests/features/steps/minifi_controller_steps.py @@ -21,47 +21,47 @@ from minifi_behave.core.minifi_test_context import MinifiTestContext @given('controller socket properties are set up') -def step_impl(context: MinifiTestContext): +def setup_controller_socket_properties(context: MinifiTestContext): context.get_or_create_default_minifi_container().controller.set_controller_socket_properties() @when('MiNiFi config is updated through MiNiFi controller') -def step_impl(context: MinifiTestContext): +def update_minifi_config_via_controller(context: MinifiTestContext): context.get_or_create_default_minifi_container().controller.update_flow_config_through_controller() @then('the updated config is persisted') -def step_impl(context: MinifiTestContext): +def verify_updated_config_is_persisted(context: MinifiTestContext): assert context.get_or_create_default_minifi_container().controller.updated_config_is_persisted() @when('the {component} component is stopped through MiNiFi controller') -def step_impl(context: MinifiTestContext, component: str): +def stop_component_via_controller(context: MinifiTestContext, component: str): context.get_or_create_default_minifi_container().controller.stop_component_through_controller(component) @when('the {component} component is started through MiNiFi controller') -def step_impl(context: MinifiTestContext, component: str): +def start_component_via_controller(context: MinifiTestContext, component: str): context.get_or_create_default_minifi_container().controller.start_component_through_controller(component) @then('the {component} component is not running') -def step_impl(context: MinifiTestContext, component: str): +def verify_component_not_running(context: MinifiTestContext, component: str): assert not context.get_or_create_default_minifi_container().controller.is_component_running(component) @then('the {component} component is running') -def step_impl(context: MinifiTestContext, component: str): +def verify_component_is_running(context: MinifiTestContext, component: str): assert context.get_or_create_default_minifi_container().controller.is_component_running(component) @then('connection \"{connection}\" can be seen through MiNiFi controller') -def step_impl(context: MinifiTestContext, connection: str): +def verify_connection_seen_via_controller(context: MinifiTestContext, connection: str): assert context.get_or_create_default_minifi_container().controller.connection_found_through_controller(connection) @then('{connection_count:d} connections can be seen full through MiNiFi controller') -def step_impl(context: MinifiTestContext, connection_count: int): +def verify_full_connection_count(context: MinifiTestContext, connection_count: int): assert context.get_or_create_default_minifi_container().controller.get_full_connection_count() == connection_count @@ -71,7 +71,7 @@ def check_connection_size_through_controller(context: MinifiTestContext, connect @then('connection \"{connection}\" has {size:d} size and {max_size:d} max size through MiNiFi controller') -def step_impl(context: MinifiTestContext, connection: str, size: int, max_size: int): +def verify_connection_size_via_controller(context: MinifiTestContext, connection: str, size: int, max_size: int): assert check_connection_size_through_controller(context, connection, size, max_size) @@ -82,10 +82,10 @@ def manifest_can_be_retrieved_through_minifi_controller(context: MinifiTestConte @then('manifest can be retrieved through MiNiFi controller') -def step_impl(context: MinifiTestContext): +def verify_manifest_retrieval_via_controller(context: MinifiTestContext): assert manifest_can_be_retrieved_through_minifi_controller(context) @then('debug bundle can be retrieved through MiNiFi controller') -def step_impl(context: MinifiTestContext): +def verify_debug_bundle_retrieval_via_controller(context: MinifiTestContext): assert context.get_or_create_default_minifi_container().controller.create_debug_bundle() diff --git a/extensions/standard-processors/tests/features/steps/steps.py b/extensions/standard-processors/tests/features/steps/steps.py index bed3c07e3..472d1a926 100644 --- a/extensions/standard-processors/tests/features/steps/steps.py +++ b/extensions/standard-processors/tests/features/steps/steps.py @@ -33,33 +33,33 @@ from minifi_c2_server_container import MinifiC2Server @step("a Syslog client with TCP protocol is setup to send logs to minifi") -def step_impl(context: MinifiTestContext): +def setup_syslog_tcp_client(context: MinifiTestContext): context.containers["syslog-tcp"] = SyslogContainer("tcp", context) @step("a Syslog client with UDP protocol is setup to send logs to minifi") -def step_impl(context: MinifiTestContext): +def setup_syslog_udp_client(context: MinifiTestContext): context.containers["syslog-udp"] = SyslogContainer("udp", context) @step('there is an accessible PLC with modbus enabled') -def step_impl(context: MinifiTestContext): +def setup_accessible_plc_with_modbus(context: MinifiTestContext): modbus_container = context.containers["diag-slave-tcp"] = DiagSlave(context) assert modbus_container.deploy(context) @step('PLC register has been set with {modbus_cmd} command') -def step_impl(context: MinifiTestContext, modbus_cmd: str): +def set_plc_register_with_command(context: MinifiTestContext, modbus_cmd: str): assert context.containers["diag-slave-tcp"].set_value_on_plc_with_modbus(modbus_cmd) or context.containers["diag-slave-tcp"].log_app_output() @step('a TCP client is set up to send a test TCP message to minifi') -def step_impl(context: MinifiTestContext): +def setup_tcp_client(context: MinifiTestContext): context.containers["tcp-client"] = TcpClientContainer(context) @given("C2 is enabled in MiNiFi") -def step_impl(context: MinifiTestContext): +def enable_c2_in_minifi(context: MinifiTestContext): context.get_or_create_default_minifi_container().set_property("nifi.c2.enable", "true") context.get_or_create_default_minifi_container().set_property("nifi.c2.rest.url", f"http://minifi-c2-server-{context.scenario_id}:10090/c2/config/heartbeat") context.get_or_create_default_minifi_container().set_property("nifi.c2.rest.url.ack", f"http://minifi-c2-server-{context.scenario_id}:10090/c2/config/acknowledge") @@ -71,7 +71,7 @@ def step_impl(context: MinifiTestContext): @given("ssl properties are set up for MiNiFi C2 server") -def step_impl(context: MinifiTestContext): +def setup_ssl_properties_for_c2(context: MinifiTestContext): context.get_or_create_default_minifi_container().set_property("nifi.c2.enable", "true") context.get_or_create_default_minifi_container().set_property("nifi.c2.rest.url", f"https://minifi-c2-server-{context.scenario_id}:10090/c2/config/heartbeat") context.get_or_create_default_minifi_container().set_property("nifi.c2.rest.url.ack", f"https://minifi-c2-server-{context.scenario_id}:10090/c2/config/acknowledge") @@ -84,24 +84,24 @@ def step_impl(context: MinifiTestContext): @given("a MiNiFi C2 server is set up") -def step_impl(context: MinifiTestContext): +def setup_minifi_c2_server(context: MinifiTestContext): context.containers["minifi-c2-server"] = MinifiC2Server(context) @given("a MiNiFi C2 server is set up with SSL") -def step_impl(context: MinifiTestContext): +def setup_minifi_c2_server_with_ssl(context: MinifiTestContext): context.containers["minifi-c2-server"] = MinifiC2Server(context, ssl=True) @given("a MiNiFi C2 server is started") -def step_impl(context: MinifiTestContext): +def start_minifi_c2_server(context: MinifiTestContext): context.containers["minifi-c2-server"] = MinifiC2Server(context) assert context.containers["minifi-c2-server"].deploy(context) @then("the MiNiFi C2 server logs contain the following message: \"{log_message}\" in less than {duration}") -def step_impl(context: MinifiTestContext, log_message: str, duration: str): +def verify_c2_server_logs_contain_message(context: MinifiTestContext, log_message: str, duration: str): duration_seconds = humanfriendly.parse_timespan(duration) assert wait_for_condition(condition=lambda: log_message in context.containers["minifi-c2-server"].get_logs(), timeout_seconds=duration_seconds, bail_condition=lambda: context.containers["minifi-c2-server"].exited, - context=context) + context=context) \ No newline at end of file
