yaml

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

README

Declarative YAML tests

See OpenTelemetry Acceptance Tests (OATs) for more information.

Documentation

Index

Constants

View Source
const DefaultTestCaseInterval = 100 * time.Millisecond

Variables

View Source
var VerboseLogging bool

Functions

func AssertLoki

func AssertLoki(r *runner, l ExpectedLogs)

func AssertLokiResponse added in v0.1.0

func AssertLokiResponse(b []byte, l ExpectedLogs, r *runner)

func AssertProm

func AssertProm(r *runner, promQL string, value string)

func AssertTempo

func AssertTempo(r *runner, t ExpectedTraces)

func AssumeNoYamlTest

func AssumeNoYamlTest(t *testing.T)

func GetFreePorts

func GetFreePorts(count int) ([]int, error)

func RunTestCase

func RunTestCase(c *TestCase)

func TestCaseBasePath added in v0.1.0

func TestCaseBasePath() string

Types

type CustomCheck added in v0.1.0

type CustomCheck struct {
	Script string `yaml:"script"`
}

type DashboardAssert

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

func NewDashboardAssert

func NewDashboardAssert(d ExpectedDashboard) *DashboardAssert

func (*DashboardAssert) AssertDashboard

func (a *DashboardAssert) AssertDashboard(r *runner, panelIndex int)

type DockerCompose

type DockerCompose struct {
	Generator   string   `yaml:"generator"` // deprecated: only used by beyla
	Files       []string `yaml:"files"`
	Environment []string `yaml:"env"`
}

type Expected

type Expected struct {
	Logs         []ExpectedLogs      `yaml:"logs"`
	Traces       []ExpectedTraces    `yaml:"traces"`
	Metrics      []ExpectedMetrics   `yaml:"metrics"`
	Dashboards   []ExpectedDashboard `yaml:"dashboards"`
	CustomChecks []CustomCheck       `yaml:"custom-checks"`
}

type ExpectedDashboard

type ExpectedDashboard struct {
	Path   string                   `yaml:"path"`
	Panels []ExpectedDashboardPanel `yaml:"panels"`
}

type ExpectedDashboardPanel

type ExpectedDashboardPanel struct {
	Title string `yaml:"title"`
	Value string `yaml:"value"`
}

type ExpectedLogs

type ExpectedLogs struct {
	LogQL             string            `yaml:"logql"`
	Equals            string            `yaml:"equals"`
	Contains          []string          `yaml:"contains"`
	Regexp            string            `yaml:"regexp"`
	Attributes        map[string]string `yaml:"attributes"`
	AttributeRegexp   map[string]string `yaml:"attribute-regexp"`
	NoExtraAttributes bool              `yaml:"no-extra-attributes"`
}

type ExpectedMetrics

type ExpectedMetrics struct {
	PromQL string `yaml:"promql"`
	Value  string `yaml:"value"`
}

type ExpectedSpan

type ExpectedSpan struct {
	Name       string            `yaml:"name"`
	Attributes map[string]string `yaml:"attributes"`
	AllowDups  bool              `yaml:"allow-duplicates"`
}

type ExpectedTraces

type ExpectedTraces struct {
	TraceQL string         `yaml:"traceql"`
	Spans   []ExpectedSpan `yaml:"spans"`
}

type Input

type Input struct {
	Path   string `yaml:"path"`
	Status string `yaml:"status"`
}

type PortAllocator

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

func NewPortAllocator

func NewPortAllocator(needed int) *PortAllocator

func (*PortAllocator) Allocate

func (p *PortAllocator) Allocate() int

func (*PortAllocator) AllocatePorts

func (p *PortAllocator) AllocatePorts() *PortConfig

type PortConfig

type PortConfig struct {
	ApplicationPort    int
	GrafanaHTTPPort    int
	PrometheusHTTPPort int
	LokiHTTPPort       int
	TempoHTTPPort      int
}

type QueryLogger

type QueryLogger struct {
	Verbose bool

	Logger io.WriteCloser
	// contains filtered or unexported fields
}

func NewQueryLogger

func NewQueryLogger(endpoint observability.Endpoint, logger io.WriteCloser) QueryLogger

func (*QueryLogger) LogQueryResult

func (q *QueryLogger) LogQueryResult(format string, a ...any)

type QueryResponse added in v0.1.0

type QueryResponse struct {
	Status string `json:"status"`
	Data   struct {
		Result []struct {
			Stream map[string]string `json:"stream"`
			Values [][]string        `json:"values"`
		} `json:"result"`
	} `json:"data"`
}

type TestCase

type TestCase struct {
	Name       string
	Dir        string
	OutputDir  string
	Definition TestCaseDefinition
	PortConfig *PortConfig
	Dashboard  *TestDashboard
	Timeout    time.Duration
}

func ReadTestCases

func ReadTestCases() ([]*TestCase, string)

func (*TestCase) CreateDockerComposeFile

func (c *TestCase) CreateDockerComposeFile() string

type TestCaseDefinition

type TestCaseDefinition struct {
	Include       []string               `yaml:"include"`
	DockerCompose *DockerCompose         `yaml:"docker-compose"`
	Kubernetes    *kubernetes.Kubernetes `yaml:"kubernetes"`
	Input         []Input                `yaml:"input"`
	Interval      time.Duration          `yaml:"interval"`
	Expected      Expected               `yaml:"expected"`
}

func (*TestCaseDefinition) Merge

func (d *TestCaseDefinition) Merge(other TestCaseDefinition)

type TestDashboard

type TestDashboard struct {
	Path    string
	Content lint.Dashboard
}

Jump to

Keyboard shortcuts

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