@@ -184,3 +184,80 @@ podman run --privileged --network=host ghcr.io/ovn-kubernetes/kubernetes-traffic
184
184
```
185
185
podman run --privileged --network=host ghcr.io/ovn-kubernetes/kubernetes-traffic-flow-tests:latest sh -c 'ktoolbox-netdev | yq -P -C' | less -R
186
186
```
187
+
188
+ ## Debugging Tests using Simple Exec Script
189
+
190
+ When a TFT test fails, it cleans up the broken environment. That can make
191
+ debugging cumbersome.
192
+
193
+ One possible way can be using the "simple" test type with the "--exec"
194
+ parameter. The "simple" test type runs
195
+ [ scripts/simple-tcp-server-client.py] ( scripts/simple-tcp-server-client.py )
196
+ script. Check the ` --help ` output about the ` --exec ` options (and
197
+ ` --exec-insecure ` , ` --exec-args ` , ` --exec-arg ` ). In exec mode, the script
198
+ simple does something else. It will download an external script and execute
199
+ that instead. That script can do anything and you can tweak it to be useful for
200
+ debugging.
201
+
202
+ There is already a default script
203
+ [ scripts/simple-exec.sh] ( scripts/simple-exec.sh ) . You could take that script as
204
+ starting poing and tweak it (or you can use your own script).
205
+
206
+ If you use ` scripts/simple-exec.sh ` , then by default it will call it's calling
207
+ script ` simple-tcp-server-client.py ` again, albeit with some steps that might
208
+ be useful for debugging. In particular, if the ` simple-tcp-server-client.py `
209
+ call fails, the script will hang, which allows you to enter the pod and
210
+ investigate the problem yourself.
211
+
212
+ If a non-empty first parameter to ` scripts/simple-exec.sh ` is provided, then
213
+ that is expected to be a URL to download a ` simple-tcp-server-client.py ` like
214
+ script, which is invoked instead of the ` simple-tcp-server-client.py ` script
215
+ from the tft container.
216
+
217
+ This allows you to run arbitrary code without need to rebuild the tft
218
+ container. In a first step, you can pass your own ` --exec ` script. Either based
219
+ on ` scripts/simple-exec.sh ` or whatever suits you.
220
+
221
+ If you use the unmodified ` scripts/simple-exec.sh ` , then by default it will
222
+ call back into ` scripts/simple-tcp-server-client.py ` from inside the container.
223
+ This then runs the actual traffic flow test. If you wish, you can also provide
224
+ your own patched variant of that latter script, instead of using the one from
225
+ the container.
226
+
227
+ For example, consider the following configuration.
228
+
229
+ ```
230
+ --- c/tft-config.yaml
231
+ +++ i/tft-config.yaml
232
+ @@ -1,21 +1,24 @@
233
+ tft:
234
+ - name: "Test 1"
235
+ namespace: "default"
236
+ test_cases: "1"
237
+ duration: "30"
238
+ + privileged_pod: true
239
+ connections:
240
+ - name: "Connection_1"
241
+ - type: "iperf-udp"
242
+ + type: "simple"
243
+ instances: 1
244
+ server:
245
+ - name: "$worker"
246
+ sriov: "true"
247
+ + args: "--num-clients 0 --exec https://example.com/tft-test/simple-exec.sh --exec-insecure -E https://example.com/tft-test/simple-tcp-server-client.py"
248
+ client:
249
+ - name: "$worker"
250
+ sriov: "true"
251
+ + args: "--exec https://example.com/tft-test/simple-exec.sh --exec-insecure -E https://example.com/tft-test/simple-tcp-server-client.py"
252
+ ```
253
+
254
+ In above example, the server side will first download and exec
255
+ ` https://example.com/tft-test/simple-exec.sh ` , with one parameter, the URL
256
+ ` https://example.com/tft-test/simple-tcp-server-client.py ` . If that scripts
257
+ behaves as the ` scripts/simple-exec.sh ` from our tree, then it will take the
258
+ first argument, download it, and execut that script as if it were a
259
+ "simple-tcp-server-client.py" script. Note how the parameters like
260
+ ` --num-clients 0 ` will be passed all the way down to that last python script.
261
+ This leaves you two scripts that you can tweak to your needs and update easily,
262
+ while being based on some default implementations that can be useful without
263
+ modification.
0 commit comments