testing

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const AssetDebug = false

AssetDebug is true if the assets were built with the debug flag enabled.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest added in v1.4.1

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString added in v1.4.1

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func BuildExpectedLog

func BuildExpectedLog(timestamp time.Time, requestId, method, path, sourceHost, sourcePort, dstHost, dstPort string) string

func BuildRequest

func BuildRequest(method, url, remoteAddr, requestId, forwardedFor string) *http.Request

func Cert

func Cert(filename string) string

func Digests added in v1.4.1

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func FormatTimeWithDecimalMillis

func FormatTimeWithDecimalMillis(t time.Time) string

func GetFreePort

func GetFreePort() int

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString added in v1.4.1

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MutualTLSClientConfig

func MutualTLSClientConfig() *tls.Config

func MutualTLSServerConfig

func MutualTLSServerConfig() *tls.Config

func NewQueryEngine

func NewQueryEngine() *promql.Engine

func NewServerRequest

func NewServerRequest(method, uri string, body io.Reader) (*http.Request, error)

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

func SkipTestOnMac added in v1.4.3

func SkipTestOnMac()

func StartGoProcess

func StartGoProcess(importPath string, env []string, args ...string) *gexec.Session

func WaitForHealthCheck

func WaitForHealthCheck(profilingAddr string, tlsConfig *tls.Config)

Types

type AlertManagerSpy

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

func NewAlertManagerSpy

func NewAlertManagerSpy(tlsConfig *tls.Config) *AlertManagerSpy

func (*AlertManagerSpy) Addr

func (a *AlertManagerSpy) Addr() string

func (*AlertManagerSpy) AlertsReceived

func (a *AlertManagerSpy) AlertsReceived() int64

func (*AlertManagerSpy) LastAlertReceived

func (a *AlertManagerSpy) LastAlertReceived() string

func (*AlertManagerSpy) Start

func (a *AlertManagerSpy) Start()

func (*AlertManagerSpy) Stop

func (a *AlertManagerSpy) Stop()

type MockAuthClient added in v1.4.3

type MockAuthClient struct {
	Calls atomic.Int32
}

func (*MockAuthClient) GetAuthHeader added in v1.4.3

func (m *MockAuthClient) GetAuthHeader() (string, error)

type Point

type Point struct {
	Time  int64
	Value float64
}

type PromRuleManagersSpy

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

func NewPromRuleManagersSpy

func NewPromRuleManagersSpy() *PromRuleManagersSpy

func (*PromRuleManagersSpy) AlertingRules

func (p *PromRuleManagersSpy) AlertingRules() []*prom_rules.AlertingRule

func (*PromRuleManagersSpy) Alertmanagers

func (p *PromRuleManagersSpy) Alertmanagers() []*url.URL

func (*PromRuleManagersSpy) Create

func (*PromRuleManagersSpy) Delete

func (p *PromRuleManagersSpy) Delete(managerId string) error

func (*PromRuleManagersSpy) DeleteAll

func (p *PromRuleManagersSpy) DeleteAll() error

func (*PromRuleManagersSpy) DroppedAlertmanagers

func (p *PromRuleManagersSpy) DroppedAlertmanagers() []*url.URL

func (*PromRuleManagersSpy) ManagerIds

func (p *PromRuleManagersSpy) ManagerIds() []string

func (*PromRuleManagersSpy) Reload

func (p *PromRuleManagersSpy) Reload() error

func (*PromRuleManagersSpy) RuleGroups

func (p *PromRuleManagersSpy) RuleGroups() []*prom_rules.Group

type RuleManagerSpy

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

func NewRuleManagerSpy

func NewRuleManagerSpy() *RuleManagerSpy

func (*RuleManagerSpy) AddDroppedAlertmanagers

func (r *RuleManagerSpy) AddDroppedAlertmanagers(urls []*url.URL)

func (*RuleManagerSpy) AlertingRules

func (r *RuleManagerSpy) AlertingRules() []*prom_rules.AlertingRule

func (*RuleManagerSpy) Alertmanagers

func (r *RuleManagerSpy) Alertmanagers() []*url.URL

func (*RuleManagerSpy) CreateManager

func (r *RuleManagerSpy) CreateManager(managerId string, alertManagers *prom_config.AlertmanagerConfigs) (*rules.Manager, error)

func (*RuleManagerSpy) DeleteManager

func (r *RuleManagerSpy) DeleteManager(managerId string) error

func (*RuleManagerSpy) DroppedAlertmanagers

func (r *RuleManagerSpy) DroppedAlertmanagers() []*url.URL

func (*RuleManagerSpy) ManagerIds

func (r *RuleManagerSpy) ManagerIds() []string

func (*RuleManagerSpy) MethodsCalled

func (r *RuleManagerSpy) MethodsCalled() []string

func (*RuleManagerSpy) RuleGroupForManager

func (r *RuleManagerSpy) RuleGroupForManager(managerId string) *rulesclient.RuleGroup

func (*RuleManagerSpy) RuleGroups

func (r *RuleManagerSpy) RuleGroups() []*prom_rules.Group

