Documentation ¶
Overview ¶
Package testutil contains helper functions used in network tests
Index ¶
- func IP6tablesRestore(tb testing.TB, state []byte)
- func IP6tablesSave(tb testing.TB)
- func IptablesRestore(tb testing.TB, state []byte)
- func IptablesSave(tb testing.TB) []byte
- func MustPingTCP(tb require.TestingT, ip net.IP, port int) net.Conn
- func MustPingUDP(tb require.TestingT, ip net.IP, port int) net.Conn
- func PingTCP(tb require.TestingT, ip net.IP, port int) net.Conn
- func PingUDP(tb require.TestingT, ip net.IP, port int) net.Conn
- func RunCommand(cmd string) (string, error)
- func RunCommandWithContext(ctx context.Context, cmd string) (string, error)
- func RunCommands(tb testing.TB, cmds []string, ignoreErrors bool) []string
- func StartCommandCtx(ctx context.Context, cmd string) (*exec.Cmd, io.WriteCloser, error)
- func StartServerTCP(t testing.TB, ip net.IP, port int) io.Closer
- func StartServerTCPNs(t testing.TB, ip net.IP, port int, ns string) io.Closer
- func StartServerUDP(t *testing.T, ip net.IP, port int) io.Closer
- func StartServerUDPNs(t *testing.T, ip net.IP, port int, ns string) io.Closer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IP6tablesRestore ¶
IP6tablesRestore restores iptables state from a file
func IP6tablesSave ¶
IP6tablesSave saves the current iptables state to a file and returns its path
func IptablesRestore ¶
IptablesRestore restores iptables state from a file
func IptablesSave ¶
IptablesSave saves the current iptables state to a file and returns its path
func MustPingTCP ¶
MustPingTCP is a wrapper around PingTCP that guarantees a non-nil connection is returned
func MustPingUDP ¶
MustPingUDP is a wrapper around PingUDP that guarantees a non-nil connection is returned
func PingTCP ¶
PingTCP connects to the provided IP address over TCP/TCPv6, sends the string "ping", reads from the connection, and returns the open connection for further use/inspection.
func PingUDP ¶
PingUDP connects to the provided IP address over UDP/UDPv6, sends the string "ping", and returns the open connection for further use/inspection.
func RunCommandWithContext ¶
RunCommandWithContext runs a single command with the given context
func RunCommands ¶
RunCommands runs each command in cmds individually and returns the output as a []string, with each element corresponding to the respective command. If ignoreErrors is false, it will fail the test via t.Fatal immediately upon error. Otherwise, the output on errors will be logged via t.Log.
func StartCommandCtx ¶
StartCommandCtx Runs a command with the given context, returning a handle to the command and its input stream.
func StartServerTCP ¶
StartServerTCP starts a TCP server listening at provided IP address and port. It will respond to any connection with "hello" and then close the connection. It returns an io.Closer that should be Close'd when you are finished with it.
func StartServerTCPNs ¶
StartServerTCPNs is identical to StartServerTCP, but it operates with the network namespace provided by name.
func StartServerUDP ¶
StartServerUDP starts a UDP server listening at provided IP address and port. It does not respond in any fashion to sent datagrams. It returns an io.Closer that should be Close'd when you are finished with it.
Types ¶
This section is empty.