assertions

package
v1.17.8 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SafeTimeToSyncStats represents a safe estimate for metrics reporting interval. We provide a buffer beyond
	// the time that metrics reporting occurs, to account for latencies. Tests should use the SafeTimeToSyncStats
	// to ensure that we are polling the stats endpoints infrequently enough that they will have updated each time
	SafeTimeToSyncStats = timeToSyncStats + time.Second*3
)

Variables

View Source
var CommonLeakOptions = []types.GomegaMatcher{
	gleak.IgnoringTopFunction("os/exec..."),
	gleak.IgnoringTopFunction("internal/poll.runtime_pollWait"),
}

CommonLeakOptions are options to ignore in the goroutine leak detector If we are running tests, we will likely have the test framework running and will expect to see these goroutines

View Source
var DefaultStatsPortFwd = StatsPortFwd{
	ResourceName:      "deployment/gloo",
	ResourceNamespace: defaults.GlooSystem,
	LocalPort:         stats.DefaultPort,
	TargetPort:        stats.DefaultPort,
}

DefaultStatsPortFwd is a commonly used port-forward configuration, since Gloo Deployment stats are the most valuable This is used in Gloo Enterprise

Functions

func EventuallyStatisticsMatchAssertions

func EventuallyStatisticsMatchAssertions(statsPortFwd StatsPortFwd, assertions ...types.AsyncAssertion)

EventuallyStatisticsMatchAssertions first opens a fort-forward and then performs a series of Asynchronous assertions. The fort-forward is cleaned up with the function returns

func EventuallyWithOffsetStatisticsMatchAssertions

func EventuallyWithOffsetStatisticsMatchAssertions(offset int, statsPortFwd StatsPortFwd, assertions ...types.AsyncAssertion)

EventuallyWithOffsetStatisticsMatchAssertions first opens a fort-forward and then performs a series of Asynchronous assertions. The fort-forward is cleaned up with the function returns

func ExpectNumFields added in v1.17.1

func ExpectNumFields(obj interface{}, numFields int)

ExpectNumFields asserts that the given struct contains the given number of fields

func ExpectStatLastValueMatches added in v1.15.19

func ExpectStatLastValueMatches(measure *stats2.Int64Measure, lastValueMatcher types.GomegaMatcher)

ExpectStatLastValueMatches is a helper function that retrieves the last value of a statistic and asserts that it matches the passed matcher

func ExpectStatSumMatches added in v1.15.19

func ExpectStatSumMatches(measure *stats2.Int64Measure, sumValueMatcher types.GomegaMatcher)

ExpectStatSumMatches is a helper function that retrieves the sum of a statistic and asserts that it matches the passed matcher

func IntStatisticReachesConsistentValueAssertion

func IntStatisticReachesConsistentValueAssertion(prometheusStat string, inARow int) (types.AsyncAssertion, *int)

IntStatisticReachesConsistentValueAssertion returns an assertion that a prometheus stats has reached a consistent value It optionally returns the value of that statistic as well Arguments:

prometheusStat (string) - The name of the statistic we will be evaluating
inARow (int) - We periodically poll the statistic value from a metrics endpoint. InARow represents
			   the number of consecutive times the statistic must be the same for it to be considered "consistent"
			   For example, if InARow=4, we must poll the endpoint 4 times consecutively and return the same value

func LogLevelAssertion

func LogLevelAssertion(logLevel zapcore.Level) types.AsyncAssertion

LogLevelAssertion returns an Assertion to verify that the dynamic log level matches the provided value

Types

type ExpectNoLeaksArgs added in v1.17.1

type ExpectNoLeaksArgs struct {
	// Goroutines to ignore in addition to those stored in the GoroutineMonitor's goroutines field. See CommonLeakOptions for example.
	AllowedRoutines []types.GomegaMatcher
	// Additional arguments to pass to Eventually to control the timeout/polling interval.
	// If not set, defaults to 5 second timeout and the Gomega default polling interval (10ms)
	Timeouts []interface{}
}

type GoRoutineMonitor added in v1.17.1

type GoRoutineMonitor struct {
	// contains filtered or unexported fields
}

func NewGoRoutineMonitor added in v1.17.1

func NewGoRoutineMonitor() *GoRoutineMonitor

func (*GoRoutineMonitor) ExpectNoLeaks added in v1.17.1

func (m *GoRoutineMonitor) ExpectNoLeaks(args *ExpectNoLeaksArgs)

type StatsPortFwd

type StatsPortFwd struct {
	ResourceName      string
	ResourceNamespace string
	LocalPort         int
	TargetPort        int
}

StatsPortFwd represents the set of configuration required to generated port-forward to access statistics locally

Jump to

Keyboard shortcuts

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