Documentation

Overview

Package cvtesting reduces boilerplate in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DispatchRecorder

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

DispatchRecorder records dispatches in memory.

func (*DispatchRecorder) Clear

func (d *DispatchRecorder) Clear()

Clear clears all recorded dispatches.

func (*DispatchRecorder) Dispatch

func (d *DispatchRecorder) Dispatch(target string, eta time.Time)

Dispatch records a dispatch.

func (*DispatchRecorder) ETAsOf

func (d *DispatchRecorder) ETAsOf(target string) []time.Time

ETAsOf returns sorted distinct ETAs for dispatches of the given target.

func (*DispatchRecorder) LatestETAof

func (d *DispatchRecorder) LatestETAof(target string) time.Time

LatestETAof returns the last ETA of the given target.

Panics if the target has no ETAs.

func (*DispatchRecorder) PopTargets

func (d *DispatchRecorder) PopTargets() []string

PopTargets returns sorted list of targets and clears the state.

func (*DispatchRecorder) Targets

func (d *DispatchRecorder) Targets() []string

Targets returns sorted list of targets.

type Test

type Test struct {
	// Cfg manipulates CV config.
	Cfg config.TestController
	// GFake is a Gerrit fake. Defaults to an empty one.
	GFake *gf.Fake
	// TreeFake is a fake Tree. Defaults to an open Tree.
	TreeFake *treetest.Fake
	// BQFake is a fake BQ client.
	BQFake *bq.Fake
	// TQDispatcher is a dispatcher with which task classes must be registered.
	//
	// Must not be set.
	TQDispatcher *tq.Dispatcher
	// TQ allows to run TQ tasks.
	TQ *tqtesting.Scheduler
	// Clock allows to move time forward.
	// By default, the time is moved automatically is something waits on it.
	Clock testclock.TestClock

	// MaxDuration limits how long a test can run as a fail safe.
	//
	// Defaults to 10s to most likely finish in pre/post submit tests,
	// with limited CPU resources.
	// Set to ~10ms when debugging a hung test.
	MaxDuration time.Duration

	// AppID overrides default AppID for in-memory tests.
	AppID string
	// contains filtered or unexported fields
}

Test encapsulates typical setup for CV test.

Typical use:

ct := cvtesting.Test{}
ctx, cancel := ct.SetUp()
defer cancel()

func (*Test) DisableCVRunManagement

func (t *Test) DisableCVRunManagement(ctx context.Context)

DisableCVRunManagement disables CV Run management for all projects.

Not goroutine-safe, do not call concurrently.

func (*Test) EnableCVRunManagement

func (t *Test) EnableCVRunManagement(ctx context.Context, lProject string)

EnableCVRunManagement opts in the given project for CV managing Runs.

Can be called multiple times to add more than 1 project. Not goroutine-safe, do not call concurrently.

func (*Test) RoundTestClock

func (t *Test) RoundTestClock(multiple time.Duration)

func (*Test) SetUp

func (t *Test) SetUp() (ctx context.Context, deferme func())

Directories

Path Synopsis
Package benchmarks contains benchmarks for heavy CV use cases.
Package benchmarks contains benchmarks for heavy CV use cases.
Package e2e contains all CV end-to-end tests.
Package e2e contains all CV end-to-end tests.