Documentation ¶
Overview ¶
Package test provides helpers to test the various pion transports implementations. The tests are standardized around the io.ReadWriteCloser interface. This package is meant to be used in addition to golang.org/x/net/nettest.
Index ¶
- func CheckRoutines(t *testing.T) func()
- func CheckRoutinesStrict(tb testing.TB) func()
- func FlattenErrs(errs []error) error
- func GatherErrs(c chan error) []error
- func Stress(ca io.Writer, cb io.Reader, opt Options) error
- func StressContext(ctx context.Context, ca netctx.Writer, cb netctx.Reader, opt Options) error
- func StressDuplex(ca io.ReadWriter, cb io.ReadWriter, opt Options) error
- func StressDuplexContext(ctx context.Context, ca netctx.ReadWriter, cb netctx.ReadWriter, opt Options) error
- func TimeOut(t time.Duration) *time.Timer
- type Bridge
- func (br *Bridge) Drop(fromID, offset, n int)
- func (br *Bridge) DropNextNWrites(fromID, n int)
- func (br *Bridge) Filter(fromID int, cb func([]byte) bool)
- func (br *Bridge) GetConn0() net.Conn
- func (br *Bridge) GetConn1() net.Conn
- func (br *Bridge) Len(fromID int) int
- func (br *Bridge) Process()
- func (br *Bridge) Push(packet []byte, fromID int) bool
- func (br *Bridge) Reorder(fromID int) error
- func (br *Bridge) ReorderNextNWrites(fromID, n int)
- func (br *Bridge) SetLossChance(chance int) error
- func (br *Bridge) Tick() int
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRoutines ¶
CheckRoutines is used to check for leaked go-routines
func CheckRoutinesStrict ¶ added in v3.0.3
CheckRoutinesStrict is used to check for leaked go-routines. It differs from CheckRoutines in that it has very little tolerance for lingering goroutines. This is helpful for tests that need to ensure clean closure of resources. Checking the state of goroutines exactly is tricky. As users writing goroutines, we tend to clean up gracefully using some synchronization pattern. When used correctly, we won't leak goroutines, but we cannot gurantee *when* the goroutines will end. This is the nature of waiting on the runtime's goexit1 being called which is the final subroutine called, which is after any user written code. This small, but possible chance to have a thread (not goroutine) be preempted before this is called, can have our goroutine stack be not quite correct yet. The best we can do is sleep a little bit and try to encourage the runtime to run that goroutine (G) on the machine (M) it belongs to.
func FlattenErrs ¶
FlattenErrs flattens a slice of errors into a single error
func GatherErrs ¶
GatherErrs gathers all errors returned by a channel. It blocks until the channel is closed.
func Stress ¶
Stress enables stress testing of a io.ReadWriter. It checks that packets are received correctly and in order.
func StressContext ¶
StressContext enables stress testing of a io.ReadWriter. It checks that packets are received correctly and in order.
func StressDuplex ¶
func StressDuplex(ca io.ReadWriter, cb io.ReadWriter, opt Options) error
StressDuplex enables duplex stress testing of a io.ReadWriter. It checks that packets are received correctly and in order.
func StressDuplexContext ¶
func StressDuplexContext(ctx context.Context, ca netctx.ReadWriter, cb netctx.ReadWriter, opt Options) error
StressDuplexContext enables duplex stress testing of a io.ReadWriter. It checks that packets are received correctly and in order.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge represents a network between the two endpoints.
func (*Bridge) Drop ¶
Drop drops the specified number of packets from the given offset index of the specified queue.
func (*Bridge) DropNextNWrites ¶
DropNextNWrites drops the next n packets that will be written to the specified queue.
func (*Bridge) Process ¶
func (br *Bridge) Process()
Process repeats tick() calls until no more outstanding packet in the queues.
func (*Bridge) ReorderNextNWrites ¶
ReorderNextNWrites drops the next n packets that will be written to the specified queue.
func (*Bridge) SetLossChance ¶
SetLossChance sets the probability of writes being discard (to introduce artificial loss)