tracereplay

package
v0.0.0-...-9e0e42b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 2

README

What is it?

The tracereplay tool can save runsc trace sessions to a file, and later replay the same sequence of messages. This can be used to run tests that rely on the messages without the need to setup runsc, configure trace sessions, and run specific workloads.

How to use it?

The tracereplay save command starts a server that listens to new connections from runsc and creates a trace file for each runsc instance that connects to it. The command below starts a server on listening on /tmp/gvisor_events.sock and writes trace files to /tmp/trace directory:

$ tracereplay save --endpoint=/tmp/gvisor_events.sock --out=/tmp/trace

When you execute runsc configured with a trace session using the remote sink connecting to /tmp/gvisor_events.sock, all messages will be saved to a file under /tmp/trace. For example, if you run the following commands, runsc will connect to the server above and all trace points triggered by the workload will be stored in the save file:

$ cat > /tmp/pod_init.json <<EOL
{
  "trace_session": {
    "name": "Default",
    "points": [
      {
        "name": "container/start"
      }
    ],
    "sinks": [
      {
        "name": "remote",
        "config": {
          "endpoint": "/tmp/gvisor_events.sock"
        }
      }
    ]
  }
}
EOL
$ runsc --rootless --network=none --pod-init-config=/tmp/pod_init.json do /bin/true

You should see the following output from tracereplay save:

New client connected, writing to: "/tmp/trace/client-0001"
Closing client, wrote 1 messages to "/tmp/trace/client-0001"

You can then use the tracereplay replay command to replay the exact same messages anytime and as many times as you want. Here is an example using the file created above:

$ tracereplay replay --endpoint=/tmp/gvisor_events.sock --in=/tmp/trace/client-0001
Handshake completed
Replaying message: 1
Done

If you want to see the messages that are stored in the file, you can setup the example server provided in examples/seccheck:server_cc and replay the save file using the same command above. Here is the output you would get:

$ bazel run examples/seccheck:server_cc
Socket address /tmp/gvisor_events.sock
Connection accepted
Start => id:     "runsc-865139" cwd: "/home/fvoznika" args: "/bin/true"
Connection closed

Documentation

Overview

Package tracereplay implements a tool that can save and replay messages issued from remote.Remote.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Version is the wire format saved in the file.
	Version uint32 `json:"version"`
}

Config contains information required to replay messages from a file.

type Replay

type Replay struct {
	Endpoint string
	In       string
}

Replay implements the functionality required for the "replay" command.

func (*Replay) Execute

func (r *Replay) Execute() error

Execute connects to the remote endpoint and replays all messages stored in the `In` file.

type Save

type Save struct {
	server.CommonServer
	// contains filtered or unexported fields
}

Save implements the functionality required for the "save" command.

func NewSave

func NewSave(endpoint, dir, prefix string) *Save

NewSave creates a new Save instance.

func (*Save) NewClient

func (s *Save) NewClient() (server.MessageHandler, error)

NewClient creates a new file for the client and writes messages to it.

The file format starts with a string signature to make it easy to check that it's a trace file. The signature is followed by a JSON configuration that contains information required to process the file. Next, there are a sequence of messages. Both JSON and messages are prefixed by an uint64 with their size.

Ex: signature <size>Config JSON [<size>message]*

func (*Save) Start

func (s *Save) Start() error

Start starts the server.

Directories

Path Synopsis
Package main implements a tool that can save and replay messages from issued from remote.Remote.
Package main implements a tool that can save and replay messages from issued from remote.Remote.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL