Help us shape the future of Go! Take the 2026 Go Developer Survey

ginkgo

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 56 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggressiveRetryStrategy

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

AggressiveRetryStrategy implements the multiple retry behavior with fixed failure threshold

func NewAggressiveRetryStrategy

func NewAggressiveRetryStrategy(maxRetries, failureThreshold int) *AggressiveRetryStrategy

func (*AggressiveRetryStrategy) DecideOutcome

func (s *AggressiveRetryStrategy) DecideOutcome(attempts []*testCase) RetryOutcome

func (*AggressiveRetryStrategy) GetMaxRetries

func (s *AggressiveRetryStrategy) GetMaxRetries(testCase *testCase) int

func (*AggressiveRetryStrategy) Name

func (s *AggressiveRetryStrategy) Name() string

func (*AggressiveRetryStrategy) ShouldAttemptRetries

func (s *AggressiveRetryStrategy) ShouldAttemptRetries(failing []*testCase, suite *TestSuite) bool

func (*AggressiveRetryStrategy) ShouldContinue

func (s *AggressiveRetryStrategy) ShouldContinue(originalFailure *testCase, allAttempts []*testCase, nextAttemptNumber int) bool

type ClusterStabilityDuringTest

type ClusterStabilityDuringTest string
var (
	// Stable means that at no point during testing do we expect a component to take downtime and upgrades are not happening.
	Stable ClusterStabilityDuringTest = "Stable"
	// TODO only bring this back if we have some reason to collect Upgrade specific information.  I can't think of reason.
	// TODO please contact @deads2k for vetting if you think you found something
	// Upgrade    ClusterStabilityDuringTest = "Upgrade"
	// Disruptive means that the suite is expected to induce outages to the cluster.
	// Some of the more sensitive monitor tests have their junit results converted to flakes
	// so that failures caused by intentional disruption are visible but cannot cause job failures.
	// Not all monitor tests are flaked — critical invariants still produce
	// hard failures.
	Disruptive ClusterStabilityDuringTest = "Disruptive"
	// SpotCheck means the job is a minimal, less-sensitive spot-check run. A subset of monitor
	// tests run, and some of the more sensitive ones have their junit results converted to flakes
	// so failures are visible but cannot cause job failures. Critical invariants still produce
	// hard failures.
	SpotCheck ClusterStabilityDuringTest = "SpotCheck"
)

type Edge

type Edge struct {
	In, Out *PodElement
}

type GinkgoRunSuiteOptions

type GinkgoRunSuiteOptions struct {
	Parallelism int
	Count       int
	FailFast    bool
	Timeout     time.Duration
	JUnitDir    string

	// ShardCount is the total number of partitions the test suite is divided into.
	// Each executor runs one of these partitions.
	ShardCount int

	// ShardStrategy is which strategy we'll use for dividing tests.
	ShardStrategy string

	// ShardID is the 1-based index of the shard this instance is responsible for running.
	ShardID int

	// SyntheticEventTests allows the caller to translate events or outside
	// context into a failure.
	SyntheticEventTests JUnitsForEvents

	ClusterStabilityDuringTest string

	IncludeSuccessOutput bool

	CommandEnv []string

	DryRun        bool
	PrintCommands bool
	genericclioptions.IOStreams

	StartTime time.Time

	ExactMonitorTests   []string
	DisableMonitorTests []string
	Extension           *extension.Extension

	// RetryStrategy controls retry behavior and final outcome decisions
	RetryStrategy RetryStrategy

	// WithHypervisorConfigJSON contains JSON configuration for hypervisor-based recovery operations
	WithHypervisorConfigJSON string
}

GinkgoRunSuiteOptions is used to run a suite of tests by invoking each test as a call to a child worker (the run-tests command).

func NewGinkgoRunSuiteOptions

func NewGinkgoRunSuiteOptions(streams genericclioptions.IOStreams) *GinkgoRunSuiteOptions

func (*GinkgoRunSuiteOptions) AsEnv

func (o *GinkgoRunSuiteOptions) AsEnv() []string

func (*GinkgoRunSuiteOptions) BindFlags

func (o *GinkgoRunSuiteOptions) BindFlags(flags *pflag.FlagSet)

func (*GinkgoRunSuiteOptions) Run

func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, clusterConfig *clusterdiscovery.ClusterConfiguration, junitSuiteName string, monitorTestInfo monitortestframework.MonitorTestInitializationInfo,
	upgrade bool) error

func (*GinkgoRunSuiteOptions) SetIOStreams

func (o *GinkgoRunSuiteOptions) SetIOStreams(streams genericclioptions.IOStreams)

func (*GinkgoRunSuiteOptions) Validate

func (o *GinkgoRunSuiteOptions) Validate() error

type HashSharder

type HashSharder struct{}

func (*HashSharder) Name

func (h *HashSharder) Name() string

func (*HashSharder) Shard

