testverdicts

package
v0.0.0-...-ef3ffce Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package testverdicts handles read and write test verdicts to BigQuery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Changelist

type Changelist struct {
	Host      bigquery.NullString
	Change    bigquery.NullInt64
	Patchset  bigquery.NullInt64
	OwnerKind bigquery.NullString
}

type Client

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

Client provides methods to export test verdicts to BigQuery via the BigQuery Write API.

func NewClient

func NewClient(ctx context.Context, projectID string) (s *Client, reterr error)

NewClient creates a new client for exporting test verdicts via the BigQuery Write API.

func (*Client) Close

func (c *Client) Close() (reterr error)

Close releases resources held by the client.

func (*Client) Insert

func (c *Client) Insert(ctx context.Context, rows []*bqpb.TestVerdictRow) error

Insert inserts the given rows in BigQuery.

type CommitWithVerdicts

type CommitWithVerdicts struct {
	// Source position of this commit.
	Position int64
	// Commit hash of this commit.
	CommitHash string
	// Represent a branch in the source control.
	Ref *Ref
	// Returns at most 20 test verdicts at this commit.
	TestVerdicts []*TestVerdict
}

CommitWithVerdicts represents a commit with test verdicts.

type ExportOptions

type ExportOptions struct {
	Payload     *taskspb.IngestTestVerdicts
	Invocation  *rdbpb.Invocation
	SourcesByID map[string]*pb.Sources
}

ExportOptions captures context which will be exported alongside the test verdicts.

type Exporter

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

Exporter provides methods to stream test verdicts into BigQuery.

func NewExporter

func NewExporter(client InsertClient) *Exporter

NewExporter instantiates a new Exporter. The given client is used to insert rows into BigQuery.

func (*Exporter) Export

func (e *Exporter) Export(ctx context.Context, testVariants []*rdbpb.TestVariant, opts ExportOptions) error

Export exports the given test verdicts to BigQuery.

type FakeClient

type FakeClient struct {
	// Insertions is the set of test verdicts which were attempted
	// to be exported using the client.
	Insertions []*bqp.TestVerdictRow
}

FakeClient represents a fake implementation of the test verdicts exporter, for testing.

func NewFakeClient

func NewFakeClient() *FakeClient

NewFakeClient initialises a new client for exporting test verdicts.

func (*FakeClient) Insert

func (fc *FakeClient) Insert(ctx context.Context, rows []*bqp.TestVerdictRow) error

Insert inserts the given rows.

type FakeReadClient

type FakeReadClient struct {
	CommitsWithVerdicts        []*CommitWithVerdicts
	SourceVerdictAfterPosition *SourceVerdict
}

FakeReadClient represents a fake implementation of the client to read test verdicts from BigQuery, for testing.

func (*FakeReadClient) ReadTestVerdictAfterPosition

func (f *FakeReadClient) ReadTestVerdictAfterPosition(ctx context.Context, options ReadVerdictAtOrAfterPositionOptions) (*SourceVerdict, error)

ReadTestVerdictAfterPosition reads the source veridct at or after the given source position.

func (*FakeReadClient) ReadTestVerdictsPerSourcePosition

func (f *FakeReadClient) ReadTestVerdictsPerSourcePosition(ctx context.Context, options ReadTestVerdictsPerSourcePositionOptions) ([]*CommitWithVerdicts, error)

ReadTestVerdictsPerSourcePosition reads test verdicts per source position.

type Gitiles

type Gitiles struct {
	Host    bigquery.NullString
	Project bigquery.NullString
	Ref     bigquery.NullString
}

type InsertClient

type InsertClient interface {
	// Insert inserts the given rows into BigQuery.
	Insert(ctx context.Context, rows []*bqpb.TestVerdictRow) error
}

InsertClient defines an interface for inserting rows into BigQuery.

type ReadClient

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

ReadClient represents a client to read test verdicts from BigQuery.

func NewReadClient

func NewReadClient(ctx context.Context, gcpProject string) (*ReadClient, error)

NewReadClient creates a new client for reading test verdicts.

func (*ReadClient) Close

func (c *ReadClient) Close() error

Close releases any resources held by the client.

func (*ReadClient) ReadTestVerdictAfterPosition

func (c *ReadClient) ReadTestVerdictAfterPosition(ctx context.Context, options ReadVerdictAtOrAfterPositionOptions) (*SourceVerdict, error)

ReadTestVerdictAfterPosition returns the first source verdict after the given position on the given branch.

func (*ReadClient) ReadTestVerdictsPerSourcePosition

func (c *ReadClient) ReadTestVerdictsPerSourcePosition(ctx context.Context, options ReadTestVerdictsPerSourcePositionOptions) ([]*CommitWithVerdicts, error)

ReadTestVerdictsPerSourcePosition returns commits with test verdicts in source position ascending order. Only return commits within the last 90 days.

type ReadTestVerdictsPerSourcePositionOptions

type ReadTestVerdictsPerSourcePositionOptions struct {
	Project     string
	TestID      string
	VariantHash string
	RefHash     string
	// Only test verdicts with allowed invocation realms can be returned.
	AllowedRealms []string
	// All returned commits has source position greater than PositionMustGreater.
	PositionMustGreater int64
	// The maximum number of commits to return.
	NumCommits int64
}

type ReadVerdictAtOrAfterPositionOptions

type ReadVerdictAtOrAfterPositionOptions struct {
	// The LUCI Project.
	Project string
	// The test identifier.
	TestID string
	// The variant hash, 16 hex characters.
	VariantHash string
	// The source ref hash, 16 hex characters.
	RefHash string
	// The source position along the ref to search for.
	// The first verdict at or after this position will be returned.
	AtOrAfterPosition int64
	// The start of the partition time range to search, inclusive.
	PartitionTimeStart time.Time
	// The end of the parition time range to search, exclusive.
	PartitionTimeEnd time.Time
	// The LUCI realms we are allowed to access.
	AllowedRealms []string
}

type Ref

type Ref struct {
	Gitiles *Gitiles
}

type SourceVerdict

type SourceVerdict struct {
	// Source position of this commit.
	Position int64
	// Commit hash of this commit.
	CommitHash string
	// The variant, as a JSON blob.
	Variant string
	// The location of the test, if available.
	TestLocation *TestLocation
	// Represent a branch in the source control.
	Ref *Ref
	// A selection of test results at the position.
	// May contain 0 or 1 items.
	Results []TestResult
}

type TestLocation

type TestLocation struct {
	// The repository, e.g. "https://chromium.googlesource.com/chromium/src".
	Repo string
	// The file name in the repository, e.g.
	// "//third_party/blink/web_tests/external/wpt/html/semantics/scripting-1/the-script-element/json-module-assertions/load-error-events.html".
	FileName string
}

type TestResult

type TestResult struct {
	ParentInvocationID string
	ResultID           string
	Expected           bool
	// One of the analysispb.TestResultStatus values.
	Status               string
	PrimaryFailureReason bigquery.NullString
}

type TestVerdict

type TestVerdict struct {
	TestID                string
	VariantHash           string
	RefHash               string
	InvocationID          string
	Status                string
	PartitionTime         time.Time
	PassedAvgDurationUsec bigquery.NullFloat64
	Changelists           []*Changelist
	// Whether the caller has access to this test verdict.
	HasAccess bool
}

Jump to

Keyboard shortcuts

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