harness

package
v0.0.0-...-ba09d25 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Overview

Package harness holds utility code for running benchmarks on Docker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugLog

func DebugLog(b *testing.B, msg string, args ...interface{})

DebugLog prints debug messages if the debug flag is set.

func DropCaches

func DropCaches(machine Machine) error

DropCaches drops caches on the provided machine. Requires root.

func Init

func Init() error

Init performs any harness initilialization before runs.

func MakeMount

func MakeMount(machine Machine, fsType FileSystemType, cu *cleanup.Cleanup) ([]mount.Mount, string, error)

MakeMount makes a mount and cleanup based on the requested type. Bind and volume mounts are backed by a temp directory made with mktemp. tmpfs mounts require no such backing and are just made. rootfs mounts do not make a mount, but instead return a target direectory at root. It is up to the caller to call Clean on the passed *cleanup.Cleanup

func SetFixedBenchmarks

func SetFixedBenchmarks()

SetFixedBenchmarks causes all benchmarks to run once.

This must be set if they cannot scale with N. Note that this uses 1ns instead of 1x due to https://github.com/golang/go/issues/32051.

func WaitUntilServing

func WaitUntilServing(ctx context.Context, machine Machine, server net.IP, port int) error

WaitUntilServing grabs a container from `machine` and waits for a server at IP:port.

Types

type FileSystemType

type FileSystemType string

FileSystemType represents a type container mount.

const (
	// BindFS indicates a bind mount should be created.
	BindFS FileSystemType = "bindfs"
	// TmpFS indicates a tmpfs mount should be created.
	TmpFS FileSystemType = "tmpfs"
	// RootFS indicates no mount should be created and the root mount should be used.
	RootFS FileSystemType = "rootfs"
)

type Machine

type Machine interface {
	// GetContainer gets a container from the machine. The container uses the
	// runtime under test and is profiled if requested by flags.
	GetContainer(ctx context.Context, log testutil.Logger) *dockerutil.Container

	// GetNativeContainer gets a native container from the machine. Native containers
	// use runc by default and are not profiled.
	GetNativeContainer(ctx context.Context, log testutil.Logger) *dockerutil.Container

	// RunCommand runs cmd on this machine.
	RunCommand(cmd string, args ...string) (string, error)

	// Returns IP Address for the machine.
	IPAddress() (net.IP, error)

	// CleanUp cleans up this machine.
	CleanUp()
}

Machine describes a real machine for use in benchmarks.

func GetMachine

func GetMachine() (Machine, error)

GetMachine returns this run's implementation of machine.

Jump to

Keyboard shortcuts

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