databuilder

package
v0.0.0-...-ace5988 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package databuilder provides a tool for generating test data in a way that is easy for a human to update and understand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangelistBuilder

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

func (*ChangelistBuilder) AddPatchset

func (b *ChangelistBuilder) AddPatchset(psID, gitHash string, order int) *PatchsetBuilder

AddPatchset returns a builder for data associated with the given patchset.

func (*ChangelistBuilder) AddTriageEvent

func (b *ChangelistBuilder) AddTriageEvent(user, triageTime string) *ExpectationsBuilder

AddTriageEvent returns a builder for a series of triage events on the current CL. These events will be attributed to the given user and timestamp.

type CommitBuilder

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

CommitBuilder has methods for easily building commit history. All methods are chainable.

func (*CommitBuilder) Insert

func (b *CommitBuilder) Insert(commitID schema.CommitID, author, subject, commitTime string) *CommitBuilder

Insert adds a commit with the given data. It panics if the commitTime is not formatted to RFC3339.

type ExpectationsBuilder

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

func (*ExpectationsBuilder) ExpectationsForGrouping

func (b *ExpectationsBuilder) ExpectationsForGrouping(keys paramtools.Params) *ExpectationsBuilder

func (*ExpectationsBuilder) Negative

Negative marks the given digest as negative for the current grouping. It assumes that the previous triage state was untriaged (as this is quite common for test data).

func (*ExpectationsBuilder) Positive

Positive marks the given digest as positive for the current grouping. It assumes that the previous triage state was untriaged (as this is quite common for test data).

func (*ExpectationsBuilder) Triage

Triage allows an event to be added that has some custom setup. E.g. changing a postively triaged digest to be negatively triaged.

type GitCommitBuilder

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

GitCommitBuilder has methods for building rows in the GitCommits table.

func (*GitCommitBuilder) Insert

func (b *GitCommitBuilder) Insert(commitID, gitHash, author, subject, commitTime string) *GitCommitBuilder

Insert adds a commit with the given data. It panics if the commitTime is not formatted to RFC3339 or if the gitHash is invalid.

type PatchsetBuilder

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

func (*PatchsetBuilder) DataWithCommonKeys

func (b *PatchsetBuilder) DataWithCommonKeys(keys paramtools.Params) *PatchsetBuilder

DataWithCommonKeys sets it so the next calls to Digests will use these trace keys.

func (*PatchsetBuilder) Digests

func (b *PatchsetBuilder) Digests(digests ...types.Digest) *PatchsetBuilder

Digests adds some data to this patchset. Each digest represents a single data point on a single trace.

func (*PatchsetBuilder) FromTryjob

func (b *PatchsetBuilder) FromTryjob(id, cis, name, file, ingestedTS string) *PatchsetBuilder

FromTryjob assigns all data previously added with Digests() to be from the given tryjob.

func (*PatchsetBuilder) Keys

Keys applies the given keys to the previous set of data added with Digests(), including a previously set common keys. The length of keys should match the earlier call to Digests().

func (*PatchsetBuilder) OptionsAll

func (b *PatchsetBuilder) OptionsAll(opts paramtools.Params) *PatchsetBuilder

OptionsAll applies the given options to the entire previous set of data added with Digests().

func (*PatchsetBuilder) OptionsPerPoint

func (b *PatchsetBuilder) OptionsPerPoint(xopts []paramtools.Params) *PatchsetBuilder

OptionsPerPoint applies the given options to the previous set of data added with Digests(). The length of keys should match the earlier call to Digests().

type TablesBuilder

type TablesBuilder struct {
	// TileWidth is the number of commits with data that should be grouped together in a tile.
	// In production, tiles will default to 100 dense commits wide.
	TileWidth int
	// contains filtered or unexported fields
}

TablesBuilder has methods on it for generating trace data and other related data in a way that can be easily turned into SQL table rows.

func (*TablesBuilder) AddChangelist

func (b *TablesBuilder) AddChangelist(id, crs, owner, subject string, status schema.ChangelistStatus) *ChangelistBuilder

AddChangelist returns a builder for data belonging to a changelist.

func (*TablesBuilder) AddIgnoreRule

func (b *TablesBuilder) AddIgnoreRule(created, updated, updateTS, note string, query paramtools.ParamSet) uuid.UUID

AddIgnoreRule adds an ignore rule with the given information. It will be applied to traces during the generation of structs.

func (*TablesBuilder) AddTracesWithCommonKeys

