testutil

package
v0.0.0-...-54c1940 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(dir string) (url string, cl func() error, err error)

func OfficialImages

func OfficialImages(names ...string) map[string]string

func Register

func Register(w Worker)

func ReportAlloc

func ReportAlloc(b *testing.B, value int64)

func ReportMetric

func ReportMetric(b *testing.B, value float64, unit MetricUnit)

func ReportMetricDuration

func ReportMetricDuration(b *testing.B, value time.Duration)

func Run

func Run(tb testing.TB, runners []Runner, opt ...TestOpt)

func RunTest

func RunTest(tb testing.TB, testFunc func(tb testing.TB, sb Sandbox))

Types

type Backend

type Backend interface {
	Address() string
	DebugAddress() string
	ExtraEnv() []string
	BuildxBin() string
	BuildxConfigDir() string
	BuilderName() string
}

Backend describes a testing backend.

type BackendConfig

type BackendConfig struct {
	Logs         map[string]*bytes.Buffer
	DaemonConfig []ConfigUpdater
	BuildxBin    string
}

BackendConfig is used to configure backends created by a worker.

type Bench

type Bench interface {
	Runner
}

type ConfigUpdater

type ConfigUpdater interface {
	UpdateConfigFile(string) string
}

type MetricUnit

type MetricUnit string
const (
	MetricAlloc    MetricUnit = "alloc"
	MetricBytes    MetricUnit = "bytes"
	MetricDuration MetricUnit = "duration"
)

type MultiCloser

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

func (*MultiCloser) Append

func (mc *MultiCloser) Append(f func() error)

func (*MultiCloser) F

func (mc *MultiCloser) F() func() error

type Ref

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

func (*Ref) Name

func (c *Ref) Name() string

func (*Ref) New

func (c *Ref) New(ctx context.Context, cfg *BackendConfig) (b Backend, cl func() error, err error)

type Runner

type Runner interface {
	Name() string
	Run(tb testing.TB, sb Sandbox)
}

func BenchFuncs

func BenchFuncs(funcs ...func(b *testing.B, sb Sandbox)) []Runner

func TestFuncs

func TestFuncs(funcs ...func(t *testing.T, sb Sandbox)) []Runner

type Sandbox

type Sandbox interface {
	Backend

	Context() context.Context
	Logs() map[string]*bytes.Buffer
	PrintLogs(testing.TB)
	WriteLogs(testing.TB)
	ClearLogs()
	WriteLogFile(testing.TB, string, []byte)
	Value(string) interface{} // chosen matrix value
	Name() string
	BuildKitBinsDir() string
}

type Test

type Test interface {
	Runner
}

type TestConfig

type TestConfig struct {
	Defaults TestConfigDefaults       `yaml:"defaults"`
	Runs     map[string]TestConfigRun `yaml:"runs"`
}

func LoadTestConfig

func LoadTestConfig(f string) (*TestConfig, error)

func (*TestConfig) BenchmarkConfig

func (t *TestConfig) BenchmarkConfig(name string) (*TestConfigBenchmark, error)

type TestConfigBenchmark

type TestConfigBenchmark struct {
	Description string                      `yaml:"description"`
	Scope       string                      `yaml:"scope,omitempty" json:",omitempty"`
	Count       int                         `yaml:"count,omitempty" json:",omitempty"`
	Benchtime   string                      `yaml:"benchtime,omitempty" json:",omitempty"`
	Metrics     map[string]TestConfigMetric `yaml:"metrics"`
}

type TestConfigDefaults

type TestConfigDefaults struct {
	Count     int    `yaml:"count"`
	Benchtime string `yaml:"benchtime"`
}

type TestConfigMetric

type TestConfigMetric struct {
	Description string `yaml:"description"`
	Chart       string `yaml:"chart"`
	Average     bool   `yaml:"average"`
}

type TestConfigRun

type TestConfigRun map[string]TestConfigBenchmark

type TestOpt

type TestOpt func(*testConf)

TestOpt is an option that can be used to configure a set of tests.

func WithMatrix

func WithMatrix(key string, m map[string]interface{}) TestOpt

func WithMirroredImages

func WithMirroredImages(m map[string]string) TestOpt

type Worker

type Worker interface {
	New(context.Context, *BackendConfig) (Backend, func() error, error)
	Name() string
}

func List

func List() []Worker

Jump to

Keyboard shortcuts

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