shard

package
v0.16.7 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shard splits test suites into balanced shards, so CI can run each shard on its own machine in parallel.

Index

Constants

View Source
const (
	// EnvIndex names the variable holding the 1-based shard to run.
	EnvIndex = "E2E_SHARD_INDEX"
	// EnvTotal names the variable holding the number of shards.
	EnvTotal = "E2E_SHARD_TOTAL"
)

Variables

This section is empty.

Functions

func Assign

func Assign(estimates []time.Duration, total int, opts ...Option) ([][]int, error)

Assign splits items into total shards by their estimated durations and returns, per shard, the indexes of its items in ascending order, so items keep their relative order. Items are placed longest first, each on the shard with the least estimated work so far (ties go to the lowest shard), so a shard that gets items ends at most one item above the average. The result depends only on the inputs. Every estimate must be positive.

Types

type Option

type Option func(*config)

Option configures Assign.

func Reserve

func Reserve(shard int, d time.Duration) Option

Reserve counts d as work already planned on the 1-based shard, for work that runs there besides the assigned items. Reservations on one shard add up.

type Spec

type Spec struct {
	Index int
	Total int
}

Spec selects shard Index (1-based) out of Total.

func FromEnv

func FromEnv() (Spec, error)

FromEnv reads the shard from E2E_SHARD_INDEX and E2E_SHARD_TOTAL. With both unset it returns shard 1 of 1, which runs everything. Setting only one of them, or a value that does not name a shard, is an error.

Jump to

Keyboard shortcuts

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