Skip to content
Merged
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
30 changes: 26 additions & 4 deletions calico/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from datadog_checks.dev.conditions import CheckEndpoints
from datadog_checks.dev.conditions import CheckEndpoints, WaitFor
from datadog_checks.dev.kind import kind_run
from datadog_checks.dev.kube_port_forward import port_forward
from datadog_checks.dev.subprocess import run_command
Expand All @@ -16,6 +16,11 @@
HERE = path.dirname(path.abspath(__file__))


def _felix_config_default_exists():
result = run_command(["kubectl", "get", "felixconfiguration", "default"], capture='both')
return result.code == 0


def setup_calico():
# Deploy calico
run_command(["kubectl", "apply", "-f", path.join(HERE, 'kind', 'calico.yaml')])
Expand All @@ -32,10 +37,27 @@ def setup_calico():
# Wait for pods
run_command(["kubectl", "wait", "--for=condition=Ready", "pods", "--all", "--all-namespaces", "--timeout=300s"])

# Activate Felix
# calico-node creates the default FelixConfiguration asynchronously after pods report Ready.
WaitFor(_felix_config_default_exists, attempts=60, wait=2)()

# check=True so a missed patch fails loudly here instead of as a connection-refused timeout later.
run_command(
"""kubectl exec -i -n kube-system calicoctl -- /calicoctl patch felixConfiguration
default --patch '{"spec":{"prometheusMetricsEnabled": true}}'"""
[
"kubectl",
"exec",
"-i",
"-n",
"kube-system",
"calicoctl",
"--",
"/calicoctl",
"patch",
"felixConfiguration",
"default",
"--patch",
'{"spec":{"prometheusMetricsEnabled": true}}',
],
check=True,
)


Expand Down
Loading