Skip to content

Commit 0d4a898

Browse files
committed
MINIFICPP-2689 Move Splunk tests to modular docker tests
- Add more logging to the PutSpunkHTTP processor - Fail if returned status code is not 0
1 parent 3ecc14d commit 0d4a898

File tree

18 files changed

+263
-291
lines changed

18 files changed

+263
-291
lines changed

behave_framework/src/minifi_test_framework/minifi/flow_definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def add_processor(self, processor: Processor):
3939
def get_processor(self, processor_name: str) -> Processor | None:
4040
return next((proc for proc in self.processors if proc.name == processor_name), None)
4141

42+
def get_controller_service(self, controller_service_name: str) -> ControllerService | None:
43+
return next((controller for controller in self.controller_services if controller.name == controller_service_name), None)
44+
4245
def get_parameter_context(self, parameter_context_name: str) -> ParameterContext | None:
4346
return next((parameter_context for parameter_context in self.parameter_contexts if
4447
parameter_context.name == parameter_context_name), None)

behave_framework/src/minifi_test_framework/steps/flow_building_steps.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
import logging
19+
import uuid
1920
from behave import given, step
2021

2122
from minifi_test_framework.containers.directory import Directory
@@ -246,8 +247,18 @@ def step_impl(context: MinifiTestContext, property_name: str, processor_name: st
246247
processor.add_property(property_name, filtering)
247248

248249

250+
@given("the \"{property_name}\" properties of the {processor_name_one} and {processor_name_two} processors are set to the same random guid")
251+
def step_impl(context, property_name, processor_name_one, processor_name_two):
252+
uuid_str = str(uuid.uuid4())
253+
context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name_one).add_property(property_name, uuid_str)
254+
context.get_or_create_default_minifi_container().flow_definition.get_processor(processor_name_two).add_property(property_name, uuid_str)
255+
256+
249257
# TLS
250258
def add_ssl_context_service_for_minifi(context: MinifiTestContext, cert_name: str):
259+
ssl_context_service = context.get_or_create_default_minifi_container().flow_definition.get_controller_service("SSLContextService")
260+
if ssl_context_service is not None:
261+
return
251262
controller_service = ControllerService(class_name="SSLContextService", service_name="SSLContextService")
252263
controller_service.add_property("Client Certificate", f"/tmp/resources/{cert_name}.crt")
253264
controller_service.add_property("Private Key", f"/tmp/resources/{cert_name}.key")

docker/RunBehaveTests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,5 @@ exec \
202202
"${docker_dir}/../extensions/opc/tests/features" \
203203
"${docker_dir}/../extensions/kafka/tests/features" \
204204
"${docker_dir}/../extensions/couchbase/tests/features" \
205-
"${docker_dir}/../extensions/elasticsearch/tests/features"
205+
"${docker_dir}/../extensions/elasticsearch/tests/features" \
206+
"${docker_dir}/../extensions/splunk/tests/features"