func (*RuleManagerSpy) UpsertRuleGroup

func (r *RuleManagerSpy) UpsertRuleGroup(managerId string, ruleGroup *rulesclient.RuleGroup) error

type RulesApiError

type RulesApiError struct {
	Title  string `json:"title"`
	Status int    `json:"status"`
}

type RulesApiHttpError

type RulesApiHttpError struct {
	Status int
	Title  string
}

type RulesApiResponse

type RulesApiResponse struct {
	Errors []RulesApiError `json:"errors"`
}

type RulesApiSpy

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

func NewRulesApiSpy

func NewRulesApiSpy(tlsConfig *tls.Config) (*RulesApiSpy, error)

func (*RulesApiSpy) Addr

func (a *RulesApiSpy) Addr() string

func (*RulesApiSpy) LastRequestPath

func (a *RulesApiSpy) LastRequestPath() string

func (*RulesApiSpy) NextRequestError

func (a *RulesApiSpy) NextRequestError(err *RulesApiHttpError)

func (*RulesApiSpy) RequestsReceived

func (a *RulesApiSpy) RequestsReceived() int

func (*RulesApiSpy) Start

func (a *RulesApiSpy) Start() error

func (*RulesApiSpy) Stop

func (a *RulesApiSpy) Stop()

type ScrapeTargetSpy added in v1.4.3

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

func NewScrapeTargetSpy added in v1.4.3

func NewScrapeTargetSpy(tlsConfig *tls.Config) *ScrapeTargetSpy

func (*ScrapeTargetSpy) Addr added in v1.4.3

func (spy *ScrapeTargetSpy) Addr() string

func (*ScrapeTargetSpy) ScrapesReceived added in v1.4.3

func (spy *ScrapeTargetSpy) ScrapesReceived() int32

func (*ScrapeTargetSpy) Start added in v1.4.3

func (spy *ScrapeTargetSpy) Start()

func (*ScrapeTargetSpy) Stop added in v1.4.3

func (spy *ScrapeTargetSpy) Stop()

type Series

type Series struct {
	Labels map[string]string
	Points []Point
}

func ExplodeSeriesSet

func ExplodeSeriesSet(seriesSet storage.SeriesSet) []Series

type SpyAdapter

type SpyAdapter struct {
	CommittedPoints []*rpc.Point
}

func NewSpyAdapter

func NewSpyAdapter() *SpyAdapter

func (*SpyAdapter) WritePoints

func (s *SpyAdapter) WritePoints(points []*rpc.Point) error

type SpyAppender added in v1.4.3

type SpyAppender struct {
}

func (SpyAppender) Append added in v1.6.0

func (SpyAppender) AppendExemplar added in v1.6.0

func (SpyAppender) AppendHistogram added in v1.6.0

func (SpyAppender) Commit added in v1.4.3

func (s SpyAppender) Commit() error

func (SpyAppender) Rollback added in v1.4.3

func (s SpyAppender) Rollback() error

func (SpyAppender) UpdateMetadata added in v1.6.0

type SpyHistogramObserver

type SpyHistogramObserver struct {
	sync.Mutex
	Observations []float64
}

func (*SpyHistogramObserver) Observe

func (s *SpyHistogramObserver) Observe(value float64)

type SpyLookup

type SpyLookup struct {
	HashKeys []string
	Results  map[string][]int
	// contains filtered or unexported fields
}

func NewSpyLookup

func NewSpyLookup() *SpyLookup

func (*SpyLookup) GetHashKeys

func (s *SpyLookup) GetHashKeys() []string

func (*SpyLookup) Lookup

func (s *SpyLookup) Lookup(hashKey string) []int

type SpyMetricRegistrar

type SpyMetricRegistrar struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSpyMetricRegistrar

func NewSpyMetricRegistrar() *SpyMetricRegistrar

func (*SpyMetricRegistrar) Add

func (r *SpyMetricRegistrar) Add(name string, delta float64, labels ...string)

func (*SpyMetricRegistrar) Fetch

func (r *SpyMetricRegistrar) Fetch(name string) func() float64

func (*SpyMetricRegistrar) FetchHistogram

func (r *SpyMetricRegistrar) FetchHistogram(name string) func() []float64

func (*SpyMetricRegistrar) FetchOption

func (r *SpyMetricRegistrar) FetchOption(name string) func() *float64

func (*SpyMetricRegistrar) Gatherer

func (r *SpyMetricRegistrar) Gatherer() prometheus.Gatherer

func (*SpyMetricRegistrar) Histogram

func (r *SpyMetricRegistrar) Histogram(name string, labels ...string) prometheus.Observer

func (*SpyMetricRegistrar) Inc

func (r *SpyMetricRegistrar) Inc(name string, labels ...string)

func (*SpyMetricRegistrar) Registerer

func (r *SpyMetricRegistrar) Registerer() prometheus.Registerer

func (*SpyMetricRegistrar) Set

func (r *SpyMetricRegistrar) Set(name string, value float64, labels ...string)

type SpyMetricStore

type SpyMetricStore struct {
	ReloadRequestsCount atomic.Int32

	QueryError error
	// contains filtered or unexported fields
}

