@@ -122,11 +122,10 @@ def _get_falco_helm_cmd(falco_version: str):
122
122
)
123
123
124
124
125
- def _assert_falco_exporter_up (instance : harness .Instance ):
126
- # Assert that falco-exporter is responsive. The falco-exporter image is a bare image,
127
- # so, we're using the falco Pod to curl the falco-exporter endpoint instead.
128
- LOG .info ("Checking if falco-exporter is being responsive." )
129
- process = instance .exec (
125
+ def _curl_service_via_falco (
126
+ instance : harness .Instance , svc_name : str , port : int , endpoint : str
127
+ ):
128
+ return instance .exec (
130
129
[
131
130
"k8s" ,
132
131
"kubectl" ,
@@ -137,13 +136,19 @@ def _assert_falco_exporter_up(instance: harness.Instance):
137
136
"--" ,
138
137
"curl" ,
139
138
"-s" ,
140
- "http://falco-exporter:9376/metrics " ,
139
+ f "http://{ svc_name } : { port } / { endpoint } " ,
141
140
],
142
141
check = True ,
143
142
capture_output = True ,
144
143
text = True ,
145
144
)
146
145
146
+
147
+ def _assert_falco_exporter_up (instance : harness .Instance ):
148
+ # Assert that falco-exporter is responsive. The falco-exporter image is a bare image,
149
+ # so, we're using the falco Pod to curl the falco-exporter endpoint instead.
150
+ LOG .info ("Checking if falco-exporter is being responsive." )
151
+ process = _curl_service_via_falco (instance , "falco-exporter" , 9376 , "metrics" )
147
152
assert (
148
153
"Total number of scrapes" in process .stdout
149
154
), "Expected falco-exporter to return metrics."
@@ -152,30 +157,23 @@ def _assert_falco_exporter_up(instance: harness.Instance):
152
157
def _assert_falcosidekick_up (instance : harness .Instance ):
153
158
# Assert that falcosidekick is responsive. It has a ping method, to which we should get pong.
154
159
# The falcosidekick image does not have curl or wget, but the falco image does.
155
- LOG .info ("Checking if Falco detected irregularities." )
156
- process = instance .exec (
157
- [
158
- "k8s" ,
159
- "kubectl" ,
160
- "--namespace" ,
161
- "falco" ,
162
- "exec" ,
163
- f"{ constants .K8S_DAEMONSET } /falco" ,
164
- "--" ,
165
- "curl" ,
166
- "-s" ,
167
- "http://falcosidekick:2801/ping" ,
168
- ],
169
- check = True ,
170
- capture_output = True ,
171
- text = True ,
172
- )
173
-
160
+ LOG .info ("Checking if falcosidekick is being responsive." )
161
+ process = _curl_service_via_falco (instance , "falcosidekick" , 2801 , "ping" )
174
162
assert (
175
163
"pong" in process .stdout
176
164
), "Expected falcosidekick to respond with pong to ping."
177
165
178
166
167
+ def _assert_falcosidekick_ui_up (instance : harness .Instance ):
168
+ # Assert that falcosidekick-ui is responsive.
169
+ # The falcosidekick-ui image does not have curl or wget, but the falco image does.
170
+ LOG .info ("Checking if falcosidekick-ui is being responsive." )
171
+ process = _curl_service_via_falco (
172
+ instance , "falcosidekick-ui" , 2802 , "api/v1/healthz"
173
+ )
174
+ assert "ok" in process .stdout , "Expected falcosidekick-ui to respond with ok."
175
+
176
+
179
177
def _assert_falco_logs (instance : harness .Instance ):
180
178
# Falco should have noticed the unexpected behaviour from the event-generator, and it should
181
179
# have logged these events to stdout by default.
@@ -264,4 +262,5 @@ def test_integration_falco(function_instance: harness.Instance, image_version):
264
262
265
263
_assert_falco_logs (function_instance )
266
264
_assert_falcosidekick_up (function_instance )
265
+ _assert_falcosidekick_ui_up (function_instance )
267
266
_assert_falco_exporter_up (function_instance )
0 commit comments