Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

import logging
import os
from pathlib import Path
Expand Down Expand Up @@ -42,6 +41,8 @@ def __init__(self, container_name: str, test_context: MinifiTestContext):
self.files.append(File("/tmp/resources/root_ca.crt", crypto.dump_certificate(type=crypto.FILETYPE_PEM, cert=test_context.root_ca_cert)))
self.files.append(File("/tmp/resources/minifi_client.crt", crypto.dump_certificate(type=crypto.FILETYPE_PEM, cert=minifi_client_cert)))
self.files.append(File("/tmp/resources/minifi_client.key", crypto.dump_privatekey(type=crypto.FILETYPE_PEM, pkey=minifi_client_key)))
self.files.append(File("/tmp/resources/minifi_merged_cert.crt",
crypto.dump_certificate(type=crypto.FILETYPE_PEM, cert=minifi_client_cert) + crypto.dump_privatekey(type=crypto.FILETYPE_PEM, pkey=minifi_client_key)))

clientuser_cert, clientuser_key = make_client_cert("clientuser", ca_cert=test_context.root_ca_cert, ca_key=test_context.root_ca_key)
self.files.append(File("/tmp/resources/clientuser.crt", crypto.dump_certificate(type=crypto.FILETYPE_PEM, cert=clientuser_cert)))
Expand Down Expand Up @@ -117,6 +118,22 @@ def enable_c2_with_ssl(self):
self.properties["nifi.c2.agent.class"] = "minifi-test-class"
self.properties["nifi.c2.agent.identifier"] = "minifi-test-id"

def enable_log_metrics_publisher(self):
self.properties["nifi.metrics.publisher.LogMetricsPublisher.metrics"] = "RepositoryMetrics"
self.properties["nifi.metrics.publisher.LogMetricsPublisher.logging.interval"] = "1s"
self.properties["nifi.metrics.publisher.class"] = "LogMetricsPublisher"

def enable_prometheus(self):
self.properties["nifi.metrics.publisher.agent.identifier"] = "Agent1"
self.properties["nifi.metrics.publisher.PrometheusMetricsPublisher.port"] = "9936"
self.properties["nifi.metrics.publisher.PrometheusMetricsPublisher.metrics"] = "RepositoryMetrics,QueueMetrics,PutFileMetrics,processorMetrics/Get.*,FlowInformation,DeviceInfoNode,AgentStatus"
self.properties["nifi.metrics.publisher.class"] = "PrometheusMetricsPublisher"

def enable_prometheus_with_ssl(self):
self.enable_prometheus()
self.properties["nifi.metrics.publisher.PrometheusMetricsPublisher.certificate"] = "/tmp/resources/minifi_merged_cert.crt"
self.properties["nifi.metrics.publisher.PrometheusMetricsPublisher.ca.certificate"] = "/tmp/resources/root_ca.crt"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since prometheus is an extension (although a core one) I think it would be better to have these in the prometheus steps (calling set properties from there) and keep these domain speicifc function out of the framework

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, moved it in d77b9ed

def fetch_flow_config_from_flow_url(self):
self.properties["nifi.c2.flow.url"] = f"http://minifi-c2-server-{self.scenario_id}:10090/c2/config?class=minifi-test-class"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#


import time
import re

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

from behave import step
from behave import step, given

from minifi_test_framework.core.minifi_test_context import MinifiTestContext

Expand All @@ -26,12 +26,41 @@ def step_impl(context: MinifiTestContext, config_key: str, config_value: str):


@step("log metrics publisher is enabled in MiNiFi")
def step_impl(context):
context.get_or_create_default_minifi_container().set_property("nifi.metrics.publisher.LogMetricsPublisher.metrics", "RepositoryMetrics")
context.get_or_create_default_minifi_container().set_property("nifi.metrics.publisher.LogMetricsPublisher.logging.interval", "1s")
context.get_or_create_default_minifi_container().set_property("nifi.metrics.publisher.class", "LogMetricsPublisher")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_log_metrics_publisher()


@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):
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):
context.get_or_create_default_minifi_container().enable_openssl_fips_mode()


@given("C2 is enabled in MiNiFi")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_c2()


@given("flow configuration path is set up in flow url property")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().fetch_flow_config_from_flow_url()


@given("ssl properties are set up for MiNiFi C2 server")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_c2_with_ssl()
context.get_or_create_default_minifi_container().set_up_ssl_proprties()


@given("Prometheus is enabled in MiNiFi")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_prometheus()


@given("Prometheus with SSL is enabled in MiNiFi")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_prometheus_with_ssl()
21 changes: 0 additions & 21 deletions behave_framework/src/minifi_test_framework/steps/core_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ def step_impl(context: MinifiTestContext, container_name: str):
context.get_or_create_minifi_container(container_name).kill()


@given("OpenSSL FIPS mode is enabled in MiNiFi")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_openssl_fips_mode()


@step("the http proxy server is set up")
def step_impl(context: MinifiTestContext):
context.containers["http-proxy"] = HttpProxy(context)
Expand All @@ -152,22 +147,6 @@ def step_impl(context: MinifiTestContext):
context.containers["nifi"] = NifiContainer(context)


@given("C2 is enabled in MiNiFi")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_c2()


@given("flow configuration path is set up in flow url property")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().fetch_flow_config_from_flow_url()