func NewSpyMetricStore

func NewSpyMetricStore(tlsConfig *tls.Config) *SpyMetricStore

func (*SpyMetricStore) Addr added in v1.4.3

func (s *SpyMetricStore) Addr() string

func (*SpyMetricStore) GetInternodePoints

func (s *SpyMetricStore) GetInternodePoints() []*rpc.Point

func (*SpyMetricStore) GetLocalOnlyValues

func (s *SpyMetricStore) GetLocalOnlyValues() []bool

func (*SpyMetricStore) GetPoints

func (s *SpyMetricStore) GetPoints() []*rpc.Point

func (*SpyMetricStore) Resume

func (s *SpyMetricStore) Resume()

func (*SpyMetricStore) SetValue

func (s *SpyMetricStore) SetValue(value float64)

func (*SpyMetricStore) Start

func (*SpyMetricStore) Stop

func (s *SpyMetricStore) Stop()

type SpyMetricStoreAddrs

type SpyMetricStoreAddrs struct {
	EgressAddr    string
	IngressAddr   string
	InternodeAddr string
}

type SpyQueue added in v1.4.4

type SpyQueue struct {
	PurgeCalls atomic.Int64
}

func NewSpyQueue added in v1.4.4

func NewSpyQueue(dir string) *SpyQueue

func (*SpyQueue) Advance added in v1.4.4

func (spy *SpyQueue) Advance() error

func (*SpyQueue) Append added in v1.4.4

func (spy *SpyQueue) Append(_ []byte) error

func (*SpyQueue) Close added in v1.4.4

func (spy *SpyQueue) Close() error

func (*SpyQueue) Current added in v1.4.4

func (spy *SpyQueue) Current() ([]byte, error)

func (*SpyQueue) DiskUsage added in v1.4.4

func (spy *SpyQueue) DiskUsage() int64

func (*SpyQueue) Open added in v1.4.4

func (spy *SpyQueue) Open() error

func (*SpyQueue) PurgeOlderThan added in v1.4.4

func (spy *SpyQueue) PurgeOlderThan(_ time.Time) error

func (*SpyQueue) SetMaxSegmentSize added in v1.4.4

func (spy *SpyQueue) SetMaxSegmentSize(size int64) error

type SpyStorage

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

func NewSpyStorage

func NewSpyStorage(querier storage.Querier) *SpyStorage

func (*SpyStorage) Appender

func (s *SpyStorage) Appender(ctx context.Context) storage.Appender

func (*SpyStorage) ChunkQuerier added in v1.6.0

func (s *SpyStorage) ChunkQuerier(ctx context.Context, mint, maxt int64) (storage.ChunkQuerier, error)

func (*SpyStorage) Close

func (s *SpyStorage) Close() error

func (*SpyStorage) Querier

func (s *SpyStorage) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error)

func (*SpyStorage) StartTime

func (s *SpyStorage) StartTime() (int64, error)

type SpyTCPClient

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

func NewSpyTCPClient

func NewSpyTCPClient() *SpyTCPClient

func (*SpyTCPClient) GetPoints

func (s *SpyTCPClient) GetPoints() []*rpc.Point

func (*SpyTCPClient) SetErr

func (s *SpyTCPClient) SetErr(err error)

func (*SpyTCPClient) Write

func (s *SpyTCPClient) Write(data []byte) (int, error)

type SpyTCPListener

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

func NewSpyTCPListener

func NewSpyTCPListener(tlsConfig *tls.Config) *SpyTCPListener

func (*SpyTCPListener) Address

func (s *SpyTCPListener) Address() string

func (*SpyTCPListener) GetPoints

func (s *SpyTCPListener) GetPoints() []*rpc.Point

func (*SpyTCPListener) Resume

func (s *SpyTCPListener) Resume() error

func (*SpyTCPListener) Start

func (s *SpyTCPListener) Start() error

func (*SpyTCPListener) Stop

func (s *SpyTCPListener) Stop()

type SpyUAA

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

TODO rename file

func NewSpyUAA

func NewSpyUAA(tlsConfig *tls.Config) *SpyUAA

func (*SpyUAA) Port added in v1.4.3

func (spy *SpyUAA) Port() string

func (*SpyUAA) Start

func (s *SpyUAA) Start() error

func (*SpyUAA) Stop added in v1.4.3

func (s *SpyUAA) Stop()

func (*SpyUAA) Url

func (s *SpyUAA) Url() string

type TempStorage

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

func NewTempStorage

func NewTempStorage(name string) TempStorage

func (TempStorage) Cleanup

func (s TempStorage) Cleanup()

func (TempStorage) CreateFile added in v1.4.3

func (s TempStorage) CreateFile(name string, content []byte) string

func (TempStorage) Directories added in v1.4.0

func (s TempStorage) Directories() []string

func (TempStorage) Directory added in v1.4.1

func (s TempStorage) Directory(p string) []string

func (TempStorage) FileNames

func (s TempStorage) FileNames() []string

func (TempStorage) Path

func (s TempStorage) Path() string

Jump to

Keyboard shortcuts

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