Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -24,14 +24,15 @@


class DockerImageBuilder:
def __init__(self, image_tag: str, dockerfile_content: str | None = None, build_context_path: str | None = None):
def __init__(self, image_tag: str, dockerfile_content: str | None = None, files_on_context: dict[str, bytes] | None = None, build_context_path: str | None = None):
if not dockerfile_content and not build_context_path:
raise ValueError("Either 'dockerfile_content' or 'build_context_path' must be provided.")
if dockerfile_content and build_context_path:
raise ValueError("Provide either 'dockerfile_content' or 'build_context_path', not both.")

self.image_tag: str = image_tag
self.dockerfile_content: str | None = dockerfile_content
self.files_on_context: dict[str, str] | None = files_on_context
self.build_context_path: str | None = build_context_path
self.client = docker.from_env()
self.image: Image | None = None
Expand All @@ -46,6 +47,12 @@ def build(self) -> Image:
with open(dockerfile_path, 'w') as f:
f.write(self.dockerfile_content)

if self.files_on_context:
for filename, content in self.files_on_context.items():
file_path = os.path.join(context_path, filename)
with open(file_path, 'wb') as f:
f.write(content)

logging.info(f"Building Docker image '{self.image_tag}' from context '{context_path}'...")
try:
self.image, build_logs = self.client.images.build(path=context_path, tag=self.image_tag, rm=True, forcerm=True)
Expand Down
3 changes: 2 additions & 1 deletion docker/RunBehaveTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ exec \
"${docker_dir}/../extensions/couchbase/tests/features" \
"${docker_dir}/../extensions/elasticsearch/tests/features" \
"${docker_dir}/../extensions/splunk/tests/features" \
"${docker_dir}/../extensions/gcp/tests/features"
"${docker_dir}/../extensions/gcp/tests/features" \
"${docker_dir}/../extensions/grafana-loki/tests/features"
27 changes: 0 additions & 27 deletions docker/test/integration/cluster/ContainerStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@
from .containers.MinifiAsPodInKubernetesCluster import MinifiAsPodInKubernetesCluster
from .containers.PrometheusContainer import PrometheusContainer
from .containers.MinifiC2ServerContainer import MinifiC2ServerContainer
from .containers.GrafanaLokiContainer import GrafanaLokiContainer
from .containers.GrafanaLokiContainer import GrafanaLokiOptions
from .containers.ReverseProxyContainer import ReverseProxyContainer
from .FeatureContext import FeatureContext


class ContainerStore:
def __init__(self, network, image_store, kubernetes_proxy, feature_id):
self.feature_id = feature_id
self.minifi_options = MinifiOptions()
self.grafana_loki_options = GrafanaLokiOptions()
self.containers = {}
self.data_directories = {}
self.network = network
Expand Down Expand Up @@ -212,23 +208,6 @@ def acquire_container(self, context, container_name: str, engine='minifi-cpp', c
image_store=self.image_store,
command=command,
ssl=True))
elif engine == "grafana-loki-server":
return self.containers.setdefault(container_name,
GrafanaLokiContainer(feature_context=feature_context,
name=container_name,
vols=self.vols,
network=self.network,
image_store=self.image_store,
options=self.grafana_loki_options,
command=command))
elif engine == "reverse-proxy":
return self.containers.setdefault(container_name,
ReverseProxyContainer(feature_context=feature_context,
name=container_name,
vols=self.vols,
network=self.network,
image_store=self.image_store,
command=command))
else:
raise Exception('invalid flow engine: \'%s\'' % engine)

Expand Down Expand Up @@ -345,12 +324,6 @@ def get_app_log(self, container_name):
def get_container_names(self, engine=None):
return [key for key in self.containers.keys() if not engine or self.containers[key].get_engine() == engine]

def enable_ssl_in_grafana_loki(self):
self.grafana_loki_options.enable_ssl = True