@given("ssl properties are set up for MiNiFi C2 server")
def step_impl(context: MinifiTestContext):
context.get_or_create_default_minifi_container().enable_c2_with_ssl()
context.get_or_create_default_minifi_container().set_up_ssl_proprties()


@given("a MiNiFi C2 server is set up")
def step_impl(context: MinifiTestContext):
context.containers["minifi-c2-server"] = MinifiC2Server(context)
Expand Down
3 changes: 2 additions & 1 deletion docker/RunBehaveTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,5 @@ exec \
"${docker_dir}/../extensions/grafana-loki/tests/features" \
"${docker_dir}/../extensions/lua/tests/features/" \
"${docker_dir}/../extensions/civetweb/tests/features/" \
"${docker_dir}/../extensions/mqtt/tests/features/"
"${docker_dir}/../extensions/mqtt/tests/features/" \
"${docker_dir}/../extensions/prometheus/tests/features/"
1 change: 0 additions & 1 deletion docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ m2crypto==0.46.2
watchdog==6.0.0
pyopenssl==25.0.0
azure-storage-blob==12.24.1
prometheus-api-client==0.5.5
humanfriendly==10.0
requests<2.29 # https://github.com/docker/docker-py/issues/3113
24 changes: 0 additions & 24 deletions docker/test/integration/cluster/ContainerStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from .containers.SyslogUdpClientContainer import SyslogUdpClientContainer
from .containers.SyslogTcpClientContainer import SyslogTcpClientContainer
from .containers.MinifiAsPodInKubernetesCluster import MinifiAsPodInKubernetesCluster
from .containers.PrometheusContainer import PrometheusContainer
from .FeatureContext import FeatureContext


Expand Down Expand Up @@ -145,23 +144,6 @@ def acquire_container(self, context, container_name: str, engine='minifi-cpp', c
network=self.network,
image_store=self.image_store,
command=command))
elif engine == "prometheus":
return self.containers.setdefault(container_name,
PrometheusContainer(feature_context=feature_context,
name=container_name,
vols=self.vols,
network=self.network,
image_store=self.image_store,
command=command))
elif engine == "prometheus-ssl":
return self.containers.setdefault(container_name,
PrometheusContainer(feature_context=feature_context,
name=container_name,
vols=self.vols,
network=self.network,
image_store=self.image_store,
command=command,
ssl=True))
else:
raise Exception('invalid flow engine: \'%s\'' % engine)

Expand Down Expand Up @@ -206,12 +188,6 @@ def enable_provenance_repository_in_minifi(self):
def set_ssl_context_properties_in_minifi(self):
self.minifi_options.set_ssl_context_properties = True

def enable_prometheus_in_minifi(self):
self.minifi_options.enable_prometheus = True

def enable_prometheus_with_ssl_in_minifi(self):
self.minifi_options.enable_prometheus_with_ssl = True

def enable_sql_in_minifi(self):
self.minifi_options.enable_sql = True

Expand Down
17 changes: 0 additions & 17 deletions docker/test/integration/cluster/DockerTestCluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from .DockerCommunicator import DockerCommunicator
from .checkers.AzureChecker import AzureChecker
from .checkers.PostgresChecker import PostgresChecker
from .checkers.PrometheusChecker import PrometheusChecker
from .checkers.ModbusChecker import ModbusChecker
from utils import get_peak_memory_usage, get_minifi_pid, get_memory_usage

Expand All @@ -34,7 +33,6 @@ def __init__(self, context, feature_id):
self.container_store = ContainerStore(self.container_communicator.create_docker_network(feature_id), context.image_store, context.kubernetes_proxy, feature_id=feature_id)
self.azure_checker = AzureChecker(self.container_communicator)
self.postgres_checker = PostgresChecker(self.container_communicator)
self.prometheus_checker = PrometheusChecker()
self.modbus_checker = ModbusChecker(self.container_communicator)

def cleanup(self):
Expand Down Expand Up @@ -79,12 +77,6 @@ def fetch_flow_config_from_c2_url_in_minifi(self):
def set_ssl_context_properties_in_minifi(self):
self.container_store.set_ssl_context_properties_in_minifi()

def enable_prometheus_in_minifi(self):
self.container_store.enable_prometheus_in_minifi()

def enable_prometheus_with_ssl_in_minifi(self):
self.container_store.enable_prometheus_with_ssl_in_minifi()

def enable_openssl_fips_mode_in_minifi(self):
self.container_store.enable_openssl_fips_mode_in_minifi()

Expand Down Expand Up @@ -196,15 +188,6 @@ def check_query_results(self, postgresql_container_name, query, number_of_rows,
def segfault_happened(self):
return self.segfault

def wait_for_metric_class_on_prometheus(self, metric_class, timeout_seconds):
return self.prometheus_checker.wait_for_metric_class_on_prometheus(metric_class, timeout_seconds)

def wait_for_processor_metric_on_prometheus(self, metric_class, timeout_seconds, processor_name):
return self.prometheus_checker.wait_for_processor_metric_on_prometheus(metric_class, timeout_seconds, processor_name)

def verify_all_metric_types_are_defined_once(self):
return self.prometheus_checker.verify_all_metric_types_are_defined_once()

def check_minifi_log_matches_regex(self, regex, timeout_seconds=60, count=1):
for container_name in self.container_store.get_container_names("minifi-cpp"):
line_found = self.wait_for_app_logs_regex(container_name, regex, timeout_seconds, count)
Expand Down
Loading
Loading