func (h *HashSharder) Shard(allTests []*testCase, shardCount, shardID int) ([]*testCase, error)

type JUnitForEventsFunc

type JUnitForEventsFunc func(events monitorapi.Intervals, duration time.Duration, kubeClientConfig *rest.Config, testSuite string, recordedResource *monitorapi.ResourcesMap) []*junitapi.JUnitTestCase

JUnitForEventsFunc converts a function into the JUnitForEvents interface. kubeClientConfig may or may not be present. The JUnit evaluation needs to tolerate a missing *rest.Config and an unavailable cluster without crashing.

func (JUnitForEventsFunc) JUnitsForEvents

func (fn JUnitForEventsFunc) JUnitsForEvents(events monitorapi.Intervals, duration time.Duration, kubeClientConfig *rest.Config, testSuite string, recordedResource *monitorapi.ResourcesMap) []*junitapi.JUnitTestCase

type JUnitsForAllEvents

type JUnitsForAllEvents []JUnitsForEvents

JUnitsForAllEvents aggregates multiple JUnitsForEvent interfaces and returns the result of all invocations. It ignores nil interfaces.

func (JUnitsForAllEvents) JUnitsForEvents

func (a JUnitsForAllEvents) JUnitsForEvents(events monitorapi.Intervals, duration time.Duration, kubeClientConfig *rest.Config, testSuite string, recordedResource *monitorapi.ResourcesMap) []*junitapi.JUnitTestCase

type JUnitsForEvents

type JUnitsForEvents interface {
	// JUnitsForEvents returns a set of additional test passes or failures implied by the
	// events sent during the test suite run. If passed is false, the entire suite is failed.
	// To set a test as flaky, return a passing and failing JUnitTestCase with the same name.
	JUnitsForEvents(events monitorapi.Intervals, duration time.Duration, kubeClientConfig *rest.Config, testSuite string, recordedResource *monitorapi.ResourcesMap) []*junitapi.JUnitTestCase
}

JUnitsForEvents returns a set of JUnit results for the provided events encountered during a test suite run.

type Kind

type Kind int
const (
	KindInternal Kind = iota
	KindExternal
)

type NoRetryStrategy

type NoRetryStrategy struct{}

func (*NoRetryStrategy) DecideOutcome

func (s *NoRetryStrategy) DecideOutcome(_ []*testCase) RetryOutcome

func (*NoRetryStrategy) GetMaxRetries

func (s *NoRetryStrategy) GetMaxRetries(_ *testCase) int

func (*NoRetryStrategy) Name

func (s *NoRetryStrategy) Name() string

func (*NoRetryStrategy) ShouldAttemptRetries

func (s *NoRetryStrategy) ShouldAttemptRetries(_ []*testCase, _ *TestSuite) bool

func (*NoRetryStrategy) ShouldContinue

func (s *NoRetryStrategy) ShouldContinue(_ *testCase, _ []*testCase, _ int) bool

type PodCollector

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

func NewPodCollector

func NewPodCollector() *PodCollector

func SetupNewPodCollector

func SetupNewPodCollector(ctx context.Context) (*PodCollector, error)

func (*PodCollector) ComputePodTransitions

func (pc *PodCollector) ComputePodTransitions()

func (*PodCollector) Import

func (pc *PodCollector) Import(data []byte) error

func (*PodCollector) JsonDump

func (pc *PodCollector) JsonDump() ([]byte, error)

func (*PodCollector) PodDisplacements

func (pc *PodCollector) PodDisplacements() PodDisplacements

func (*PodCollector) Record

func (pc *PodCollector) Record(element *PodElement)

func (*PodCollector) Run

func (pc *PodCollector) Run(ctx context.Context)

func (*PodCollector) SetEvents

func (pc *PodCollector) SetEvents(events []string)

func (*PodCollector) Setup

func (pc *PodCollector) Setup(ctx context.Context, sharedInformerFactory informers.SharedInformerFactory)

type PodDisplacements

type PodDisplacements map[string][][]Edge

func (PodDisplacements) Dump

func (pd PodDisplacements) Dump(minChainLen int) string

type PodElement

type PodElement struct {
	Namespace         string       `json:"namespace"`
	Kind              string       `json:"kind"`
	KindName          string       `json:"kindName"`
	PodName           string       `json:"podName"`
	Node              string       `json:"node"`
	CreationTimestamp metav1.Time  `json:"creationTimestamp"`
	DeletionTimestamp *metav1.Time `json:"deletionTimestamp"`
	Events            []string     `json:"events"`
}

func (*PodElement) KindOwnerKey

func (pe *PodElement) KindOwnerKey() string

func (*PodElement) String

func (pe *PodElement) String() string

func (*PodElement) UniqueKey

func (pe *PodElement) UniqueKey() string

type RetryOnceStrategy

type RetryOnceStrategy struct {
	AllowedRetryTests map[string]bool
}

