Skip to content

Commit 2685fca

Browse files
authored
Adds falco-exporter to the integration test (#19)
falco-exporter requires falco to have grpc enabled, according to the Helm chart documentation.
1 parent 7ceaf9e commit 2685fca

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

tests/integration/test_falco.py

+60-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ def _get_event_generator_helm_cmd():
3434
)
3535

3636

37+
def _get_falco_exporter_helm_cmd(instance: harness.Instance):
38+
falco_exporter_rock = env_util.get_build_meta_info_for_rock_version(
39+
"falco-exporter", "0.8.7", "amd64"
40+
)
41+
42+
images = [
43+
k8s_util.HelmImage(falco_exporter_rock.image),
44+
]
45+
46+
return k8s_util.get_helm_install_command(
47+
"falco-exporter",
48+
"falco-exporter",
49+
namespace="falco",
50+
repository="https://falcosecurity.github.io/charts",
51+
images=images,
52+
runAsUser=0,
53+
split_image_registry=True,
54+
)
55+
56+
3757
def _get_falcosidekick_helm_cmd():
3858
falcosidekick_rock = env_util.get_build_meta_info_for_rock_version(
3959
"falcosidekick", "2.29.0", "amd64"
@@ -79,6 +99,10 @@ def _get_falco_helm_cmd(falco_version: str):
7999

80100
set_configs = [
81101
"driver.kind=modern_ebpf",
102+
# required for the falco-exporter.
103+
# https://github.com/falcosecurity/charts/tree/master/charts/falco-exporter#falco-exporter-helm-chart
104+
"falco.grpc.enabled=true",
105+
"falco.grpc_output.enabled=true",
82106
]
83107

84108
return k8s_util.get_helm_install_command(
@@ -93,6 +117,33 @@ def _get_falco_helm_cmd(falco_version: str):
93117
)
94118

95119

120+
def _assert_falco_exporter_up(instance: harness.Instance):
121+
# Assert that falco-exporter is responsive. The falco-exporter image is a bare image,
122+
# so, we're using the falco Pod to curl the falco-exporter endpoint instead.
123+
LOG.info("Checking if falco-exporter is being responsive.")
124+
process = instance.exec(
125+
[
126+
"k8s",
127+
"kubectl",
128+
"--namespace",
129+
"falco",
130+
"exec",
131+
f"{constants.K8S_DAEMONSET}/falco",
132+
"--",
133+
"curl",
134+
"-s",
135+
"http://falco-exporter:9376/metrics",
136+
],
137+
check=True,
138+
capture_output=True,
139+
text=True,
140+
)
141+
142+
assert (
143+
"Total number of scrapes" in process.stdout
144+
), "Expected falco-exporter to return metrics."
145+
146+
96147
def _assert_falcosidekick_up(instance: harness.Instance):
97148
# Assert that falcosidekick is responsive. It has a ping method, to which we should get pong.
98149
# The falcosidekick image does not have curl or wget, but the falco image does.
@@ -178,8 +229,14 @@ def test_integration_falco(function_instance: harness.Instance, image_version):
178229
# Deploy falcosidekick helm chart and wait for it to become active.
179230
function_instance.exec(_get_falcosidekick_helm_cmd())
180231

181-
# Wait for the daemonset to become Active.
182-
k8s_util.wait_for_daemonset(function_instance, "falco", "falco", retry_times=10)
232+
# Deploy falco-exporter helm chart and wait for it to become active.
233+
function_instance.exec(_get_falco_exporter_helm_cmd(function_instance))
234+
235+
# Wait for the daemonsets to become Active.
236+
for daemonset in ["falco", "falco-exporter"]:
237+
k8s_util.wait_for_daemonset(
238+
function_instance, daemonset, "falco", retry_times=10
239+
)
183240

184241
# Wait for the deployments to become Active.
185242
for deployment in ["falcosidekick", "falcosidekick-ui"]:
@@ -202,3 +259,4 @@ def test_integration_falco(function_instance: harness.Instance, image_version):
202259

203260
_assert_falco_logs(function_instance)
204261
_assert_falcosidekick_up(function_instance)
262+
_assert_falco_exporter_up(function_instance)

0 commit comments

Comments
 (0)