testresult

package
v0.0.0-...-fc9d343 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 19 Imported by: 28

Documentation

Overview

Package testresult models test results, which are posted by tasks during execution.

Index

Constants

View Source
const (
	TestResultsServiceLocal = "local"
	TestResultsServiceCedar = "cedar"
)

Valid test results services.

View Source
const (
	SortByStartKey      = "start"
	SortByDurationKey   = "duration"
	SortByTestNameKey   = "test_name"
	SortByStatusKey     = "status"
	SortByBaseStatusKey = "base_status"
)

Valid sort by keys.

View Source
const Collection = "testresults"

Variables

This section is empty.

Functions

func ClearLocal

func ClearLocal(ctx context.Context, env evergreen.Environment) error

ClearLocal clears the local test results store.

func GetMergedFailedTestSample

func GetMergedFailedTestSample(ctx context.Context, env evergreen.Environment, taskOpts []TaskOptions) ([]string, error)

GetMergedFailedTestSample returns a sample of test names (up to 10) that failed in the given tasks.

func InsertLocal

func InsertLocal(ctx context.Context, env evergreen.Environment, results ...TestResult) error

InsertLocal inserts the given test results into the local test results store for testing and local development.

Types

type FilterOptions

type FilterOptions struct {
	TestName            string
	ExcludeDisplayNames bool
	Statuses            []string
	GroupID             string
	Sort                []SortBy
	Limit               int
	Page                int
	BaseTasks           []TaskOptions
}

FilterOptions represents the filtering arguments for fetching test results.

type SortBy

type SortBy struct {
	Key      string
	OrderDSC bool
}

SortBy describes the properties by which to sort a set of test results.

type TaskOptions

type TaskOptions struct {
	TaskID         string
	Execution      int
	ResultsService string
}

TaskOptions represents the task-level information required to fetch test results from an Evergreen test run.

type TaskTestResults

type TaskTestResults struct {
	Stats   TaskTestResultsStats `json:"stats"`
	Results []TestResult         `json:"results"`
}

TaskTestResults represents a set of test results. These results may come from a single task run or multiple related task runs, such as execution tasks within a display task.

func GetMergedTaskTestResults

func GetMergedTaskTestResults(ctx context.Context, env evergreen.Environment, taskOpts []TaskOptions, filterOpts *FilterOptions) (TaskTestResults, error)

GetMergedTaskTestResults returns the merged test results filtered, sorted, and paginated as specified by the optional filter options for the given tasks. This function requires that all specified tasks have persisted their results using the same test results service.

type TaskTestResultsFailedSample

type TaskTestResultsFailedSample struct {
	TaskID                  string   `json:"task_id"`
	Execution               int      `json:"execution"`
	MatchingFailedTestNames []string `json:"matching_failed_test_names"`
	TotalFailedNames        int      `json:"total_failed_names"`
}

TaskTestResultsFailedSample represents a sample of failed test names from an Evergreen task run.

func GetFailedTestSamples

func GetFailedTestSamples(ctx context.Context, env evergreen.Environment, taskOpts []TaskOptions, regexFilters []string) ([]TaskTestResultsFailedSample, error)

GetFailedTestSamples returns failed test samples filtered as specified by the optional regex filters for each task specified.

type TaskTestResultsStats

type TaskTestResultsStats struct {
	TotalCount    int  `json:"total_count" bson:"total_count"`
	FailedCount   int  `json:"failed_count" bson:"failed_count"`
	FilteredCount *int `json:"filtered_count" bson:"-"`
}

TaskTestResultsStats represents basic statistics of a set of test results.

func GetMergedTaskTestResultsStats

func GetMergedTaskTestResultsStats(ctx context.Context, env evergreen.Environment, taskOpts []TaskOptions) (TaskTestResultsStats, error)

GetMergedTaskTestResultsStats returns the aggregated statistics of the test results for the given tasks.

type TestLogInfo

type TestLogInfo struct {
	LogName       string    `json:"log_name" bson:"log_name"`
	LogsToMerge   []*string `json:"logs_to_merge" bson:"logs_to_merge"`
	LineNum       int32     `json:"line_num" bson:"line_num"`
	RenderingType *string   `json:"rendering_type" bson:"rendering_type"`
	Version       int32     `json:"version" bson:"version"`
}

TestLogInfo describes a metadata for a test result's log stored using Evergreen logging.

type TestResult

type TestResult struct {
	TaskID          string       `json:"task_id" bson:"task_id"`
	Execution       int          `json:"execution" bson:"execution"`
	TestName        string       `json:"test_name" bson:"test_name"`
	GroupID         string       `json:"group_id" bson:"group_id"`
	DisplayTestName string       `json:"display_test_name" bson:"display_test_name"`
	Status          string       `json:"status" bson:"status"`
	BaseStatus      string       `json:"base_status" bson:"base_status"`
	LogInfo         *TestLogInfo `json:"log_info" bson:"log_info"`
	TestStartTime   time.Time    `json:"test_start_time" bson:"test_start_time"`
	TestEndTime     time.Time    `json:"test_end_time" bson:"test_end_time"`

	// Legacy test log fields.
	LogTestName string `json:"log_test_name" bson:"log_test_name"`
	LogURL      string `json:"log_url" bson:"log_url"`
	RawLogURL   string `json:"raw_log_url" bson:"raw_log_url"`
	LineNum     int    `json:"line_num" bson:"line_num"`
}

TestResult represents a single test result from an Evergreen task run.

func (TestResult) Duration

func (tr TestResult) Duration() time.Duration

Duration returns the duration of the test.

func (TestResult) GetDisplayTestName

func (tr TestResult) GetDisplayTestName() string

GetDisplayTestName returns the name of the test that should be displayed in the UI. In most cases, this will just be TestName.

func (TestResult) GetLogURL

func (tr TestResult) GetLogURL(env evergreen.Environment, viewer evergreen.LogViewer) string

GetLogURL returns the external or internal log URL for this test result.

It is not advisable to set URL or URLRaw with the output of this function as those fields are reserved for external logs and used to determine URL generation for other log viewers.

Jump to

Keyboard shortcuts

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