Documentation ¶
Index ¶
- func AddImageDeps(s *Shard, images []build.Image, pave bool)
- func ApplyRealmLabel(shards []*Shard, realmLabel string)
- func ApplyTestTimeouts(shards []*Shard, perTestTimeout time.Duration)
- func ExtractDeps(shards []*Shard, fuchsiaBuildDir string) error
- func ValidateTests(specs []build.TestSpec, platforms []build.DimensionSet) error
- type Mode
- type RunAlgorithm
- type Shard
- func MakeShards(specs []build.TestSpec, opts *ShardOptions) []*Shard
- func MultiplyShards(ctx context.Context, shards []*Shard, multipliers []TestModifier, ...) ([]*Shard, error)
- func ShardAffected(shards []*Shard, modTests []TestModifier, affectedOnly bool) ([]*Shard, error)
- func WithTargetDuration(shards []*Shard, targetDuration time.Duration, ...) []*Shard
- type ShardOptions
- type Test
- type TestDurationsMap
- type TestModifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddImageDeps ¶
AddImageDeps selects and adds the subset of images needed by a shard to that shard's list of dependencies.
func ApplyRealmLabel ¶
Applies the realm label to all tests on all shards provided.
func ApplyTestTimeouts ¶
ApplyTestTimeouts sets the timeout field on every test to the specified duration.
func ExtractDeps ¶
func ValidateTests ¶
func ValidateTests(specs []build.TestSpec, platforms []build.DimensionSet) error
ValidateTests validates a list of test specs against a list of available test platforms.
Types ¶
type Mode ¶
type Mode int
Mode is a mode in which the testsharder can be run.
const ( // Normal is the default mode in which all tests are sharded, except // those excluded by differing tags. Normal Mode = iota // Restricted is the mode in which auth-needing tests (i.e., those that // specify service accounts) are ignored. This mode is useful for // running untrusted code. Restricted )
type RunAlgorithm ¶
type RunAlgorithm string
RunAlgorithm describes how to run a test using the test's `Runs` field.
const ( // KeepGoing means to run the test for as many times as `Runs` // regardless of the result of each test run. KeepGoing RunAlgorithm = "KEEP_GOING" // StopOnFailure means to try the test up to `Runs` times // and to break on the first failure. StopOnFailure RunAlgorithm = "STOP_ON_FAILURE" // StopOnSuccess means to try the test up to `Runs` times // and to break on the first success. StopOnSuccess RunAlgorithm = "STOP_ON_SUCCESS" )
type Shard ¶
type Shard struct { // Name is the identifier for the shard. Name string `json:"name"` // Tests is the set of tests to be executed in this shard. Tests []Test `json:"tests"` // Env is a generalized notion of the execution environment for the shard. Env build.Environment `json:"environment"` // Deps is the list of runtime dependencies required to be present on the host // at shard execution time. It is a list of paths relative to the fuchsia // build directory. Deps []string `json:"deps,omitempty"` // PkgRepo is the path to the shard-specific package repository. It is // relative to the fuchsia build directory, and is a directory itself. PkgRepo string `json:"pkg_repo,omitempty"` // TimeoutSecs is the execution timeout, in seconds, that should be set for // the task that runs the shard. It's computed dynamically based on the // expected runtime of the tests. TimeoutSecs int `json:"timeout_secs"` }
Shard represents a set of tests with a common execution environment.
func MakeShards ¶
func MakeShards(specs []build.TestSpec, opts *ShardOptions) []*Shard
MakeShards returns the list of shards associated with a given build. A single output shard will contain only tests that have the same environment.
func MultiplyShards ¶
func MultiplyShards( ctx context.Context, shards []*Shard, multipliers []TestModifier, testDurations TestDurationsMap, targetDuration time.Duration, targetTestCount int, ) ([]*Shard, error)
MultiplyShards appends new shards to shards where each new shard contains one test repeated multiple times according to the specifications in multipliers. It also removes all multiplied tests from the input shards.
func ShardAffected ¶
func ShardAffected(shards []*Shard, modTests []TestModifier, affectedOnly bool) ([]*Shard, error)
ShardAffected separates the affected tests into separate shards. If `affectedOnly` is true, it will only return the affected test shards.
func WithTargetDuration ¶
func WithTargetDuration( shards []*Shard, targetDuration time.Duration, targetTestCount, maxShardsPerEnvironment int, testDurations TestDurationsMap, ) []*Shard
WithTargetDuration returns a list of shards such that all shards are expected to complete in approximately `targetDuration` time. If targetDuration <= 0, just returns its input. Alternatively, accepts a `targetTestCount` argument for backwards compatibility.
Each resulting shard will have a TimeoutSecs field populated dynamically based on the expected total runtime of its tests. The caller can choose to respect and enforce this timeout, or ignore it.
func (*Shard) AddDeps ¶
AddDeps adds a set of runtime dependencies to the shard. It ensures no duplicates and a stable ordering.
func (*Shard) CreatePackageRepo ¶
CreatePackageRepo creates a package repository for the given shard.
type ShardOptions ¶
type ShardOptions struct { // Mode is a general mode in which the testsharder will be run. See mode.go // for more details. Mode Mode // Tags is the list of tags that the sharded Environments must match; those // that don't match all tags will be ignored. Tags []string }
ShardOptions parametrize sharding behavior.
type Test ¶
type Test struct { build.Test // Runs is the number of times this test should be run. Runs int `json:"runs,omitempty"` // RunAlgorithm determines how `Runs` will be used to run the test. RunAlgorithm RunAlgorithm `json:"run_algorithm,omitempty"` // RealmLabel is an optional arg passed to run-test-component to specify a // realm. RealmLabel string `json:"realm_label,omitempty"` // StopRepeatingAfterSecs is the duration for which to repeatedly run a // test. StopRepeatingAfterSecs int `json:"stop_repeating_after_secs,omitempty"` // Timeout is the timeout that should be set for each run of this test. Timeout time.Duration `json:"timeout_nanos,omitempty"` }
Test is a struct used to hold information about a build.Test and how to run it.
type TestDurationsMap ¶
type TestDurationsMap map[string]build.TestDuration
TestDurationsMap maps test names to corresponding test duration data.
func NewTestDurationsMap ¶
func NewTestDurationsMap(durations []build.TestDuration) TestDurationsMap
func (TestDurationsMap) Get ¶
func (m TestDurationsMap) Get(test Test) build.TestDuration
Get returns the duration data for a given test. If the test is not included in the durations map, the default duration data is returned instead.
type TestModifier ¶
type TestModifier struct { // Name is the name of the test. Name string `json:"name"` // OS is the operating system in which this test must be executed. If not // present, this multiplier will match tests from any operating system. OS string `json:"os,omitempty"` // TotalRuns is the number of times to run the test. If not present, // testsharder will try to produce exactly one full shard for this test // using historical test duration data. TotalRuns int `json:"total_runs,omitempty"` // Affected specifies whether the test is an affected test. If affected, // it will be run in a separate shard than the unaffected tests. Affected bool `json:"affected,omitempty"` // MaxAttempts is the max number of times to run this test if it fails. // This is the max attempts per run as specified by the `TotalRuns` field. MaxAttempts int `json:"max_attempts,omitempty"` }
TestModifier is the specification for a single test and the number of times it should be run.
func AffectedModifiers ¶
func AffectedModifiers(testSpecs []build.TestSpec, affectedTestsPath string, maxAttempts, multiplyThreshold int) ([]TestModifier, error)
AffectedModifiers returns modifiers for tests that are in both testSpecs and affectedTestsPath. affectedTestsPath is the path to a file containing test names separated by `\n`. maxAttempts will be applied to any test that is not multiplied. Tests will be considered for multiplication only if num affected tests <= multiplyThreshold.
func LoadTestModifiers ¶
func LoadTestModifiers(manifestPath string) ([]TestModifier, error)
LoadTestModifiers loads a set of test modifiers from a json manifest.