spouttest

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LongWait = 10 * time.Second

LongWait should be used in tests when waiting for events that are expected to happen. It is quite long to account for slow/busy test hosts. Typically only a fraction of this time is actually used, unless something is broken.

View Source
const ShortWait = 50 * time.Millisecond

ShortWait should be used in tests when checking for events that are expected *not* to happen. A test will block for this long, unless something is broken.

Variables

This section is empty.

Functions

func AssertMonitor

func AssertMonitor(t *testing.T, ch chan string, expected []string)

AssertMonitor ensures that a number of lines have been from a component's statistician goroutine. The target lines may arrive in any order and non-matching lines are ignored. Timestamps on the received lines are checked for and then stripped.

func AssertNoMore

func AssertNoMore(t *testing.T, ch <-chan string)

AssertNoMore checks that there aren't more items received from a string channel in ShortWait time.

func AssertReadyProbe

func AssertReadyProbe(t require.TestingT, probePort int)

AssertReadyProbe fails a test if CheckReadyProbe returns false.

func AssertRecv

func AssertRecv(t *testing.T, ch <-chan string, label, expected string)

AssertRecv checks that a specific string has been received from a channel. The check times out after LongWait.

func CheckReadyProbe

func CheckReadyProbe(probePort int) bool

CheckReadyProbe repeatedly tries a readiness probe on the given port. It will return true if a successful readiness probe is observed within LongWait.

func RestoreLogs added in v1.1.0

func RestoreLogs()

RestoreLogs causes log output globally to be sent to stderr.

func RunGnatsd

func RunGnatsd(port int) *server.Server

RunGnatsd runs a gnatsd server on the specified port for testing against.

func StripTimestamps

func StripTimestamps(t *testing.T, s string) string

StripTimestamps takes a string containing one or more metrics lines, validates that each line appears to end with a timestamp and then strips the timestamp off. The returned string is the same as the input but without the timestamps (for easier test comparisons).

func SuppressLogs added in v1.1.0

func SuppressLogs()

SuppressLogs causes log output globally to be discarded.

Types

type FakeInfluxDB

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

FakeInfluxDB implements a simple listener which mimics InfluxDB's HTTP write API, recording writes for later inspection.

func RunFakeInfluxd

func RunFakeInfluxd(port int) *FakeInfluxDB

RunFakeInfluxd starts a fake influxd instance with the HTTP port given. Stop() should be called on the returned instance once it is no longer needed.

func (*FakeInfluxDB) DatabaseCount

func (f *FakeInfluxDB) DatabaseCount() int

DatabaseCount returns the number of databases that have been written to.

func (*FakeInfluxDB) Lines

func (f *FakeInfluxDB) Lines(dbName string) []string

Lines returned the lines received for a given "database".

func (*FakeInfluxDB) Stop

func (f *FakeInfluxDB) Stop()

Stop shuts down the instance's server. It blocks until the server is stopped.

Jump to

Keyboard shortcuts

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