gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/tracereplay/README.md (about) 1 # What is it? 2 3 The `tracereplay` tool can save `runsc trace` sessions to a file, and later 4 replay the same sequence of messages. This can be used to run tests that rely on 5 the messages without the need to setup runsc, configure trace sessions, and run 6 specific workloads. 7 8 # How to use it? 9 10 The `tracereplay save` command starts a server that listens to new connections 11 from runsc and creates a trace file for each runsc instance that connects to it. 12 The command below starts a server on listening on `/tmp/gvisor_events.sock` and 13 writes trace files to `/tmp/trace` directory: 14 15 ```shell 16 $ tracereplay save --endpoint=/tmp/gvisor_events.sock --out=/tmp/trace 17 ``` 18 19 When you execute runsc configured with a trace session using the `remote` sink 20 connecting to `/tmp/gvisor_events.sock`, all messages will be saved to a file 21 under `/tmp/trace`. For example, if you run the following commands, runsc will 22 connect to the server above and all trace points triggered by the workload will 23 be stored in the save file: 24 25 ```shell 26 $ cat > /tmp/pod_init.json <<EOL 27 { 28 "trace_session": { 29 "name": "Default", 30 "points": [ 31 { 32 "name": "container/start" 33 } 34 ], 35 "sinks": [ 36 { 37 "name": "remote", 38 "config": { 39 "endpoint": "/tmp/gvisor_events.sock" 40 } 41 } 42 ] 43 } 44 } 45 EOL 46 $ runsc --rootless --network=none --pod-init-config=/tmp/pod_init.json do /bin/true 47 ``` 48 49 You should see the following output from `tracereplay save`: 50 51 ``` 52 New client connected, writing to: "/tmp/trace/client-0001" 53 Closing client, wrote 1 messages to "/tmp/trace/client-0001" 54 ``` 55 56 You can then use the `tracereplay replay` command to replay the exact same 57 messages anytime and as many times as you want. Here is an example using the 58 file created above: 59 60 ```shell 61 $ tracereplay replay --endpoint=/tmp/gvisor_events.sock --in=/tmp/trace/client-0001 62 Handshake completed 63 Replaying message: 1 64 Done 65 ``` 66 67 If you want to see the messages that are stored in the file, you can setup the 68 example server provided in `examples/seccheck:server_cc` and replay the save 69 file using the same command above. Here is the output you would get: 70 71 ```shell 72 $ bazel run examples/seccheck:server_cc 73 Socket address /tmp/gvisor_events.sock 74 Connection accepted 75 Start => id: "runsc-865139" cwd: "/home/fvoznika" args: "/bin/true" 76 Connection closed 77 ```