test

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SeriesID is the expected id for the generated series
	SeriesID string
	// SeriesNamespace is the expected namespace for the generated series
	SeriesNamespace string
	// TestTags is the expected tags for the generated series
	TestTags map[string]string
	// BlockSize is the expected block size for the generated series
	BlockSize time.Duration
	// Start is the expected start time for the first block in the generated series
	Start time.Time
	// SeriesStart is the expected start time for the generated series
	SeriesStart time.Time
	// Middle is the expected end for the first block, and start of the second block
	Middle time.Time
	// End is the expected end time for the generated series
	End time.Time
)

Functions

func BuildTestSeriesIterator

func BuildTestSeriesIterator() (encoding.SeriesIterator, error)

BuildTestSeriesIterator creates a sample SeriesIterator This series iterator has two identical replicas. Each replica has two blocks. The first block in each replica is merged and has values 1->30 The values 1 and 2 appear before the SeriesIterator start time, and are not expected to appear when reading through the iterator The second block is unmerged; when it was merged, it has values 101 -> 130 from two readers, one with even values and other with odd values Expected data points for reading through the iterator: [3..30,101..130], 58 in total SeriesIterator ID is 'foo', namespace is 'namespace' Tags are "foo": "bar" and "baz": "qux"

func EqualsWithNans

func EqualsWithNans(t *testing.T, expected interface{}, actual interface{})

EqualsWithNans helps compare float slices which have NaNs in them

func GeneratePromReadBody

func GeneratePromReadBody(t *testing.T) io.Reader

GeneratePromReadBody generates a sample snappy encoded prometheus remote read request body

func GeneratePromReadRequest

func GeneratePromReadRequest() *prompb.ReadRequest

GeneratePromReadRequest generates a sample prometheus remote read request

func GenerateValuesAndBounds

func GenerateValuesAndBounds(vals [][]float64, b *block.Bounds) ([][]float64, block.Bounds)

GenerateValuesAndBounds generates a list of sample values and bounds while allowing overrides

func NewBlockFromValues

func NewBlockFromValues(bounds block.Bounds, seriesValues [][]float64) block.Block

NewBlockFromValues creates a new block using the provided values

func NewBlockFromValuesWithMetaAndSeriesMeta added in v0.4.1

func NewBlockFromValuesWithMetaAndSeriesMeta(
	meta block.Metadata,
	seriesMeta []block.SeriesMeta,
	seriesValues [][]float64,
) block.Block

NewBlockFromValuesWithMetaAndSeriesMeta creates a new block using the provided values

func NewBlockFromValuesWithSeriesMeta added in v0.4.1

func NewBlockFromValuesWithSeriesMeta(
	bounds block.Bounds,
	seriesMeta []block.SeriesMeta,
	seriesValues [][]float64,
) block.Block

NewBlockFromValuesWithSeriesMeta creates a new block using the provided values

func NewMultiBlocksFromValues added in v0.4.1

func NewMultiBlocksFromValues(bounds block.Bounds, seriesValues [][]float64, valueMod ValueMod, numBlocks int) []block.Block

NewMultiBlocksFromValues creates new blocks using the provided values and a modifier

func NewSeriesMeta added in v0.4.1

func NewSeriesMeta(tagPrefix string, count int) []block.SeriesMeta

NewSeriesMeta creates new metadata tags in the format [tagPrefix:i] for the number of series

func NewSlowStorage

func NewSlowStorage(storage storage.Storage, delay time.Duration) storage.Storage

NewSlowStorage creates a new slow storage

func NoopMod added in v0.4.1

func NoopMod(v []float64) []float64

NoopMod can be used to generate multi blocks when no value modification is needed

Types

type SlowHandler

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

SlowHandler slows down a request by delay

func NewSlowHandler

func NewSlowHandler(handler http.Handler, delay time.Duration) *SlowHandler

NewSlowHandler creates a new slow handler

func (*SlowHandler) ServeHTTP

func (h *SlowHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.handler

type ValueMod added in v0.4.1

type ValueMod func([]float64) []float64

ValueMod can be used to modify provided values for testing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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