Skip to content

Commit

Permalink
Remove unneeded SSL config from Prometheus server
Browse files Browse the repository at this point in the history
  • Loading branch information
lordgamez committed Jul 14, 2023
1 parent bdb0ef9 commit f38c20c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 49 deletions.
3 changes: 0 additions & 3 deletions docker/test/integration/cluster/DockerTestCluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,3 @@ def check_connection_size_through_controller(self, connection: str, size: int, m
def manifest_can_be_retrieved_through_minifi_controller(self, container_name: str) -> bool:
manifest = self.minifi_controller_executor.get_manifest(container_name)
return '"agentManifest": {' in manifest and '"componentManifest": {' in manifest and '"agentType": "cpp"' in manifest

def enable_ssl_in_prometheus_checker(self):
self.prometheus_checker.enable_ssl()
15 changes: 3 additions & 12 deletions docker/test/integration/cluster/checkers/PrometheusChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@

class PrometheusChecker:
def __init__(self):
self.use_ssl = False

def enable_ssl(self):
self.use_ssl = True

def _getClient(self):
if self.use_ssl:
return PrometheusConnect(url="https://localhost:9090", disable_ssl=True)
else:
return PrometheusConnect(url="http://localhost:9090", disable_ssl=True)
self.prometheus_client = PrometheusConnect(url="http://localhost:9090", disable_ssl=True)

def wait_for_metric_class_on_prometheus(self, metric_class, timeout_seconds):
return wait_for(lambda: self.verify_metric_class(metric_class), timeout_seconds)
Expand Down Expand Up @@ -110,14 +101,14 @@ def verify_agent_status_metrics(self):
def verify_metric_exists(self, metric_name, metric_class, labels={}):
labels['metric_class'] = metric_class
labels['agent_identifier'] = "Agent1"
return len(self._getClient().get_current_metric_value(metric_name=metric_name, label_config=labels)) > 0
return len(self.prometheus_client.get_current_metric_value(metric_name=metric_name, label_config=labels)) > 0

def verify_metrics_exist(self, metric_names, metric_class, labels={}):
return all((self.verify_metric_exists(metric_name, metric_class, labels) for metric_name in metric_names))

def verify_metric_larger_than_zero(self, metric_name, metric_class, labels={}):
labels['metric_class'] = metric_class
result = self._getClient().get_current_metric_value(metric_name=metric_name, label_config=labels)
result = self.prometheus_client.get_current_metric_value(metric_name=metric_name, label_config=labels)
return len(result) > 0 and int(result[0]['value'][1]) > 0

def verify_metrics_larger_than_zero(self, metric_names, metric_class, labels={}):
Expand Down
27 changes: 0 additions & 27 deletions docker/test/integration/cluster/containers/PrometheusContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,11 @@ def __init__(self, feature_context, name, vols, network, image_store, command=No
scheme: https
tls_config:
ca_file: /etc/prometheus/certs/root-ca.pem
cert_file: /etc/prometheus/certs/prometheus.crt
key_file: /etc/prometheus/certs/prometheus.key
""".format(feature_id=self.feature_context.id)
self.yaml_file = tempfile.NamedTemporaryFile(delete=False)
self.yaml_file.write(prometheus_yml_content.encode())
self.yaml_file.close()
os.chmod(self.yaml_file.name, 0o644)

prometheus_web_config_content = """
tls_server_config:
cert_file: /etc/prometheus/certs/prometheus.crt
key_file: /etc/prometheus/certs/prometheus.key
"""
self.web_config_file = tempfile.NamedTemporaryFile(delete=False)
self.web_config_file.write(prometheus_web_config_content.encode())
self.web_config_file.close()
os.chmod(self.web_config_file.name, 0o644)
else:
prometheus_yml_content = """
global:
Expand Down Expand Up @@ -104,26 +92,11 @@ def deploy(self):
)]

if self.ssl:
mounts.append(docker.types.Mount(
type='bind',
source=self.web_config_file.name,
target='/etc/prometheus/web-config.yml'
))
mounts.append(docker.types.Mount(
type='bind',
source=self.root_ca_file.name,
target='/etc/prometheus/certs/root-ca.pem'
))
mounts.append(docker.types.Mount(
type='bind',
source=self.prometheus_cert_file.name,
target='/etc/prometheus/certs/prometheus.crt'
))
mounts.append(docker.types.Mount(
type='bind',
source=self.prometheus_key_file.name,
target='/etc/prometheus/certs/prometheus.key'
))

self.client.containers.run(
image="prom/prometheus:v2.35.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,3 @@ def manifest_can_be_retrieved_through_minifi_controller(self, container_name: st

def enable_log_metrics_publisher_in_minifi(self):
self.cluster.enable_log_metrics_publisher_in_minifi()

def enable_ssl_in_prometheus_checker(self):
self.cluster.enable_ssl_in_prometheus_checker()
5 changes: 1 addition & 4 deletions docker/test/integration/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,7 @@ def step_impl(context):

@given("a Prometheus server is set up with SSL")
def step_impl(context):
context.test.enable_ssl_in_prometheus_checker()
context.test.acquire_container(context=context, name="prometheus", engine="prometheus-ssl",
command=['/bin/prometheus', '--web.config.file=/etc/prometheus/web-config.yml', '--config.file=/etc/prometheus/prometheus.yml', '--storage.tsdb.path=/prometheus',
'--web.console.libraries=/usr/share/prometheus/console_libraries', '--web.console.templates=/usr/share/prometheus/consoles', '--log.level=debug'])
context.test.acquire_container(context=context, name="prometheus", engine="prometheus-ssl")


@then("\"{metric_class}\" are published to the Prometheus server in less than {timeout_seconds:d} seconds")
Expand Down

0 comments on commit f38c20c

Please sign in to comment.