53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
MANIFEST = ROOT / "k8s" / "observability" / "otel-collector-daemonset.yaml"
|
|
|
|
|
|
def _documents() -> list[dict]:
|
|
return [doc for doc in yaml.safe_load_all(MANIFEST.read_text(encoding="utf-8")) if doc]
|
|
|
|
|
|
def test_otel_collector_uses_durable_offsets_and_export_queue() -> None:
|
|
documents = _documents()
|
|
config_map = next(doc for doc in documents if doc["kind"] == "ConfigMap")
|
|
config = yaml.safe_load(config_map["data"]["config.yaml"])
|
|
|
|
assert config["extensions"]["file_storage"]["directory"] == "/var/lib/otelcol"
|
|
assert config["receivers"]["filelog"]["storage"] == "file_storage"
|
|
exporter = config["exporters"]["otlphttp"]
|
|
assert exporter["retry_on_failure"]["max_elapsed_time"] == "0s"
|
|
assert exporter["sending_queue"] == {
|
|
"enabled": True,
|
|
"num_consumers": 2,
|
|
"queue_size": 10000,
|
|
"storage": "file_storage",
|
|
}
|
|
assert "file_storage" in config["service"]["extensions"]
|
|
|
|
|
|
def test_otel_daemonset_mounts_per_node_storage_and_rolls_one_at_a_time() -> None:
|
|
daemonset = next(doc for doc in _documents() if doc["kind"] == "DaemonSet")
|
|
assert daemonset["spec"]["updateStrategy"]["rollingUpdate"]["maxUnavailable"] == 1
|
|
pod_spec = daemonset["spec"]["template"]["spec"]
|
|
assert pod_spec["terminationGracePeriodSeconds"] == 60
|
|
|
|
storage = next(volume for volume in pod_spec["volumes"] if volume["name"] == "otel-storage")
|
|
assert storage["hostPath"] == {
|
|
"path": "/var/lib/awoooi/otelcol",
|
|
"type": "DirectoryOrCreate",
|
|
}
|
|
collector = next(container for container in pod_spec["containers"] if container["name"] == "otel-collector")
|
|
assert collector["image"] == (
|
|
"192.168.0.110:5000/awoooi/otel-collector-contrib@"
|
|
"sha256:8edf386cdd1f4dc4393e34680e298dcc577296279febf243cf122155fa560c39"
|
|
)
|
|
assert collector["imagePullPolicy"] == "IfNotPresent"
|
|
mount = next(volume for volume in collector["volumeMounts"] if volume["name"] == "otel-storage")
|
|
assert mount["mountPath"] == "/var/lib/otelcol"
|