comparer

package
v0.0.0-...-12cbdf9 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: 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) (model.Value, v1.Warnings, error)
	// QueryRange performs a query for the given range.
	QueryRange(ctx context.Context, query string, r v1.Range) (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"`
	UnexpectedFailure string    `json:"unexpectedFailure"`
	UnexpectedSuccess bool      `json:"unexpectedSuccess"`
	Unsupported       bool      `json:"unsupported"`
}

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