func (b *TablesBuilder) AddTracesWithCommonKeys(params paramtools.Params) *TraceBuilder

AddTracesWithCommonKeys returns a new TraceBuilder for building a set of related traces. This can be called more than once - all data will be combined at the end. It panics if any of its prerequisites have not been called.

func (*TablesBuilder) AddTriageEvent

func (b *TablesBuilder) AddTriageEvent(user, triageTime string) *ExpectationsBuilder

AddTriageEvent returns a builder for a series of triage events on the primary branch. These events will be attributed to the given user and timestamp.

func (*TablesBuilder) Build

func (b *TablesBuilder) Build() schema.Tables

Build should be called when all the data has been loaded in for a given setup. It will generate the SQL rows as represented in a schema.Tables. If any validation steps fail, it will panic.

func (*TablesBuilder) CommitsWithData

func (b *TablesBuilder) CommitsWithData() *CommitBuilder

CommitsWithData returns a new CommitBuilder to which the trace data will be connected. It panics if called more than once.

func (*TablesBuilder) CommitsWithNoData

func (b *TablesBuilder) CommitsWithNoData() *GitCommitBuilder

CommitsWithNoData returns a new CommitBuilder that will fill in the GitCommits table.

func (*TablesBuilder) ComputeDiffMetricsFromImages

func (b *TablesBuilder) ComputeDiffMetricsFromImages(imgDir string, nowStr string)

ComputeDiffMetricsFromImages generates all the diff metrics from the observed images/digests and from the trace history. It reads the images from disk to use in order to compute the diffs. It is expected that the images are in the provided directory named [digest].png.

func (*TablesBuilder) NoIgnoredTraces

func (b *TablesBuilder) NoIgnoredTraces()

NoIgnoredTraces marks all traces as not ignored.

func (*TablesBuilder) SetDigests

func (b *TablesBuilder) SetDigests(runeToDigest map[rune]types.Digest)

SetDigests loads a mapping of runes to the digest that they represent. This allows specifying the trace history be done with a string of characters. If a rune is invalid or the digests are invalid, this will panic. It panics if called more than once.

func (*TablesBuilder) SetGroupingKeys

func (b *TablesBuilder) SetGroupingKeys(fields ...string)

SetGroupingKeys specifies which keys from a Trace's params will be used to define the grouping. It panics if called more than once.

type TraceBuilder

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

TraceBuilder has methods for easily building trace data. All methods are chainable.

func (*TraceBuilder) History

func (b *TraceBuilder) History(traceHistories ...string) *TraceBuilder

History takes in a slice of strings, with each string representing the history of a trace. Each string must have a number of symbols equal to the length of the number of commits. A dash '-' means no data at that commit; any other symbol must match the previous call to SetDigests(). If any data is invalid or missing, this method panics.

func (*TraceBuilder) IngestedFrom

func (b *TraceBuilder) IngestedFrom(filenames, ingestedDates []string) *TraceBuilder

IngestedFrom applies the given list of files and ingested times to the provided data. The number of filenames and ingestedDates is expected to match the number of commits; if no data is at that commit, it is ok to have both entries be empty string. It panics if any inputs are invalid.

func (*TraceBuilder) Keys

func (b *TraceBuilder) Keys(keys []paramtools.Params) *TraceBuilder

Keys specifies the params for each trace. It must be called after History() and the keys param must have the same number of elements that the call to History() had. The nth element here represents the nth trace history. This method panics if any trace would end up being identical or lacks the grouping data. This method panics if called with incorrect parameters or at the wrong time in building chain.

func (*TraceBuilder) OptionsAll

func (b *TraceBuilder) OptionsAll(opts paramtools.Params) *TraceBuilder

OptionsAll applies the given options for all data points provided in history.

func (*TraceBuilder) OptionsPerPoint

func (b *TraceBuilder) OptionsPerPoint(optsByTrace [][]paramtools.Params) *TraceBuilder

OptionsPerPoint applies the given optional params to the each data point in the provided traces. The number of rows should equal the number of traces and the number of cols should equal the number of commits.

func (*TraceBuilder) OptionsPerTrace

func (b *TraceBuilder) OptionsPerTrace(xopts []paramtools.Params) *TraceBuilder

OptionsPerTrace applies the given optional params to the traces created in History. The number of options is expected to match the number of traces. It panics if called more than once or at the wrong time.

Jump to

Keyboard shortcuts

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