comparer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparer

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

A Comparer allows comparing query results for test cases between a reference API and a test API.

func New

func New(refAPI, testAPI PromAPI, queryTweaks []*config.QueryTweak) *Comparer

New returns a new Comparer.

func (*Comparer) Compare

func (c *Comparer) Compare(tc *TestCase) (*Result, error)

Compare runs a test case query against the reference API and the test API and compares the results.

type PromAPI

type PromAPI interface {
	// Query performs a query for the given time.
	Query(ctx context.Context, query string, ts time.Time, opts ...v1.Option) (model.Value, v1.Warnings, error)
	// QueryRange performs a query for the given range.
	QueryRange(ctx context.Context, query string, r v1.Range, opts ...v1.Option) (model.Value, v1.Warnings, error)
}

PromAPI allows running instant and range queries against a Prometheus-compatible API.

type Result

type Result struct {
	TestCase          *TestCase `json:"testCase"`
	Diff              string    `json:"diff,omitempty"`
	UnexpectedFailure string    `json:"unexpectedFailure,omitempty"`
	UnexpectedSuccess bool      `json:"unexpectedSuccess"`
	Unsupported       bool      `json:"unsupported,omitempty"`
}

Result tracks a single test case's query comparison result.

func (*Result) Success

func (r *Result) Success() bool

Success returns true if the comparison result was successful.

type TestCase

type TestCase struct {
	Query          string        `json:"query"`
	SkipComparison bool          `json:"skipComparison"`
	ShouldFail     bool          `json:"shouldFail"`
	Start          time.Time     `json:"start"`
	End            time.Time     `json:"end"`
	Resolution     time.Duration `json:"resolution"`
}

TestCase represents a fully expanded query to be tested.

Jump to

Keyboard shortcuts

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