analyzer

package
v0.0.0-...-b0621e5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package analyzer defines and runs the steps to check builder groups, builders, test results and so on, in order to produce alerts.

Index

Constants

View Source
const (
	// StepCompletedRun is a synthetic step name used to indicate the build run is complete.
	StepCompletedRun = "completed run"
)

Variables

This section is empty.

Functions

func GetBigQueryAlerts

func GetBigQueryAlerts(ctx context.Context, tree string) ([]*messages.BuildFailure, error)

GetBigQueryAlerts generates alerts for currently failing build steps, using BigQuery to do most of the heavy lifting. Note that this returns alerts for all failing steps, so filtering should be applied on the return value. TODO: Some post-bq result merging with heuristics:

  • Merge alerts for sets of multiple failing steps. Currently will return one alert for each failing step on a builder. If step_a and step_b are failing on the same builder or set of builders, they should be merged into a single alert.

func QueryBQForProject

func QueryBQForProject(ctx context.Context, project string) error

QueryBQForProject queries the sheriffable_failures for a project and stores the result in memcache.

Types

type Analyzer

type Analyzer struct {
	// MaxRecentBuilds is the maximum number of recent builds to check, per builder.
	MaxRecentBuilds int

	// MinRecentBuilds is the minimum number of recent builds to check, per builder.
	MinRecentBuilds int

	// HungBuilerThresh is the maxumum length of time a builder may be in state "building"
	// before triggering a "hung builder" alert.
	HungBuilderThresh time.Duration

	// OfflineBuilderThresh is the maximum length of time a builder may be in state "offline"
	//  before triggering an "offline builder" alert.
	OfflineBuilderThresh time.Duration

	// IdleBuilderCountThresh is the maximum number of builds a builder may have in queue
	// while in the "idle" state before triggering an "idle builder" alert.
	IdleBuilderCountThresh int64

	// Now is useful for mocking the system clock in testing and simulating time
	// during replay.
	Now func() time.Time

	// Mock these out in tests.
	CrBug     client.CrBug
	Bisection client.Bisection
	// contains filtered or unexported fields
}

Analyzer runs the process of checking builder groups, builders, test results and so on, in order to produce alerts.

func CreateAnalyzer

func CreateAnalyzer(c context.Context) *Analyzer

CreateAnalyzer creates a new analyzer and set its service clients.

func New

func New(minBuilds, maxBuilds int) *Analyzer

New returns a new Analyzer. If client is nil, it assigns a default implementation. maxBuilds is the maximum number of builds to check, per builder.

func (*Analyzer) GetRevisionSummaries

func (a *Analyzer) GetRevisionSummaries(hashes []string) ([]*messages.RevisionSummary, error)

GetRevisionSummaries returns a slice of RevisionSummaries for the list of hashes.

type BqFailure

type BqFailure struct {
	Name string `json:"step"`

	Tests           []step.TestWithResult `json:"tests"`
	NumFailingTests int64                 `json:"num_failing_tests"`
	// contains filtered or unexported fields
}

This type is a catch-all for every kind of failure. In a better, simpler design we wouldn't have to use this but it's here to make the transition from previous analyzer logic easier.

func (*BqFailure) Kind

func (b *BqFailure) Kind() string

func (*BqFailure) Severity

func (b *BqFailure) Severity() messages.Severity

func (*BqFailure) Signature

func (b *BqFailure) Signature() string

func (*BqFailure) Title

func (b *BqFailure) Title(bses []*messages.BuildStep) string

func (*BqFailure) WithKind

func (b *BqFailure) WithKind(kind string) *BqFailure

type ConfigRules

type ConfigRules struct {
	IgnoredSteps []string `json:"ignored_steps"`
}

ConfigRules is a parsed representation of the config.json file, which specifies builders and steps to exclude.

func GetConfigRules

func GetConfigRules(c context.Context) (*ConfigRules, error)

GetConfigRules fetches the latest version of the config from Gitiles.

func ParseConfigRules

func ParseConfigRules(cfgJSON []byte) (*ConfigRules, error)

ParseConfigRules parses the given byte array into a ConfigRules object. Public so that parse_config_test can use it.

func (*ConfigRules) ExcludeFailure

func (r *ConfigRules) ExcludeFailure(ctx context.Context, builderGroup, builder, step string) bool

ExcludeFailure determines whether a particular failure should be ignored, according to the rules in the config.

type GitCommit

type GitCommit struct {
	Project  bigquery.NullString
	Ref      bigquery.NullString
	Host     bigquery.NullString
	ID       bigquery.NullString
	Position bigquery.NullInt64
}

GitCommit represents a struct column for BQ query results.

type TestFailure

type TestFailure struct {
	TestName    bigquery.NullString
	TestID      bigquery.NullString
	Realm       bigquery.NullString
	VariantHash bigquery.NullString
	ClusterName bigquery.NullString
	RefHash     bigquery.NullString
	Segments    []*segment
}

TestFailure represents a struct column for a test failure in BQ results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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