Documentation ¶
Overview ¶
Package model provides types that represent Chromium test result files such as "results.json", "full_results.json", etc.
Index ¶
- Constants
- Variables
- func CleanJSON(r io.Reader) (io.Reader, error)
- func IsAggregateTestFile(filename string) bool
- type AggregateResult
- type AggregateTest
- func (at *AggregateTest) MarshalJSON() ([]byte, error)
- func (at *AggregateTest) Merge(other AggregateTest) error
- func (at *AggregateTest) UnmarshalJSON(data []byte) error
- func (at AggregateTest) Walk(fn func(key string, node Node))
- func (at AggregateTest) WalkLeaves(fn func(key string, leaf *AggregateTestLeaf))
- type AggregateTestLeaf
- type BuildNum
- type BuilderData
- type BuilderInfo
- type DataEntry
- type FlatTest
- type FullResult
- type FullTest
- type FullTestLeaf
- type Master
- type Node
- type Number
- type ResultSummary
- type RuntimeSummary
- type Test
- type TestFile
- type TestFileParams
- type TestList
- type TestLocation
- type Times
Constants ¶
const ( // ResultsSize is the size that "results.json" should be trimmed to. ResultsSize = 500 // ResultsSmallSize is the size that "results_small.json" should // be trimmed to. ResultsSmallSize = 100 )
const ResultsVersion = 4
ResultsVersion is the latest version of the JSON format that "results.json" and "results-small.json" files are using.
Variables ¶
var ( // CleanPrefix is the prefix that CleanJSON removes. CleanPrefix = []byte("ADD_RESULTS(") // CleanSuffix is the suffix that CleanJSON removes. CleanSuffix = []byte(");") )
var ( // ErrBuildNumberConflict is returned when the build numbers // are the same when merging. ErrBuildNumberConflict = errors.New("build number conflict") // ErrBuilderNameConflict is returned when the builder names // do not match when merging. ErrBuilderNameConflict = errors.New("builder name conflict") )
var ( // FailureLongNames is a map from short failure name to long failure // name. FailureLongNames = map[string]string{ "A": "AUDIO", "C": "CRASH", "Q": "FAIL", "L": "FLAKY", "I": "IMAGE", "Z": "IMAGE+TEXT", "K": "LEAK", "O": "MISSING", "N": "NO DATA", "Y": "NOTRUN", "P": "PASS", "X": "SKIP", "S": "SLOW", "F": "TEXT", "T": "TIMEOUT", "U": "UNKNOWN", "V": "VERYFLAKY", } // FailureShortNames is a map from long failure name to short // failure name. FailureShortNames map[string]string )
Functions ¶
func CleanJSON ¶
CleanJSON returns the result of removing CleanPrefix and CleanSuffix from the contents in r. If either CleanPrefix or CleanSuffix does not exist, the returned io.Reader has the same contents as r.
func IsAggregateTestFile ¶
IsAggregateTestFile returns whether filename is that of an aggregate test file.
Types ¶
type AggregateResult ¶
type AggregateResult struct { Version int Builder string *BuilderInfo }
AggregateResult represents "results.json" and "results-small.json" files.
func (*AggregateResult) MarshalJSON ¶
func (ag *AggregateResult) MarshalJSON() ([]byte, error)
MarshalJSON marshal ag into JSON.
func (*AggregateResult) Merge ¶
func (ag *AggregateResult) Merge(other *AggregateResult) error
Merge merges other into ag.
func (*AggregateResult) ToTestList ¶
func (ag *AggregateResult) ToTestList() TestList
ToTestList returns a TestList representation of ag. The receiver's Tests field will be modified in the process.
func (*AggregateResult) Trim ¶
func (ag *AggregateResult) Trim(size int) error
Trim trims ag's fields to the specified size.
func (*AggregateResult) UnmarshalJSON ¶
func (ag *AggregateResult) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes JSON data into t.
The expected format is a modified version of the format described in the URL below. The modifications account for the structure of results.json and results_small.json files in the wild.
https://chromium.googlesource.com/chromium/src/+/c7dd0560d9544a15908239bebc177410899851ca/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_package/bot_test_expectations.py#45
type AggregateTest ¶
AggregateTest represents Tests in a AggregateResult.
func (*AggregateTest) MarshalJSON ¶
func (at *AggregateTest) MarshalJSON() ([]byte, error)
MarshalJSON marshals at into JSON.
func (*AggregateTest) Merge ¶
func (at *AggregateTest) Merge(other AggregateTest) error
Merge merges other into at.
func (*AggregateTest) UnmarshalJSON ¶
func (at *AggregateTest) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the supplied data into at.
func (AggregateTest) Walk ¶
func (at AggregateTest) Walk(fn func(key string, node Node))
Walk performs a depth-first traversal of the Nodes reachable from the receiver, calling fn each time. The Node in fn is guaranteed to be either AggregateTest or *AggregateTestLeaf. The traversal order may vary across different runs.
func (AggregateTest) WalkLeaves ¶
func (at AggregateTest) WalkLeaves(fn func(key string, leaf *AggregateTestLeaf))
WalkLeaves is similar to Walk but only calls fn for *AggregateTestLeaf.
type AggregateTestLeaf ¶
type AggregateTestLeaf struct { Results []ResultSummary Runtimes []RuntimeSummary Expected []string Bugs []string }
AggregateTestLeaf is the summary of test results at the l of a tests trie.
func (*AggregateTestLeaf) MarshalJSON ¶
func (leaf *AggregateTestLeaf) MarshalJSON() ([]byte, error)
MarshalJSON marshals leaf into JSON.
func (*AggregateTestLeaf) Merge ¶
func (leaf *AggregateTestLeaf) Merge(other *AggregateTestLeaf) error
Merge merges other into leaf.
func (*AggregateTestLeaf) UnmarshalJSON ¶
func (leaf *AggregateTestLeaf) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the supplied data into leaf.
type BuildNum ¶
type BuildNum int64
BuildNum is int64 that is used to handle TestFile datastore records with null build_number. The value is >= 0 if the datastore value was not null. The value is -1 for null datastore value.
func (*BuildNum) FromProperty ¶
FromProperty is for implementing datastore.PropertyConverter.
type BuilderData ¶
type BuilderData struct { Masters []Master `json:"masters"` NoUploadTestTypes []string `json:"no_upload_test_types"` }
BuilderData is the data returned from the GET "/builders" endpoint.
type BuilderInfo ¶
type BuilderInfo struct { // SecondsEpoch is the start time of tests expressed in seconds from // the Unix epoch. SecondsEpoch []float64 `json:"secondsSinceEpoch"` // BlinkRevs is list of Blink revisions. BlinkRevs []Number `json:"blinkRevision"` // BuildNumbers is list of build numbers. BuildNumbers []Number `json:"buildNumbers"` // ChromeRevs is a list of Chrome/Chromium revisions. // The elements are strings because they can either be revision // numbers or commit hashes. ChromeRevs []string `json:"chromeRevision"` // Tests is the test trie. The leaf nodes will be of type // AggregateTestLeaf. Tests AggregateTest `json:"tests"` // FailureMap is a map from long failure types to short failure // types. Usually, it resembles LongFailureTypes. FailureMap map[string]string `json:"failure_map"` // FailuresByType is a map from long failure type to // number of failures. FailuresByType map[string][]int `json:"num_failures_by_type,omitempty"` // FixableCounts represents test failures in a legacy format, // and is usually nil. // // It is included here because it may be needed to compute // FailuresByType when unmarshaling JSON. FixableCounts []map[string]int `json:"fixableCounts,omitempty"` }
BuilderInfo represents aggregate information for a builder.
func (*BuilderInfo) Merge ¶
func (info *BuilderInfo) Merge(other *BuilderInfo) error
Merge merges other into info.
The returned error is ErrBuildNumberConflict when other.BuildNumbers[0] already has the latest build number. This can happen if a single build re-uses a step name, or the normalized test name derived from the step name is the same as another step in the same build.
type DataEntry ¶
type DataEntry struct { ID int64 `gae:"$id"` Data []byte `gae:"data,noindex"` Created time.Time `gae:"created"` }
DataEntry represents a DataEntry record.
type FlatTest ¶
type FlatTest map[string]*FullTestLeaf
FlatTest is a flattened representation of FullTest.
type FullResult ¶
type FullResult struct { Version int `json:"version"` Builder string `json:"builder_name"` BuildNumber Number `json:"build_number"` BuildID int `json:"build_id"` SecondsEpoch float64 `json:"seconds_since_epoch"` Tests FullTest `json:"tests"` FailuresByType map[string]int `json:"num_failures_by_type"` ChromiumRev *string `json:"chromium_revision,omitempty"` PathDelim *string `json:"path_delimiter,omitempty"` Interrupted *bool `json:"interrupted,omitempty"` BlinkRev *string `json:"blink_revision,omitempty"` TestLocations *map[string]TestLocation `json:"test_locations,omitempty"` PrettyPatch *bool `json:"has_pretty_patch,omitempty"` Wdiff *bool `json:"has_wdiff"` LayoutTestsDir *string `json:"layout_tests_dir,omitempty"` PixelTestsEnabled *bool `json:"pixel_tests_enabled,omitempty"` Fixable *int `json:"fixable,omitempty"` NumFlaky *int `json:"num_flaky,omitempty"` NumPasses *int `json:"num_passes,omitempty"` NumRegressions *int `json:"num_regressions,omitempty"` Skips *int `json:"skips,omitempty"` }
FullResult represents "full_results.json".
func (*FullResult) AggregateResult ¶
func (fr *FullResult) AggregateResult() (AggregateResult, error)
AggregateResult converts fr to an AggregateResult. The returned AggregateResult does not share references to objects referenced by fr.
type FullTest ¶
FullTest represents Tests in a FullResult.
func (FullTest) AggregateTest ¶
func (ft FullTest) AggregateTest() (AggregateTest, error)
AggregateTest converts ft to an AggregateTest. The returned AggregateTest does not share references to objects referenced by ft.
func (FullTest) Flatten ¶
Flatten flattens the test trie ft. delim is the delimiter between test names. Usually it is set to the value of the PathDelim field on the parent FullResult of ft.
func (*FullTest) MarshalJSON ¶
MarshalJSON marshals ft into JSON.
func (*FullTest) UnmarshalJSON ¶
UnmarshalJSON unmarshals the supplied data into ft.
type FullTestLeaf ¶
type FullTestLeaf struct { Actual []string `json:"-"` Expected []string `json:"-"` Runtime *float64 `json:"time,omitempty"` // In seconds. Runtimes []*float64 `json:"times,omitempty"` // In seconds. Bugs []string `json:"bugs"` Unexpected *bool `json:"is_unexpected,omitempty"` RepaintOverlay *bool `json:"has_repaint_overlay,omitempty"` MissingAudio *bool `json:"is_missing_audio,omitempty"` MissingText *bool `json:"is_missing_text,omitempty"` MissingVideo *bool `json:"is_missing_video,omitempty"` UsedTestHarness *bool `json:"is_testharness_test,omitempty"` // ReferenceTestType is documented at the JSON Test Results // Format (https://www.chromium.org/developers/the-json-test-results-format) // as string, but uploaders use []string. ReferenceTestType []string `json:"reftest_type,omitempty"` // Artifacts identify extra files produced by the test. Artifacts map[string][]string `json:"artifacts"` }
FullTestLeaf represents the results for a particular test name.
func (*FullTestLeaf) AggregateTestLeaf ¶
func (l *FullTestLeaf) AggregateTestLeaf() (AggregateTestLeaf, error)
AggregateTestLeaf converts l to AggregateTestLeaf. The returned AggregateTestLeaf does not share references to objects referenced by l.
The returned error is always nil, but callers should check the error anyway because this behavior may change in the future.
func (*FullTestLeaf) MarshalJSON ¶
func (l *FullTestLeaf) MarshalJSON() ([]byte, error)
MarshalJSON marshals l into JSON.
func (*FullTestLeaf) UnmarshalJSON ¶
func (l *FullTestLeaf) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the supplied data into l.
type Master ¶
type Master struct { Name string `json:"name"` Identifier string `json:"url_name"` Groups []string `json:"groups"` Tests map[string]*Test `json:"tests"` }
Master represents information about a build master.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is a node in a Tests tree.
In reality, it as almost as weak as empty interface, but the unexported method allow the package to achieve type safety internally.
type Number ¶
type Number int
Number is an integer that supports JSON unmarshaling from a string and marshaling back to a string.
func (*Number) MarshalJSON ¶
MarshalJSON marshals n into JSON string.
func (*Number) UnmarshalJSON ¶
UnmarshalJSON unmarshals data into n. data is expected to be a JSON string. If the string fails to parse to an integer, UnmarshalJSON returns an error.
type ResultSummary ¶
ResultSummary is the type of test failure and count of how many times the running time occurred.
func (*ResultSummary) MarshalJSON ¶
func (rs *ResultSummary) MarshalJSON() ([]byte, error)
MarshalJSON marshals rs into JSON.
func (*ResultSummary) UnmarshalJSON ¶
func (rs *ResultSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the provided data into rs.
type RuntimeSummary ¶
RuntimeSummary is the running time of a test and count of how many times the running time occurred.
func (*RuntimeSummary) MarshalJSON ¶
func (rs *RuntimeSummary) MarshalJSON() ([]byte, error)
MarshalJSON marshals rs into JSON.
func (*RuntimeSummary) UnmarshalJSON ¶
func (rs *RuntimeSummary) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the provided data into rs.
type Test ¶
type Test struct {
Builders []string `json:"builders"`
}
Test represents information about Tests in a master.
type TestFile ¶
type TestFile struct { ID int64 `gae:"$id"` BuildNumber BuildNum `gae:"build_number"` Builder string `gae:"builder"` Master string `gae:"master"` Name string `gae:"name"` TestType string `gae:"test_type"` // DataKeys is the keys to the DataEntry(s) that contain // the data for this TestFile. DataKeys []*datastore.Key `gae:"data_keys,noindex"` // LastMod is the last modified time. LastMod time.Time `gae:"date"` // OldDataKeys is the keys of the old DataEntry(s) used // before putting the new data. This field is set after a // successful call to PutData. // // Users are responsible for deleting the DataEntry(s) // pointed to by these keys if they are no longer needed. OldDataKeys []*datastore.Key `gae:"-,noindex"` // NewDataKeys is UNUSED in this implementation. It is // a remnant of the old Python implementation. NewDataKeys []*datastore.Key `gae:"new_data_keys,noindex"` }
TestFile represents a TestFile record.
func (*TestFile) DataReader ¶
DataReader fetches data from the DataEntry(s) pointed to by tf.DataKeys and sets tf.Data to the fetched data.
func (*TestFile) PutData ¶
PutData puts the contents of tf.Data to DataEntry(s) in the datastore and updates tf.LastMod and tf.DataKeys locally.
datastore.Put(tf) should be called after PutData to put the the updated tf.LastMod and tf.DataKeys fields to the datastore. PutData does has no effect on the old DataEntry(s). tf.OldDataKeys will be modified only if PutData returns a non-nil error.
It is safe to call PutData within a transaction: tf.DataKeys will point to the DataEntry(s) created in the successful attempt, and tf.LastMod will equal the time of the successful attempt.
type TestFileParams ¶
type TestFileParams struct { Master string Builder string Name string TestType string BuildNumber *int OrderBuildNumbers bool // Whether to order build numbers by latest. Before time.Time // Limit is the limit on the query. If the value is negative or greater // than the default limit, the default limit will be used instead. Limit int32 }
TestFileParams represents the parameters in a TestFile query.
func (*TestFileParams) Query ¶
func (p *TestFileParams) Query() *datastore.Query
Query generates a datastore query for the parameters. If a field in p is the zero value, a default value is used in the query or the constraint is omitted from the query.
type TestList ¶
type TestList struct { Builder string Tests AggregateTest }
TestList is a representation an AggregateResult in which the Results and Runtimes fields of all the AggregateTestLeafs are set to nil.
func (*TestList) MarshalJSON ¶
MarshalJSON marshals tl into JSON.
type TestLocation ¶
TestLocation describes a location of a single test.