Documentation
¶
Overview ¶
Package plan provides the model for the test plan.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintSplitSummary ¶
PrintSplitSummary writes a human-readable summary of the resolved test plan to w (typically os.Stderr). At parallelism > 1 it uses per-format TimingMetadata to break down known vs unknown cases. At parallelism == 1 the server skips the per-format timing fetch and emits an empty TimingMetadata, so only the header and case count are printed. Skipped for fallback plans and plans without TimingMetadata at all (e.g. error or older cached plans).
Types ¶
type FormatTimingMetadata ¶
type FormatTimingMetadata struct {
// MedianDuration is the median of historical timings used to backfill
// cases without history. Nil when no history existed at all.
MedianDuration *float64 `json:"median_duration"`
// DefaultDuration is the assumed duration when no history exists at all.
DefaultDuration float64 `json:"default_duration"`
}
FormatTimingMetadata is the timing data for a single case format (file-scoped or example-scoped). All durations are in milliseconds and may be fractional (the server-side median can be the mean of two middle values).
type Task ¶
type Task struct {
NodeNumber int `json:"node_number"`
// When splitting by file, this tests array is essentially an array of test files.
// When splitting by example, this array is an array of proper test cases.
// See comment above, we plan to split TestCase into two types or clarify its usage.
Tests []TestCase `json:"tests"`
}
Task represents the task for the given node.
type TestCase ¶
type TestCase struct {
EstimatedDuration int `json:"estimated_duration,omitempty"`
Format TestCaseFormat `json:"format,omitempty"`
Identifier string `json:"identifier,omitempty"`
Name string `json:"name,omitempty"`
// Path is the path of the individual test or test file that the test runner can interpret.
// For example:
// In RSpec, the path can be a test file like `user_spec.rb` or an individual test id like `user_spec.rb[1,2]`.
// In Jest, the path is a test file like `src/components/Button.spec.tsx`.
// In pytest, the path can be a test file like `test_hello.py` or a node id like `test_hello.py::TestHello::test_greet`
// In go test, the path can only be package name like "example.com/foo/bar".
Path string `json:"path"`
Scope string `json:"scope,omitempty"`
// Value is the runnable selector for selector-based plans, for example a Go package import path.
Value string `json:"value,omitempty"`
// TimingSampleSize is the number of historical executions/runs behind this
// case's EstimatedDuration. For file-scoped cases this is distinct runs,
// for example-scoped cases this is raw executions. Defaults to 0 when no
// history is available or the field is missing on older/cached plans.
TimingSampleSize int `json:"timing_sample_size,omitempty"`
}
TestCase currently can represent a single test case or a single test file (when used as output of test plan API). TODO: it's best if we split this into two types.
type TestCaseFormat ¶
type TestCaseFormat string
const ( TestCaseFormatFile TestCaseFormat = "file" TestCaseFormatExample TestCaseFormat = "example" TestCaseFormatSelector TestCaseFormat = "selector" )
type TestPlan ¶
type TestPlan struct {
Identifier string `json:"identifier"`
Parallelism int `json:"parallelism"`
Experiment string `json:"experiment"`
Tasks map[string]*Task `json:"tasks"`
Fallback bool
MutedTests []TestCase `json:"muted_tests,omitempty"`
SkippedTests []TestCase `json:"skipped_tests,omitempty"`
// TimingMetadata describes the historical timing data the server used to
// build this plan. Nil when missing (e.g. error plans, plans cached before
// the server began emitting it).
TimingMetadata *TimingMetadata `json:"timing_metadata,omitempty"`
// KnownTimingsRatio is the fraction (0.0–1.0) of cases that had historical
// timing data when the plan was built. The server only emits it at
// parallelism > 1, where the split summary instead uses per-format
// TimingMetadata. Currently unread; retained for wire compatibility.
KnownTimingsRatio *float64 `json:"known_timings_ratio,omitempty"`
}
TestPlan represents the entire test plan.
func CreateFallbackPlan ¶
CreateFallbackPlan creates a fallback test plan for the given tests and parallelism. It distributes test cases evenly across the tasks using deterministic algorithm.
func (TestPlan) HasNoSelectorTimingHistory ¶
HasNoSelectorTimingHistory reports whether a multi-node selector plan used default durations because no historical selector timings were available.
type TimingMetadata ¶
type TimingMetadata struct {
File *FormatTimingMetadata `json:"file,omitempty"`
Example *FormatTimingMetadata `json:"example,omitempty"`
Selector *FormatTimingMetadata `json:"selector,omitempty"`
}
TimingMetadata describes the historical timing data the server used to build the test plan, broken down per case format. Either key may be omitted when the plan contains no cases of that format (or when parallelism is 1 and no timings were fetched).