docker/test/integration/cluster/ContainerStore.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from .containers.HttpProxyContainer import HttpProxyContainer
2626
from .containers.PostgreSQLServerContainer import PostgreSQLServerContainer
2727
from .containers.MqttBrokerContainer import MqttBrokerContainer
28-
from .containers.SplunkContainer import SplunkContainer
2928
from .containers.SyslogUdpClientContainer import SyslogUdpClientContainer
3029
from .containers.SyslogTcpClientContainer import SyslogTcpClientContainer
3130
from .containers.MinifiAsPodInKubernetesCluster import MinifiAsPodInKubernetesCluster
@@ -169,14 +168,6 @@ def acquire_container(self, context, container_name: str, engine='minifi-cpp', c
169168
network=self.network,
170169
image_store=self.image_store,
171170
command=command))
172-
elif engine == 'splunk':
173-
return self.containers.setdefault(container_name,
174-
SplunkContainer(feature_context=feature_context,
175-
name=container_name,
176-
vols=self.vols,
177-
network=self.network,
178-
image_store=self.image_store,
179-
command=command))
180171
elif engine == "syslog-udp-client":
181172
return self.containers.setdefault(container_name,
182173
SyslogUdpClientContainer(

docker/test/integration/cluster/DockerTestCluster.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from .checkers.GcsChecker import GcsChecker
3232
from .checkers.PostgresChecker import PostgresChecker
3333
from .checkers.PrometheusChecker import PrometheusChecker
34-
from .checkers.SplunkChecker import SplunkChecker
3534
from .checkers.GrafanaLokiChecker import GrafanaLokiChecker
3635
from .checkers.ModbusChecker import ModbusChecker
3736
from .checkers.MqttHelper import MqttHelper
@@ -48,7 +47,6 @@ def __init__(self, context, feature_id):
4847
self.azure_checker = AzureChecker(self.container_communicator)
4948
self.gcs_checker = GcsChecker(self.container_communicator)
5049
self.postgres_checker = PostgresChecker(self.container_communicator)
51-
self.splunk_checker = SplunkChecker(self.container_communicator)
5250
self.prometheus_checker = PrometheusChecker()
5351
self.grafana_loki_checker = GrafanaLokiChecker()
5452
self.minifi_controller_executor = MinifiControllerExecutor(self.container_communicator)
@@ -236,22 +234,6 @@ def check_azure_blob_and_snapshot_count(self, blob_and_snapshot_count, timeout_s
236234
def check_azure_blob_storage_is_empty(self, timeout_seconds):
237235
return self.azure_checker.check_azure_blob_storage_is_empty(timeout_seconds)
238236

239-
def check_splunk_event(self, container_name, query):
240-
container_name = self.container_store.get_container_name_with_postfix(container_name)
241-
return self.splunk_checker.check_splunk_event(container_name, query)
242-
243-
def check_splunk_event_with_attributes(self, container_name, query, attributes):
244-
container_name = self.container_store.get_container_name_with_postfix(container_name)
245-
return self.splunk_checker.check_splunk_event_with_attributes(container_name, query, attributes)
246-
247-
def enable_splunk_hec_indexer(self, container_name, hec_name):
248-
container_name = self.container_store.get_container_name_with_postfix(container_name)
249-
return self.splunk_checker.enable_splunk_hec_indexer(container_name, hec_name)
250-
251-
def enable_splunk_hec_ssl(self, container_name, splunk_cert_pem, splunk_key_pem, root_ca_cert_pem):
252-
container_name = self.container_store.get_container_name_with_postfix(container_name)
253-
return self.splunk_checker.enable_splunk_hec_ssl(container_name, splunk_cert_pem, splunk_key_pem, root_ca_cert_pem)
254-
255237
def check_google_cloud_storage(self, gcs_container_name, content):
256238
gcs_container_name = self.container_store.get_container_name_with_postfix(gcs_container_name)
257239
return self.gcs_checker.check_google_cloud_storage(gcs_container_name, content)

docker/test/integration/cluster/ImageStore.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ def get_image(self, container_engine):
6565
image = self.__build_postgresql_server_image()
6666
elif container_engine == "mqtt-broker":
6767
image = self.__build_mqtt_broker_image()
68-
elif container_engine == "splunk":
69-
image = self.__build_splunk_image()
7068
elif container_engine == "kinesis-server":
7169
image = self.__build_kinesis_image()
7270
elif container_engine == "reverse-proxy":
@@ -295,9 +293,6 @@ def __build_mqtt_broker_image(self):
295293
def __build_kinesis_image(self):
296294
return self.__build_image_by_path(self.test_dir + "/resources/kinesis-mock", 'kinesis-server')
297295

298-
def __build_splunk_image(self):
299-
return self.__build_image_by_path(self.test_dir + "/resources/splunk-hec", 'minifi-splunk')
300-
301296
def __build_reverse_proxy_image(self):
302297
return self.__build_image_by_path(self.test_dir + "/resources/reverse-proxy", 'reverse-proxy')
303298

docker/test/integration/cluster/checkers/SplunkChecker.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

docker/test/integration/cluster/containers/SplunkContainer.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

docker/test/integration/features/MiNiFi_integration_test_driver.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ def acquire_container(self, context, name, engine='minifi-cpp', command=None):
6464
def acquire_transient_minifi(self, context, name, engine='minifi-cpp'):
6565
return self.cluster.acquire_transient_minifi(context=context, name=name, engine=engine)
6666

67-
def start_splunk(self, context):
68-
self.cluster.acquire_container(context=context, name='splunk', engine='splunk')
69-
self.cluster.deploy_container(name='splunk')
70-
assert self.cluster.wait_for_container_startup_to_finish('splunk') or self.cluster.log_app_output()
71-
assert self.cluster.enable_splunk_hec_indexer('splunk', 'splunk_hec_token') or self.cluster.log_app_output()
72-
7367
def start_minifi_c2_server(self, context):
7468
self.cluster.acquire_container(context=context, name="minifi-c2-server", engine="minifi-c2-server")
7569
self.cluster.deploy_container('minifi-c2-server')
@@ -303,12 +297,6 @@ def check_http_proxy_access(self, http_proxy_container_name, url):
303297
def check_azure_storage_server_data(self, azure_container_name, object_data):
304298
assert self.cluster.check_azure_storage_server_data(azure_container_name, object_data) or self.cluster.log_app_output()
305299

306-
def check_splunk_event(self, splunk_container_name, query):
307-
assert self.cluster.check_splunk_event(splunk_container_name, query) or self.cluster.log_app_output()
308-
309-
def check_splunk_event_with_attributes(self, splunk_container_name, query, attributes):
310-
assert self.cluster.check_splunk_event_with_attributes(splunk_container_name, query, attributes) or self.cluster.log_app_output()
311-
312300
def check_google_cloud_storage(self, gcs_container_name, content):
313301
assert self.cluster.check_google_cloud_storage(gcs_container_name, content) or self.cluster.log_app_output()
314302

@@ -384,9 +372,6 @@ def enable_prometheus_in_minifi(self):
384372
def enable_prometheus_with_ssl_in_minifi(self):
385373
self.cluster.enable_prometheus_with_ssl_in_minifi()
386374

387-
def enable_splunk_hec_ssl(self, container_name, splunk_cert_pem, splunk_key_pem, root_ca_cert_pem):
388-
self.cluster.enable_splunk_hec_ssl(container_name, splunk_cert_pem, splunk_key_pem, root_ca_cert_pem)
389-
390375
def enable_sql_in_minifi(self):
391376
self.cluster.enable_sql_in_minifi()
392377

0 commit comments

Comments
 (0)