func NewRetryOnceStrategy

func NewRetryOnceStrategy() *RetryOnceStrategy

func (*RetryOnceStrategy) DecideOutcome

func (s *RetryOnceStrategy) DecideOutcome(attempts []*testCase) RetryOutcome

func (*RetryOnceStrategy) GetMaxRetries

func (s *RetryOnceStrategy) GetMaxRetries(testCase *testCase) int

func (*RetryOnceStrategy) Name

func (s *RetryOnceStrategy) Name() string

func (*RetryOnceStrategy) ShouldAttemptRetries

func (s *RetryOnceStrategy) ShouldAttemptRetries(failing []*testCase, suite *TestSuite) bool

func (*RetryOnceStrategy) ShouldContinue

func (s *RetryOnceStrategy) ShouldContinue(testCase *testCase, allAttempts []*testCase, nextAttemptNumber int) bool

type RetryOutcome

type RetryOutcome int

RetryOutcome represents the decision for a multi-retry test

const (
	RetryOutcomeFail RetryOutcome = iota
	RetryOutcomeFlaky
	RetryOutcomeSkipped
)

type RetryStrategy

type RetryStrategy interface {
	// Name returns the strategy name for CLI and logging
	Name() string

	// ShouldAttemptRetries determines if we attempt any retries given the list of failing tests
	ShouldAttemptRetries(failing []*testCase, suite *TestSuite) bool

	// GetMaxRetries returns the upper bound of retries (for reporting/planning)
	GetMaxRetries(testCase *testCase) int

	// ShouldContinue determines if we continue retrying. Allows for early termination of retries.
	ShouldContinue(testCase *testCase, allAttempts []*testCase, nextAttemptNumber int) bool

	// DecideOutcome reports the final result of all attempts.
	DecideOutcome(attempts []*testCase) RetryOutcome
}

RetryStrategy controls both retry behavior and final outcome decisions Example usage:

options.RetryStrategy = NewRetryOnceStrategy()                          // Restrictive retry with rules
options.RetryStrategy = NewAggressiveRetryStrategy(10, 4)               // Aggressive multiple retries

type Sharder

type Sharder interface {
	// Shard selects tests for the given executor and total shards.
	// The returned slice must be deterministic and non-overlapping across shards.
	Shard(allTests []*testCase, shardCount, shardID int) ([]*testCase, error)

	// Name returns the name of the strategy (e.g. "hash", "time-balanced").
	Name() string
}

type TestMatchFunc

type TestMatchFunc func(name string) bool

type TestScheduler

type TestScheduler interface {
	// GetNextTestToRun blocks until a test is available, then returns it.
	// Returns nil when all tests have been distributed (queue is empty) or context is cancelled.
	// When a test is returned, it is atomically removed from queue and marked as running.
	// This method can be safely called from multiple goroutines concurrently.
	GetNextTestToRun(ctx context.Context) *testCase

	// MarkTestComplete marks a test as complete, cleaning up its conflicts and taints.
	// This may unblock other tests that were waiting.
	// This method can be safely called from multiple goroutines concurrently.
	MarkTestComplete(test *testCase)
}

TestScheduler defines the interface for test scheduling Different implementations can provide various scheduling strategies

type TestState

type TestState string
const (
	TestSucceeded     TestState = "Success"
	TestFailed        TestState = "Failed"
	TestFailedTimeout TestState = "TimedOut"
	TestFlaked        TestState = "Flaked"
	TestSkipped       TestState = "Skipped"
	TestUnknown       TestState = "Unknown"
)

type TestSuite

type TestSuite struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Kind        Kind   `json:"kind"`

	SuiteMatcher TestMatchFunc `json:"-"`

	// The number of times to execute each test in this suite.
	Count int `json:"count,omitempty"`
	// The maximum parallelism of this suite based on a minimum of 3 workers.
	// Otherwise, parallelism is automatically scaled down using 1/3 the parallelism value x the number of workers.
	// Jobs can explicitly set the parallelism value via max-parallel-tests
	Parallelism int `json:"parallelism,omitempty"`
	// The number of flakes that may occur before this test is marked as a failure.
	MaximumAllowedFlakes int `json:"maximumAllowedFlakes,omitempty"`

	ClusterStabilityDuringTest ClusterStabilityDuringTest `json:"clusterStabilityDuringTest,omitempty"`

	TestTimeout time.Duration `json:"testTimeout,omitempty"`

	// OTE
	Parents    []string              `json:"parents,omitempty"`
	Qualifiers []string              `json:"qualifiers,omitempty"`
	Extension  *extensions.Extension `json:"-"`
}

func (*TestSuite) AddRequiredMatchFunc

func (s *TestSuite) AddRequiredMatchFunc(matchFn TestMatchFunc)

func (*TestSuite) Filter

func (s *TestSuite) Filter(tests []*testCase) []*testCase

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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