util

package
v2.25.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendReport

func AppendReport(report, toAppend *reporters.JUnitTestSuite)

AppendReport appends a reporters.JUnitTestSuite to another. During that process, test cases are deduplicated (identified via their name). Successful or failing test cases always take precedence over skipped test cases.

func JUnitWrapper

func JUnitWrapper(testCaseName string, report *reporters.JUnitTestSuite, executor func() error, extraErrOutputFn ...func() string) error

JUnitWrapper is a convenience func to get junit results for a step It will create a report, append it to the passed in testsuite and propagate the error of the executor back up TODO: Should we add optional retrying here to limit the amount of wrappers we need?

func MeasuredRetryN

func MeasuredRetryN(
	runtimeMetric *prometheus.GaugeVec,

	attemptsMetric prometheus.Gauge,
	log *zap.SugaredLogger,
	delay time.Duration,
	maxAttempts int,
	f func(attempt int) error,
) func() error

measuredRetryN wraps retryNAttempts with code that counts the executed number of attempts and the runtimes for each attempt.

func NodeIsReady

func NodeIsReady(node corev1.Node) bool

func PodIsCompleted added in v2.24.0

func PodIsCompleted(p *corev1.Pod) bool

func PodIsReady

func PodIsReady(p *corev1.Pod) bool

func RetryN

func RetryN(delay time.Duration, maxAttempts int, f func(attempt int) error) error

Types

type GinkgoResult

type GinkgoResult struct {
	Logfile  string
	Report   *reporters.JUnitTestSuite
	Duration time.Duration
}

type GinkgoRun

type GinkgoRun struct {
	Name       string
	Cmd        *exec.Cmd
	ReportsDir string
	Timeout    time.Duration
}

func (*GinkgoRun) Run

func (r *GinkgoRun) Run(ctx context.Context, parentLog *zap.SugaredLogger, client ctrlruntimeclient.Client) (*GinkgoResult, error)

type JUnitTestSuites added in v2.22.0

type JUnitTestSuites struct {
	XMLName    xml.Name                   `xml:"testsuites"`
	Tests      int                        `xml:"tests,attr"`
	Disabled   int                        `xml:"disabled,attr"`
	Errors     int                        `xml:"errors,attr"`
	Failures   int                        `xml:"failures,attr"`
	Time       float64                    `xml:"time,attr"`
	TestSuites []reporters.JUnitTestSuite `xml:"testsuite"`
}

JUnitTestSuites is copied from Ginkgo 2.x because KKP otherwise depends on Ginkgo 1.x for now. Once we migrate everything, this struct can be removed. Source: https://github.com/onsi/ginkgo/blob/9c9f45ef886e23dcb006aa245f67e91140e1e60e/reporters/junit_report.go#L24-L39

Jump to

Keyboard shortcuts

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