Documentation ¶
Index ¶
- Constants
- Variables
- func HaveConnectivityTo(target ConnectionTarget, explicitPort ...uint16) types.GomegaMatcher
- func IsMessagePartOfStream(msg string) bool
- type CheckCmd
- type CheckOption
- func WithDuration(duration time.Duration) CheckOption
- func WithNamespacePath(nsPath string) CheckOption
- func WithRecvLen(l int) CheckOption
- func WithSendLen(l int) CheckOption
- func WithSourceIP(ip string) CheckOption
- func WithSourcePort(port string) CheckOption
- func WithTimeout(t time.Duration) CheckOption
- type Checker
- func (c *Checker) ActualConnectivity(isARetry bool) ([]*Result, []string)
- func (c *Checker) CheckConnectivity(opts ...interface{})
- func (c *Checker) CheckConnectivityOffset(offset int, opts ...interface{})
- func (c *Checker) CheckConnectivityPacketLoss(opts ...interface{})
- func (c *Checker) CheckConnectivityWithTimeout(timeout time.Duration, opts ...interface{})
- func (c *Checker) CheckConnectivityWithTimeoutOffset(callerSkip int, timeout time.Duration, opts ...interface{})
- func (c *Checker) Expect(expected Expected, from ConnectionSource, to ConnectionTarget, ...)
- func (c *Checker) ExpectLoss(from ConnectionSource, to ConnectionTarget, duration time.Duration, ...)
- func (c *Checker) ExpectNone(from ConnectionSource, to ConnectionTarget, explicitPort ...uint16)
- func (c *Checker) ExpectSNAT(from ConnectionSource, srcIP string, to ConnectionTarget, ...)
- func (c *Checker) ExpectSome(from ConnectionSource, to ConnectionTarget, explicitPort ...uint16)
- func (c *Checker) ExpectedConnectivityPretty() []string
- func (c *Checker) ResetExpectations()
- type CheckerOpt
- type ConnConfig
- type ConnectionSource
- type ConnectionTarget
- type ExpPacketLoss
- type Expectation
- type ExpectationOption
- func ExpectNoneWithError(ErrorStr string) ExpectationOption
- func ExpectWithClientAdjustedMTU(from, to int) ExpectationOption
- func ExpectWithIPVersion(ipVersion int) ExpectationOption
- func ExpectWithLoss(duration time.Duration, maxPacketLossPercent float64, maxPacketLossNumber int) ExpectationOption
- func ExpectWithPorts(ports ...uint16) ExpectationOption
- func ExpectWithRecvLen(l int) ExpectationOption
- func ExpectWithSendLen(l int) ExpectationOption
- func ExpectWithSrcIPs(ips ...string) ExpectationOption
- func ExpectWithSrcPort(port uint16) ExpectationOption
- type Expected
- type MTUPair
- type Matcher
- type PersistentConnection
- type Request
- type Response
- type Result
- type Runtime
- type Stats
- type TargetIP
- type TargetIPv4AsIPv6
Constants ¶
const BinaryName = "test-connection"
BinaryName is the name of the binary that the connectivity Check() executes
const ConnectionTypePing = "ping"
const ConnectionTypeStream = "stream"
Variables ¶
var UnactivatedCheckers = set.New[*Checker]()
Functions ¶
func HaveConnectivityTo ¶
func HaveConnectivityTo(target ConnectionTarget, explicitPort ...uint16) types.GomegaMatcher
func IsMessagePartOfStream ¶
Types ¶
type CheckCmd ¶
type CheckCmd struct {
// contains filtered or unexported fields
}
CheckCmd is exported solely for the sake of CheckOption and should not be use on its own
type CheckOption ¶
type CheckOption func(cmd *CheckCmd)
CheckOption is the option format for Check()
func WithDuration ¶
func WithDuration(duration time.Duration) CheckOption
func WithNamespacePath ¶
func WithNamespacePath(nsPath string) CheckOption
func WithRecvLen ¶
func WithRecvLen(l int) CheckOption
func WithSendLen ¶
func WithSendLen(l int) CheckOption
func WithSourceIP ¶
func WithSourceIP(ip string) CheckOption
WithSourceIP tell the check what source IP to use
func WithSourcePort ¶
func WithSourcePort(port string) CheckOption
WithSourcePort tell the check what source port to use
func WithTimeout ¶
func WithTimeout(t time.Duration) CheckOption
type Checker ¶
type Checker struct { ReverseDirection bool Protocol string // "tcp" or "udp" CheckSNAT bool RetriesDisabled bool StaggerStartBy time.Duration // OnFail, if set, will be called instead of ginkgo.Fail(). (Useful for testing the checker itself.) OnFail func(msg string) // contains filtered or unexported fields }
ConnectivityChecker records a set of connectivity expectations and supports calculating the actual state of the connectivity between the given workloads. It is expected to be used like so:
var cc = &connectivity.Checker{} cc.Expect(None, w[2], w[0], 1234) cc.Expect(Some, w[1], w[0], 5678) cc.Expect(Some, w[1], w[0], 4321, ExpectWithABC, ExpectWithXYZ) cc.CheckConnectivity()
func (*Checker) ActualConnectivity ¶
ActualConnectivity calculates the current connectivity for all the expected paths. It returns a slice containing one response for each attempted check (or nil if the check failed) along with a same-length slice containing a pretty-printed description of the check and its result.
func (*Checker) CheckConnectivity ¶
func (c *Checker) CheckConnectivity(opts ...interface{})
func (*Checker) CheckConnectivityOffset ¶
func (*Checker) CheckConnectivityPacketLoss ¶
func (c *Checker) CheckConnectivityPacketLoss(opts ...interface{})
func (*Checker) CheckConnectivityWithTimeout ¶
func (*Checker) CheckConnectivityWithTimeoutOffset ¶
func (*Checker) Expect ¶
func (c *Checker) Expect(expected Expected, from ConnectionSource, to ConnectionTarget, opts ...ExpectationOption)
Expect asserts existing connectivity between a ConnectionSource and ConnectionTarget with details configurable with ExpectationOption(s). This is a super set of ExpectSome()
func (*Checker) ExpectLoss ¶
func (c *Checker) ExpectLoss(from ConnectionSource, to ConnectionTarget, duration time.Duration, maxPacketLossPercent float64, maxPacketLossNumber int, explicitPort ...uint16)
func (*Checker) ExpectNone ¶
func (c *Checker) ExpectNone(from ConnectionSource, to ConnectionTarget, explicitPort ...uint16)
func (*Checker) ExpectSNAT ¶
func (c *Checker) ExpectSNAT(from ConnectionSource, srcIP string, to ConnectionTarget, explicitPort ...uint16)
func (*Checker) ExpectSome ¶
func (c *Checker) ExpectSome(from ConnectionSource, to ConnectionTarget, explicitPort ...uint16)
func (*Checker) ExpectedConnectivityPretty ¶
ExpectedConnectivityPretty returns one string per recorded expectation in order, encoding the expected connectivity in similar format used by ActualConnectivity().
func (*Checker) ResetExpectations ¶
func (c *Checker) ResetExpectations()
type CheckerOpt ¶
type CheckerOpt func(*Checker)
CheckerOpt is an option to CheckConnectivity()
func CheckWithBeforeRetry ¶
func CheckWithBeforeRetry(f func()) CheckerOpt
CheckWithBeforeRetry sets a function executed after an attempt failed and before we retry.
func CheckWithDescription ¶
func CheckWithDescription(desc string) CheckerOpt
CheckWithDescription sets a description of a failure.
func CheckWithFinalTest ¶
func CheckWithFinalTest(f func() error) CheckerOpt
func CheckWithInit ¶
func CheckWithInit(f func()) CheckerOpt
type ConnConfig ¶
func (ConnConfig) GetTestMessage ¶
func (cc ConnConfig) GetTestMessage(sequence int) Request
Assembly a test message.
func (ConnConfig) GetTestMessageSequence ¶
func (cc ConnConfig) GetTestMessageSequence(msg string) (int, error)
Extract sequence number from test message.
type ConnectionSource ¶
type ConnectionSource interface { PreRetryCleanup(ip, port, protocol string, opts ...CheckOption) CanConnectTo(ip, port, protocol string, opts ...CheckOption) *Result SourceName() string SourceIPs() []string }
type ConnectionTarget ¶
type ExpPacketLoss ¶
type Expectation ¶
type Expectation struct { From ConnectionSource // Workload or Container To *Matcher // Workload or IP, + port Expected Expected ExpSrcIPs []string ExpectedPacketLoss ExpPacketLoss ErrorStr string // contains filtered or unexported fields }
func (Expectation) DestIP ¶
func (e Expectation) DestIP() string
type ExpectationOption ¶
type ExpectationOption func(e *Expectation)
func ExpectNoneWithError ¶
func ExpectNoneWithError(ErrorStr string) ExpectationOption
func ExpectWithClientAdjustedMTU ¶
func ExpectWithClientAdjustedMTU(from, to int) ExpectationOption
ExpectWithClientAdjustedMTU asserts that the connection MTU should change during the transfer
func ExpectWithIPVersion ¶
func ExpectWithIPVersion(ipVersion int) ExpectationOption
func ExpectWithLoss ¶
func ExpectWithLoss(duration time.Duration, maxPacketLossPercent float64, maxPacketLossNumber int) ExpectationOption
ExpectWithLoss asserts that the connection has a certain loss rate
func ExpectWithPorts ¶
func ExpectWithPorts(ports ...uint16) ExpectationOption
func ExpectWithRecvLen ¶
func ExpectWithRecvLen(l int) ExpectationOption
ExpectWithRecvLen asserts how much additional data on top of the original response should be received with success
func ExpectWithSendLen ¶
func ExpectWithSendLen(l int) ExpectationOption
ExpectWithSendLen asserts how much additional data on top of the original requests should be sent with success
func ExpectWithSrcIPs ¶
func ExpectWithSrcIPs(ips ...string) ExpectationOption
func ExpectWithSrcPort ¶
func ExpectWithSrcPort(port uint16) ExpectationOption
type Matcher ¶
type Matcher struct {
IP, Port, TargetName, Protocol, IP6 string
}
func (*Matcher) FailureMessage ¶
func (*Matcher) NegatedFailureMessage ¶
type PersistentConnection ¶
type PersistentConnection struct { sync.Mutex RuntimeName string Runtime Runtime Name string Protocol string IP string Port int SourcePort int MonitorConnectivity bool NamespacePath string Timeout time.Duration // contains filtered or unexported fields }
func (*PersistentConnection) LastPongTime ¶
func (pc *PersistentConnection) LastPongTime() time.Time
func (*PersistentConnection) PongCount ¶
func (pc *PersistentConnection) PongCount() int
func (*PersistentConnection) SinceLastPong ¶
func (pc *PersistentConnection) SinceLastPong() time.Duration
func (*PersistentConnection) Start ¶
func (pc *PersistentConnection) Start() error
func (*PersistentConnection) Stop ¶
func (pc *PersistentConnection) Stop()
type Request ¶
func NewRequest ¶
type Response ¶
type Result ¶
func Check ¶
func Check(cName, logMsg, ip, port, protocol string, opts ...CheckOption) *Result
Check executes the connectivity check
func (*Result) HasConnectivity ¶
func (Result) PrintToStdout ¶
func (r Result) PrintToStdout()
type Stats ¶
func (Stats) LostPercent ¶
type TargetIPv4AsIPv6 ¶
type TargetIPv4AsIPv6 string
func (TargetIPv4AsIPv6) ToMatcher ¶
func (s TargetIPv4AsIPv6) ToMatcher(explicitPort ...uint16) *Matcher