Documentation
¶
Index ¶
- Constants
- func AllIAPairs() []sintegration.IAPair
- func AppBinPath(name string) string
- func AssignUniquePorts(pairs []sintegration.IAPair, portOffset int, stride int)
- func Contains(expected string) func(string) error
- func DefaultIAPairs() []sintegration.IAPair
- func Init() error
- func InputPipeScript(tmpDir, name, inputCommand, command string) string
- func NoPanic(out string) error
- func RegExp(regularExpression string) func(string) error
- func TestMain(m *testing.M)
- type ScionAppsIntegration
- func (sai *ScionAppsIntegration) Run(t *testing.T, pairs []sintegration.IAPair) error
- func (sai *ScionAppsIntegration) StartClient(ctx context.Context, src, dst *snet.UDPAddr) (sintegration.Waiter, error)
- func (sai *ScionAppsIntegration) StartServer(ctx context.Context, dst *snet.UDPAddr) (sintegration.Waiter, error)
Constants ¶
const ( // SCIOND is a placeholder for the SCIOND server in the arguments. SCIOND = "<SCIOND>" // ServerPortReplace is a placeholder for the server port in the arguments. ServerPortReplace = "<ServerPort>" // SrcIAReplace is a placeholder for the source IA in the arguments. SrcIAReplace = "<SRCIA>" // SrcHostReplace is a placeholder for the source host in the arguments. SrcHostReplace = "<SRCHost>" // SrcAddrPattern is a placeholder for the source address in the arguments. SrcAddrPattern = SrcIAReplace + ",[" + SrcHostReplace + "]" // DstIAReplace is a placeholder for the destination IA in the arguments. DstIAReplace = "<DSTIA>" // DstHostReplace is a placeholder for the destination host in the arguments. DstHostReplace = "<DSTHost>" // DstAddrPattern is a placeholder for the destination address in the arguments. DstAddrPattern = DstIAReplace + ",[" + DstHostReplace + "]" // ReadySignal should be written to Stdout by the server once it is ready to accept clients. // The message should always be `Listening addr=<addr>` // where <addr> is the address the server is listening on. ReadySignal = "Listening addr=" // GoIntegrationEnv is an environment variable that is set for the binary under test. // It can be used to guard certain statements, like printing the ReadySignal, // in a program under test. GoIntegrationEnv = "SCION_GO_INTEGRATION" // Default client startup timeout DefaultClientTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AllIAPairs ¶ added in v0.5.0
func AllIAPairs() []sintegration.IAPair
AllIAPairs returns all IAPairs that should be tested.
func AppBinPath ¶
AppBinPath returns the path to a scion-apps binary built with the projects Makefile.
func AssignUniquePorts ¶ added in v0.6.0
func AssignUniquePorts(pairs []sintegration.IAPair, portOffset int, stride int)
AssignUniquePorts assigns unique ports to all combinations, so that for each distinct (IA,IP) no (IP:port) is the same. This prevents clashes while listening at the same time, with the dispatcher-less approach. The arguments portOffset and stride specify the initial port and how many ports will be skipped per server instance. E.g., with offset=1234, stride=2 the first server will use port 1234, second 1234+2, etc. In the case of bwtestserver, since the client uses two ports to the server, stride would have to be at least 2. Note: on each pair, Dst represents the server.
func DefaultIAPairs ¶ added in v0.5.0
func DefaultIAPairs() []sintegration.IAPair
DefaultIAPairs returns a small number of relevant IA pairs to be tested. In particular, it will return at most one of each of - src/dst in same AS, IPv4 - src/dst in same AS, IPv6 - src/dst in different AS, IPv4 - src/dst in different AS, IPv4 to IPv6 - src/dst in different AS, IPv6 to IPv4 - src/dst in different AS, IPv6 Depending on the topology on which these tests are being run, not all might be available.
func InputPipeScript ¶ added in v0.5.0
InputPipeScript generates a shell script that runs command with input generated by inputCommand. The script will created in tmpDir. Returns the path to the generated script. The script will generate more stuff in tmpDir when executed, the caller is responsible for cleaning this up. Use `(*testing.T).TempDir()`.
The script is roughly similar to:
#!/bin/sh inputCommand | command "$@"
The two commands are inserted verbatim (no escaping performed). Be careful to wrap longer shell commands into subshells where appropriate.
NOTE: instead of the simple pipe above, we use a named fifo, start the input command in the background so that we can *exec* command. This helps to ensure that the subprocesses are somewhat reliably cleaned up.
BACKGROUND: when exec.CommandContext kills the process, it sends a SIGKILL to only the process itself (not the process group), leaving the subprocesses dangling. Due to some additional quirk in the processing of stdout/err in exec.Command (go routines processing stdout/err are never stopped, https://github.com/golang/go/issues/23019), Wait-ing on the command then never returns. By using exec in the shell script, we make sure that `command`, instead of the parent shell, is the process that will actually be tracked/killed by the golang Command. When killing `command`, this should usually also stop the `inputCommand` simply by closing the pipe.
NOTE: if this stops working, some alternatives are:
- avoid to shell out for the input in the first place and directly write to stdin of the process with a goroutine.
- circumvent the stdout/err processing goroutine by using a os.Pipe which can be explicitly closed (as suggested in https://github.com/golang/go/issues/23019)
- avoid the CommandContext, which uses Kill, and "cancel" the whole process group explicitly by SIGTERM.
- this will NOT work: trap to clean up subprocesses in the shell script, because CommandContext sends SIGKILL. This was a "fun" exercise.
Types ¶
type ScionAppsIntegration ¶
type ScionAppsIntegration struct { ServerOutMatch func(stdout string) error ServerErrMatch func(stderrr string) error ClientOutMatch func(stdout string) error ClientErrMatch func(stderrr string) error ClientDelay time.Duration ClientTimeout time.Duration // contains filtered or unexported fields }
func NewAppsIntegration ¶
func NewAppsIntegration(clientCmd string, serverCmd string, clientArgs, serverArgs []string) *ScionAppsIntegration
NewAppsIntegration returns an implementation of the Integration interface. Start{Client|Server} will run the binary program with name and use the given arguments for the client/server. Use SrcIAReplace and DstIAReplace in arguments as placeholder for the source and destination IAs. When starting a client/server the placeholders will be replaced with the actual values. The server should output the ReadySignal to Stdout once it is ready to accept clients. If keepLog is true, also store client and server error logs.
func (*ScionAppsIntegration) Run ¶ added in v0.5.0
func (sai *ScionAppsIntegration) Run(t *testing.T, pairs []sintegration.IAPair) error
RunTests runs the client and server for each IAPair. In case of an error the function is terminated immediately.
func (*ScionAppsIntegration) StartClient ¶
func (sai *ScionAppsIntegration) StartClient(ctx context.Context, src, dst *snet.UDPAddr) (sintegration.Waiter, error)
func (*ScionAppsIntegration) StartServer ¶
func (sai *ScionAppsIntegration) StartServer(ctx context.Context, dst *snet.UDPAddr) (sintegration.Waiter, error)
StartServer starts a server and blocks until the ReadySignal is received on Stdout.
Directories
¶
Path | Synopsis |
---|---|
Package sintegration simplifies the creation of integration tests.
|
Package sintegration simplifies the creation of integration tests. |