def enable_multi_tenancy_in_grafana_loki(self):
self.grafana_loki_options.enable_multi_tenancy = True

def enable_ssl_in_nifi(self):
self.nifi_options.use_ssl = True

Expand Down
12 changes: 0 additions & 12 deletions docker/test/integration/cluster/DockerTestCluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import gzip
import shutil
from typing import List

from .LogSource import LogSource
from .ContainerStore import ContainerStore
Expand All @@ -30,7 +29,6 @@
from .checkers.AzureChecker import AzureChecker
from .checkers.PostgresChecker import PostgresChecker
from .checkers.PrometheusChecker import PrometheusChecker
from .checkers.GrafanaLokiChecker import GrafanaLokiChecker
from .checkers.ModbusChecker import ModbusChecker
from .checkers.MqttHelper import MqttHelper
from utils import get_peak_memory_usage, get_minifi_pid, get_memory_usage, retry_check
Expand All @@ -46,7 +44,6 @@ def __init__(self, context, feature_id):
self.azure_checker = AzureChecker(self.container_communicator)
self.postgres_checker = PostgresChecker(self.container_communicator)
self.prometheus_checker = PrometheusChecker()
self.grafana_loki_checker = GrafanaLokiChecker()
self.minifi_controller_executor = MinifiControllerExecutor(self.container_communicator)
self.modbus_checker = ModbusChecker(self.container_communicator)
self.mqtt_helper = MqttHelper()
Expand Down Expand Up @@ -108,12 +105,6 @@ def disable_openssl_fips_mode_in_minifi(self):
def enable_sql_in_minifi(self):
self.container_store.enable_sql_in_minifi()

def enable_ssl_in_grafana_loki(self):
self.container_store.enable_ssl_in_grafana_loki()

def enable_multi_tenancy_in_grafana_loki(self):
self.container_store.enable_multi_tenancy_in_grafana_loki()

def use_nifi_python_processors_with_system_python_packages_installed_in_minifi(self):
self.container_store.use_nifi_python_processors_with_system_python_packages_installed_in_minifi()

Expand Down Expand Up @@ -386,9 +377,6 @@ def debug_bundle_can_be_retrieved_through_minifi_controller(self, container_name

return True

def wait_for_lines_on_grafana_loki(self, lines: List[str], timeout_seconds: int, ssl: bool, tenant_id: str):
return self.grafana_loki_checker.wait_for_lines_on_grafana_loki(lines, timeout_seconds, ssl, tenant_id)

def set_value_on_plc_with_modbus(self, container_name, modbus_cmd):
return self.modbus_checker.set_value_on_plc_with_modbus(container_name, modbus_cmd)

Expand Down
5 changes: 0 additions & 5 deletions docker/test/integration/cluster/ImageStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def get_image(self, container_engine):
image = self.__build_mqtt_broker_image()
elif container_engine == "kinesis-server":
image = self.__build_kinesis_image()
elif container_engine == "reverse-proxy":
image = self.__build_reverse_proxy_image()
else:
raise Exception("There is no associated image for " + container_engine)

Expand Down Expand Up @@ -293,9 +291,6 @@ def __build_mqtt_broker_image(self):
def __build_kinesis_image(self):
return self.__build_image_by_path(self.test_dir + "/resources/kinesis-mock", 'kinesis-server')

def __build_reverse_proxy_image(self):
return self.__build_image_by_path(self.test_dir + "/resources/reverse-proxy", 'reverse-proxy')

def __build_image(self, dockerfile, context_files=[]):
conf_dockerfile_buffer = BytesIO()
docker_context_buffer = BytesIO()
Expand Down
54 changes: 0 additions & 54 deletions docker/test/integration/cluster/checkers/GrafanaLokiChecker.py

This file was deleted.

176 changes: 0 additions & 176 deletions docker/test/integration/cluster/containers/GrafanaLokiContainer.py

This file was deleted.

Loading
Loading