Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// AccessToken is the access token for the API.
AccessToken string `json:"-"`
// PromiseFailure, when true, makes bktec declare an early failure via the
// `buildkite-agent job promise-failure` CLI once retries are exhausted and
// hard failures remain.
PromiseFailure bool `json:"-"`
// UploadBaseURL is the base URL for the Test Engine analytics API.
UploadBaseURL string `json:"-"`
// Branch is the string value of the git branch name, used by Buildkite only.
Branch string `json:"-"`
BuildID string `json:"-"`
BuildkiteAgentCommand string `json:"-"`
// CollectGitMetadata enables git metadata auto-collection on plan without requiring --selection-strategy to be set.
CollectGitMetadata bool `json:"-"`
// Concurrency is the number of concurrent git operations for diff collection (default 10).
Concurrency int `json:"-"`
// Days is the lookback window in days for the commit list API (1-90, default 90).
Days int `json:"-"`
// Enable debug output
DebugEnabled bool `json:"-"`
// FailOnNoTests causes the client to exit with an error if no tests are assigned to the node
FailOnNoTests bool `json:"-"`
// Identifier is the identifier of the build.
Identifier string `json:"-"`
JobID string `json:"-"`
// JobRetryCount is the count of the number of times the job has been retried.
JobRetryCount int `json:"-"`
// LocationPrefix is prepended to test file paths when requesting a test plan.
// Use this when the test collector is configured to report files with a path prefix,
// so the test plan API can correctly match and bin-pack them across nodes.
LocationPrefix string `json:"-"`
// MaxParallelism is the maximum parallelism when calculating parallelism dynamically.
MaxParallelism int `json:"-"`
// MaxRetries is the maximum number of retries for a failed test.
MaxRetries int `json:"-"`
// Metadata is additional key/value data sent to the test plan API.
Metadata map[string]string `json:"-"`
// Node index is index of the current node.
NodeIndex int `json:"-"`
// Enable OIDC token generation
OIDC bool `json:"-"`
// Lifetime of OIDC tokens
OIDCLifetime time.Duration `json:"-"`
// OrganizationSlug is the slug of the organization.
OrganizationSlug string `json:"-"`
// Output is the local file path for the export tarball. If set, skip S3 upload.
Output string `json:"-"`
// Parallelism is the number of parallel tasks to run.
Parallelism int `json:"-"`
// PlanOut is the destination for the `bktec plan --plan-out` output: "-" for
// stdout, or a file path. The full test plan is written as the server's
// response, unmodified.
PlanOut string `json:"-"`
// Remote is the git remote name for fetching missing commits and detecting default branch (default "origin").
Remote string `json:"-"`
// ResultPath is the path to the result file.
ResultPath string `json:"-"`
// RetryCommand is the command to run the retry tests.
RetryCommand string `json:"-"`
// RetryForMutedTest indicates whether a failed muted test should be retried.
// This is default to true because we want more signal for our flaky detection system.
RetryForMutedTest bool `json:"-"`
// SelectionParams are additional key/value parameters for the strategy.
SelectionParams map[string]string `json:"-"`
// SelectionStrategy is the selection strategy sent to the test plan API.
SelectionStrategy string `json:"-"`
// ServerBaseURL is the base URL of the test plan server.
ServerBaseURL string `json:"-"`
// SkipDiffs omits git_diff and git_diff_raw from the export to reduce upload size.
SkipDiffs bool `json:"-"`
// UploadFile is the path to a previously generated tarball for the --upload flag of backfill-commit-metadata.
UploadFile string `json:"-"`
// UploadResults enables uploading test results to the Test Engine analytics API after each run.
UploadResults bool `json:"-"`
// UploadTags are key/value tags attached to the upload when sending test results.
UploadTags map[string]string `json:"-"`
// UploadToken is the token used by test collectors. From `BUILDKITE_ANALYTICS_TOKEN` if present, otherwise generated by `buildkite-agent oidc request-token`.
UploadToken string `json:"-"`
// SelectorSplitting enables selector-based splitting for supported runners.
SelectorSplitting bool `json:"-"`
// File path containing the list of selectors to run. If not set, `bktec` will rely on each runner implementation of `GetSelectors`
SelectorListPath string `json:"-"`
// SplitByExample is the flag to enable split the test by example.
SplitByExample bool `json:"-"`
StepID string `json:"-"`
// SuiteSlug is the slug of the suite.
SuiteSlug string `json:"-"`
// TagFilters filters test examples by execution tags.
TagFilters string `json:"-"`
// TargetTime is the target time in seconds for the test plan.
TargetTime time.Duration `json:"-"`
// TestCommand is the command to run the tests.
TestCommand string `json:"-"`
// TestFileExcludePattern is the pattern to exclude the test files.
TestFileExcludePattern string `json:"-"`
// TestFilePattern is the pattern to match the test files.
TestFilePattern string `json:"-"`
// TestRunner is the name of the runner.
TestRunner string `json:"-"`
// contains filtered or unexported fields
}
Config is the internal representation of the complete test engine client configuration.
Config is never serialized to the wire: every field is tagged json:"-". The data sent to the API in the "env" request field is represented by the separate EnvPayload type and built via Config.EnvPayload. This keeps internal configuration decoupled from the API contract, so adding a field here does not cause it to be sent to the API unless it is also added to EnvPayload.
func (*Config) EnvPayload ¶ added in v2.9.0
func (c *Config) EnvPayload() EnvPayload
EnvPayload builds the API "env" payload from the client configuration. This is the single, deliberate boundary where internal configuration crosses into an API request body.
func (*Config) ValidateForBackfillCommitMetadata ¶
ValidateForBackfillCommitMetadata validates config for the backfill-commit-metadata command. API connection fields and suite slug are required in all modes (the presigned upload endpoint is suite-scoped). Collection-only fields (days, concurrency) are checked when --upload is not set.
func (*Config) ValidateForPlan ¶
Validation for the `bktec plan` command
func (*Config) ValidateForRun ¶
Validation for the `bktec run` command
type EnvPayload ¶ added in v2.9.0
type EnvPayload struct {
BuildID string `json:"BUILDKITE_BUILD_ID"`
DebugEnabled bool `json:"BUILDKITE_TEST_ENGINE_DEBUG_ENABLED"`
Identifier string `json:"BUILDKITE_TEST_ENGINE_IDENTIFIER"`
JobID string `json:"BUILDKITE_JOB_ID"`
JobRetryCount int `json:"BUILDKITE_RETRY_COUNT"`
MaxRetries int `json:"BUILDKITE_TEST_ENGINE_RETRY_COUNT"`
NodeIndex int `json:"BUILDKITE_PARALLEL_JOB"`
OrganizationSlug string `json:"BUILDKITE_ORGANIZATION_SLUG"`
Parallelism int `json:"BUILDKITE_PARALLEL_JOB_COUNT"`
RetryCommand string `json:"BUILDKITE_TEST_ENGINE_RETRY_CMD"`
SplitByExample bool `json:"BUILDKITE_TEST_ENGINE_SPLIT_BY_EXAMPLE"`
StepID string `json:"BUILDKITE_STEP_ID"`
SuiteSlug string `json:"BUILDKITE_TEST_ENGINE_SUITE_SLUG"`
TagFilters string `json:"BUILDKITE_TEST_ENGINE_TAG_FILTERS"`
TestCommand string `json:"BUILDKITE_TEST_ENGINE_TEST_CMD"`
TestFileExcludePattern string `json:"BUILDKITE_TEST_ENGINE_TEST_FILE_EXCLUDE_PATTERN"`
TestFilePattern string `json:"BUILDKITE_TEST_ENGINE_TEST_FILE_PATTERN"`
TestRunner string `json:"BUILDKITE_TEST_ENGINE_TEST_RUNNER"`
}
EnvPayload is the data the client sends to the Test Engine API in the "env" field of requests (currently the filter_tests and test_plan_metadata endpoints).
It is deliberately a separate type from Config so that the API contract is explicit and opt-in: Config is the client's internal configuration and is never serialized to the wire, whereas every field here is intentionally part of the request payload. Adding a new field to Config does NOT cause it to be sent to the API; it must be added here and mapped in Config.EnvPayload.
The JSON keys below preserve the exact wire format that was previously produced by serializing Config directly, so existing API calls are unaffected.
type InvalidConfigError ¶
InvalidConfigError is an error that contains a map of all validation errors on each field of the configuration.
func (InvalidConfigError) Error ¶
func (i InvalidConfigError) Error() string