summary

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package summary provides types and utility methods for the end-of-test summary.

Index

Constants

View Source
const (
	ModeCompact  = Mode(iota) // Compact mode that only displays the total results.
	ModeFull                  // Extended mode that displays total and partial results.
	ModeLegacy                // Deprecated. Legacy mode, used for backwards compatibility.
	ModeDisabled              // Disabled, formerly known as --no-summary.
)

Possible values for SummaryMode.

Variables

View Source
var ErrInvalidSummaryMode = errors.New("invalid summary mode")

ErrInvalidSummaryMode indicates the serialized summary mode is invalid.

Functions

func ToMachineReadable

func ToMachineReadable(s *Summary, meta Meta) (machinereadable.Summary, error)

ToMachineReadable takes a Summary and Meta and builds a machine-readable summary machinereadable.Summary from them.

Types

type Check

type Check struct {
	Name   string `js:"name"`
	Passes int64  `js:"passes"`
	Fails  int64  `js:"fails"`
}

Check holds the information to be rendered in the summary for a single check.

type Checks

type Checks struct {
	Metrics       ChecksMetrics
	OrderedChecks []*Check
}

Checks holds the checks to be rendered in the summary.

func NewChecks

func NewChecks() *Checks

NewChecks instantiates an empty set of Checks.

type ChecksMetrics

type ChecksMetrics struct {
	Total   Metric `js:"checks_total"`
	Success Metric `js:"checks_succeeded"`
	Fail    Metric `js:"checks_failed"`
}

ChecksMetrics is the subset of checks-specific metrics.

type Group

type Group struct {
	Checks      *Checks // Not always present, thus we use a pointer.
	Metrics     Metrics
	Groups      map[string]Group
	GroupsOrder []string // Groups names with the order to be displayed in the summary. Typically same as in code.
}

Group is a group of metrics and subgroups (recursive) that will be rendered in the summary.

func NewGroup

func NewGroup() Group

NewGroup instantiates an empty Group.

type Meta

type Meta struct {
	Script  string
	IsCloud bool
}

Meta holds some metadata associated with the Summary but isn't strictly part of it, like the script.

type Metric

type Metric struct {
	MetricInfo
	Values map[string]float64
}

Metric holds all the information needed to display a metric in the summary, including its definition and its values.

func NewMetricFrom

func NewMetricFrom(info MetricInfo, values map[string]float64) Metric

NewMetricFrom instantiates a new Metric for a given metrics.Sink and the metric's info.

type MetricInfo

type MetricInfo struct {
	Name     string
	Type     string
	Contains string
}

MetricInfo holds the definition of a metric that will be rendered in the summary, including the name of the metric, its type (Counter, Trend, etc.) and what contains (data amounts, times, etc.).

type MetricThresholds

type MetricThresholds struct {
	Metric     Metric      `js:"metric"`
	Thresholds []Threshold `js:"thresholds"`
}

MetricThresholds is the collection of Threshold that belongs to the same metric.

type Metrics

type Metrics struct {
	// HTTP contains summary data specific to HTTP metrics and is used
	// to produce the summary HTTP subsection's content.
	HTTP map[string]Metric
	// Execution contains summary data specific to Execution metrics and is used
	// to produce the summary Execution subsection's content.
	Execution map[string]Metric
	// Network contains summary data specific to Network metrics and is used
	// to produce the summary Network subsection's content.
	Network map[string]Metric

	Browser map[string]Metric

	WebVitals map[string]Metric

	Grpc map[string]Metric

	WebSocket map[string]Metric `js:"websocket"`

	// Custom contains user-defined metric results as well as extensions metrics
	Custom map[string]Metric
}

Metrics is a collection of Metric grouped by section (http, network, etc).

func NewMetrics

func NewMetrics() Metrics

NewMetrics instantiates an empty collection of Metrics.

type Mode

type Mode int

A Mode specifies the mode of the Summary, which defines how the end-of-test summary will be rendered. TODO(@joanlopez): remove ModeLegacy by k6 v2.0, once we completely drop the support for --summary-mode=legacy.

func ValidateMode

func ValidateMode(val string) (m Mode, err error)

ValidateMode checks if the provided val is a valid Mode.

func (Mode) MarshalJSON

func (m Mode) MarshalJSON() ([]byte, error)

MarshalJSON serializes a Mode as a human-readable string.

func (Mode) MarshalText

func (m Mode) MarshalText() ([]byte, error)

MarshalText serializes a Mode as a human-readable string.

func (Mode) String

func (m Mode) String() string

String returns a human-readable string representation of a Mode.

func (*Mode) UnmarshalText

func (m *Mode) UnmarshalText(data []byte) error

UnmarshalText deserializes a Mode from a string representation.

type Summary

type Summary struct {
	Thresholds `js:"thresholds"`
	Group      `js:"root_group"`
	Scenarios  map[string]Group

	TestRunDuration           time.Duration
	NoColor                   bool // TODO: drop this when noColor is part of the (runtime) options
	EnableColors              bool
	NewMachineReadableSummary bool
}

Summary is the data structure that holds all the summary data (thresholds, metrics, checks, etc) as well as some other information, like certain rendering options.

func New

func New() *Summary

New instantiates a new empty Summary.

type Threshold

type Threshold struct {
	Source string `js:"source"`
	Ok     bool   `js:"ok"`
}

Threshold holds the information of a threshold to be rendered in the summary.

type Thresholds

type Thresholds map[string]MetricThresholds

Thresholds is a collection of MetricThresholds that will be rendered in the summary.

func NewThresholds

func NewThresholds() Thresholds

NewThresholds instantiates an empty collection of Thresholds.

Directories

Path Synopsis
cog

Jump to

Keyboard shortcuts

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