Documentation ¶
Index ¶
- Constants
- func AddDelay(blockID ulid.ULID, dir string, blockDelay time.Duration) (ulid.ULID, error)
- func AlertmanagerBinary() string
- func Copy(t testing.TB, src, dst string)
- func CreateBlock(ctx context.Context, dir string, series []labels.Labels, numSamples int, ...) (id ulid.ULID, err error)
- func CreateBlockWithBlockDelay(ctx context.Context, dir string, series []labels.Labels, numSamples int, ...) (ulid.ULID, error)
- func CreateBlockWithChurn(ctx context.Context, rnd *rand.Rand, dir string, series []labels.Labels, ...) (id ulid.ULID, err error)
- func CreateBlockWithTombstone(ctx context.Context, dir string, series []labels.Labels, numSamples int, ...) (id ulid.ULID, err error)
- func CreateEmptyBlock(dir string, mint, maxt int64, extLset labels.Labels, resolution int64) (ulid.ULID, error)
- func CreateFloatHistogramBlockWithDelay(ctx context.Context, dir string, series []labels.Labels, numSamples int, ...) (id ulid.ULID, err error)
- func CreateHistogramBlockWithDelay(ctx context.Context, dir string, series []labels.Labels, numSamples int, ...) (id ulid.ULID, err error)
- func ForeachPrometheus(t *testing.T, testFn func(t testing.TB, p *Prometheus))
- func FreePort() (int, error)
- func MinioBinary() string
- func NewTSDB() (*tsdb.DB, error)
- func PrometheusBinary() string
- func RandRange(rnd *rand.Rand, min, max int64) int64
- func SysProcAttr() *syscall.SysProcAttr
- type Prometheus
- func (p *Prometheus) Addr() string
- func (p *Prometheus) Appender() storage.Appender
- func (p *Prometheus) Dir() string
- func (p *Prometheus) DisableCompaction()
- func (p *Prometheus) Restart(ctx context.Context, l log.Logger) error
- func (p *Prometheus) SetConfig(s string)
- func (p *Prometheus) Start(ctx context.Context, l log.Logger) error
- func (p *Prometheus) Stop() (rerr error)
Constants ¶
const (
// A placeholder for actual Prometheus instance address in the scrape config.
PromAddrPlaceHolder = "PROMETHEUS_ADDRESS"
)
Variables ¶
This section is empty.
Functions ¶
func AlertmanagerBinary ¶
func AlertmanagerBinary() string
func CreateBlock ¶
func CreateBlock( ctx context.Context, dir string, series []labels.Labels, numSamples int, mint, maxt int64, extLset labels.Labels, resolution int64, hashFunc metadata.HashFunc, ) (id ulid.ULID, err error)
CreateBlock writes a block with the given series and numSamples samples each. Samples will be in the time range [mint, maxt).
func CreateBlockWithBlockDelay ¶
func CreateBlockWithBlockDelay( ctx context.Context, dir string, series []labels.Labels, numSamples int, mint, maxt int64, blockDelay time.Duration, extLset labels.Labels, resolution int64, hashFunc metadata.HashFunc, ) (ulid.ULID, error)
CreateBlockWithBlockDelay writes a block with the given series and numSamples samples each. Samples will be in the time range [mint, maxt) Block ID will be created with a delay of time duration blockDelay.
func CreateBlockWithChurn ¶ added in v0.35.0
func CreateBlockWithChurn( ctx context.Context, rnd *rand.Rand, dir string, series []labels.Labels, numSamples int, mint, maxt int64, extLset labels.Labels, resolution int64, scrapeInterval int64, seriesSize int64, ) (id ulid.ULID, err error)
CreateBlockWithChurn writes a block with the given series. Start time of each series will be randomized in the given time window to create churn. Only float chunk is supported right now.
func CreateBlockWithTombstone ¶
func CreateBlockWithTombstone( ctx context.Context, dir string, series []labels.Labels, numSamples int, mint, maxt int64, extLset labels.Labels, resolution int64, hashFunc metadata.HashFunc, ) (id ulid.ULID, err error)
CreateBlockWithTombstone is same as CreateBlock but leaves tombstones which mimics the Prometheus local block.
func CreateEmptyBlock ¶
func CreateEmptyBlock(dir string, mint, maxt int64, extLset labels.Labels, resolution int64) (ulid.ULID, error)
CreateEmptyBlock produces empty block like it was the case before fix: https://github.com/prometheus/tsdb/pull/374. (Prometheus pre v2.7.0).
func CreateFloatHistogramBlockWithDelay ¶ added in v0.34.0
func CreateFloatHistogramBlockWithDelay( ctx context.Context, dir string, series []labels.Labels, numSamples int, mint, maxt int64, blockDelay time.Duration, extLset labels.Labels, resolution int64, hashFunc metadata.HashFunc, ) (id ulid.ULID, err error)
CreateFloatHistogramBlockWithDelay writes a block with the given float native histogram series and numSamples samples each. Samples will be in the time range [mint, maxt).
func CreateHistogramBlockWithDelay ¶ added in v0.31.0
func CreateHistogramBlockWithDelay( ctx context.Context, dir string, series []labels.Labels, numSamples int, mint, maxt int64, blockDelay time.Duration, extLset labels.Labels, resolution int64, hashFunc metadata.HashFunc, ) (id ulid.ULID, err error)
CreateHistogramBlockWithDelay writes a block with the given native histogram series and numSamples samples each. Samples will be in the time range [mint, maxt).
func ForeachPrometheus ¶
func ForeachPrometheus(t *testing.T, testFn func(t testing.TB, p *Prometheus))
func MinioBinary ¶
func MinioBinary() string
func PrometheusBinary ¶
func PrometheusBinary() string
func SysProcAttr ¶
func SysProcAttr() *syscall.SysProcAttr
Types ¶
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus represents a test instance for integration testing. It can be populated with data before being started.
func NewPrometheus ¶
func NewPrometheus() (*Prometheus, error)
NewPrometheus creates a new test Prometheus instance that will listen on local address. Use ForeachPrometheus if you want to test against set of Prometheus versions. TODO(bwplotka): Improve it with https://github.com/thanos-io/thanos/issues/758.
func NewPrometheusOnPath ¶
func NewPrometheusOnPath(prefix string) (*Prometheus, error)
NewPrometheusOnPath creates a new test Prometheus instance that will listen on local address and given prefix path.
func (*Prometheus) Addr ¶
func (p *Prometheus) Addr() string
Addr returns correct address after Start method.
func (*Prometheus) Appender ¶
func (p *Prometheus) Appender() storage.Appender
Appender returns a new appender to populate the Prometheus instance with data. All appenders must be closed before Start is called and no new ones must be opened afterwards.
func (*Prometheus) DisableCompaction ¶
func (p *Prometheus) DisableCompaction()
func (*Prometheus) SetConfig ¶
func (p *Prometheus) SetConfig(s string)
SetConfig updates the contents of the config.
func (*Prometheus) Stop ¶
func (p *Prometheus) Stop() (rerr error)
Stop terminates Prometheus and clean up its data directory.