Documentation ¶
Index ¶
- Constants
- func AssertMonitor(t *testing.T, ch chan string, expected []string)
- func AssertNoMore(t *testing.T, ch <-chan string)
- func AssertReadyProbe(t require.TestingT, probePort int)
- func AssertRecv(t *testing.T, ch <-chan string, label, expected string)
- func CheckReadyProbe(probePort int) bool
- func RestoreLogs()
- func RunGnatsd(port int) *server.Server
- func StripTimestamps(t *testing.T, s string) string
- func SuppressLogs()
- type FakeInfluxDB
Constants ¶
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.
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 ¶
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 ¶
AssertNoMore checks that there aren't more items received from a string channel in ShortWait time.
func AssertReadyProbe ¶
AssertReadyProbe fails a test if CheckReadyProbe returns false.
func AssertRecv ¶
AssertRecv checks that a specific string has been received from a channel. The check times out after LongWait.
func CheckReadyProbe ¶
CheckReadyProbe repeatedly tries a readiness probe on the given port. It will return true if a successful readiness probe is observed within LongWait.
func StripTimestamps ¶
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).
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.