Documentation
¶
Index ¶
- func ErrorContainsAny(err error, substrings ...string) bool
- func IsTransientConnectionError(err error) bool
- func IsTransientDeployError(err error) bool
- func IsTransientImagePullError(err error) bool
- func ValidateAllDetails(code string, details []DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
- func ValidateAnyDetails(code string, details []DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
- func ValidateSingleDetail(code string, detail DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
- type DeployErrorExecutor
- func (d *DeployErrorExecutor) Execute(ctx context.Context, t *testing.T, options test.TestOptions)
- func (d *DeployErrorExecutor) GetDescription() string
- func (d *DeployErrorExecutor) WithApplication(application string) *DeployErrorExecutor
- func (d *DeployErrorExecutor) WithEnvironment(environment string) *DeployErrorExecutor
- type DeployExecutor
- func (d *DeployExecutor) Execute(ctx context.Context, t *testing.T, options test.TestOptions)
- func (d *DeployExecutor) GetDescription() string
- func (d *DeployExecutor) WithApplication(application string) *DeployExecutor
- func (d *DeployExecutor) WithEnvironment(environment string) *DeployExecutor
- func (d *DeployExecutor) WithRetry(maxRetries int, delay time.Duration, shouldRetry func(error) bool) *DeployExecutor
- type DeploymentErrorDetail
- type Executor
- type FuncExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorContainsAny ¶
ErrorContainsAny reports whether err - including the nested ARM error details that rad surfaces inside a CLIError - contains any of the given substrings.
rad returns the deployment root cause inside nested ARM error details[].message fields, while CLIError.Error() only exposes the top-level code and message (for example "DeploymentFailed"). ErrorContainsAny therefore flattens the full ARM error response before matching so callers can detect deeply nested causes. It is the shared building block for transient-error retry predicates such as IsTransientImagePullError.
func IsTransientConnectionError ¶
IsTransientConnectionError reports whether err was caused by a transient network disruption between rad and the UCP API server (a reset or closed port-forward tunnel) that is likely to succeed on retry. See transientConnectionErrorMarkers for the environmental root cause.
A connection reset/EOF is a transport-level failure that rad surfaces as a non-structured exit error, never as a structured ARM error. It therefore never matches a *radcli.CLIError: guarding on the concrete type ensures a genuine deployment failure whose flattened ARM message happens to contain a marker such as "unexpected EOF" is not misclassified as retryable.
func IsTransientDeployError ¶
IsTransientDeployError reports whether err was caused by any transient failure that a deployment is likely to recover from on retry - either a container image pull blip (IsTransientImagePullError) or a UCP connection reset/EOF (IsTransientConnectionError). It is the default ShouldRetry predicate for DeployExecutor (see NewDeployExecutor).
func IsTransientImagePullError ¶
IsTransientImagePullError reports whether err was caused by a transient container image pull failure that is likely to succeed on retry. It is used by tests that pull images from a shared registry (for example the ghcr.io/radius-project/mirror images), which occasionally fail to pull due to registry or network blips in CI.
func ValidateAllDetails ¶
func ValidateAllDetails(code string, details []DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
ValidateAllDetails reports success if all of the provided error details are found in the error response.
func ValidateAnyDetails ¶
func ValidateAnyDetails(code string, details []DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
ValidateAnyDetails reports success if any of the provided error details are found in the error response.
func ValidateSingleDetail ¶
func ValidateSingleDetail(code string, detail DeploymentErrorDetail) func(*testing.T, *radcli.CLIError)
ValidateSingleDetail reports success if the error code matches the expected code and the detail item is found in the error response..
Types ¶
type DeployErrorExecutor ¶
type DeployErrorExecutor struct {
Description string
Template string
Parameters []string
// ValidateError is a function that can be used to validate the error when it occurs.
ValidateError func(*testing.T, *radcli.CLIError)
// Application sets the `--application` command-line parameter. This is needed in cases where
// the application is not defined in bicep.
Application string
// Environment sets the `--environment` command-line parameter. This is needed in cases where
// the environment is not defined in bicep.
Environment string
}
func NewDeployErrorExecutor ¶
func NewDeployErrorExecutor(template string, validateError func(*testing.T, *radcli.CLIError), parameters ...string) *DeployErrorExecutor
NewDeployErrorExecutor creates a new DeployErrorExecutor instance with the given template, error code and parameters.
func (*DeployErrorExecutor) Execute ¶
func (d *DeployErrorExecutor) Execute(ctx context.Context, t *testing.T, options test.TestOptions)
Execute deploys an application from a template file and checks that the deployment fails with the expected error code.
func (*DeployErrorExecutor) GetDescription ¶
func (d *DeployErrorExecutor) GetDescription() string
GetDescription returns the Description field of the DeployErrorExecutor instance.
func (*DeployErrorExecutor) WithApplication ¶
func (d *DeployErrorExecutor) WithApplication(application string) *DeployErrorExecutor
WithApplication sets the application name for the DeployErrorExecutor instance and returns the instance.
func (*DeployErrorExecutor) WithEnvironment ¶
func (d *DeployErrorExecutor) WithEnvironment(environment string) *DeployErrorExecutor
WithEnvironment sets the environment name for the DeployExecutor instance and returns the same instance.
type DeployExecutor ¶
type DeployExecutor struct {
Description string
Template string
Parameters []string
// Application sets the `--application` command-line parameter. This is needed in cases where
// the application is not defined in bicep.
Application string
// Environment sets the `--environment` command-line parameter. This is needed in cases where
// the environment is not defined in bicep.
Environment string
// MaxRetries is the maximum number of retry attempts after the initial deployment fails.
// Zero means no retries (default behavior).
MaxRetries int
// RetryDelay is the duration to wait between retry attempts.
RetryDelay time.Duration
// ShouldRetry is a predicate that determines whether a failed deployment should be retried.
// If nil, no retries are attempted regardless of MaxRetries.
ShouldRetry func(error) bool
}
func NewDeployExecutor ¶
func NewDeployExecutor(template string, parameters ...string) *DeployExecutor
NewDeployExecutor creates a new DeployExecutor instance with the given template and parameters.
By default the executor retries a deployment that fails with a transient error - either a container image pull blip or a UCP connection reset/EOF (see IsTransientDeployError). Use WithRetry to override the retry count, delay, and predicate.
func (*DeployExecutor) Execute ¶
func (d *DeployExecutor) Execute(ctx context.Context, t *testing.T, options test.TestOptions)
Execute deploys an application from a template file using the provided parameters and logs the deployment process.
func (*DeployExecutor) GetDescription ¶
func (d *DeployExecutor) GetDescription() string
GetDescription returns the Description field of the DeployExecutor instance.
func (*DeployExecutor) WithApplication ¶
func (d *DeployExecutor) WithApplication(application string) *DeployExecutor
WithApplication sets the application name for the DeployExecutor instance and returns the same instance.
func (*DeployExecutor) WithEnvironment ¶
func (d *DeployExecutor) WithEnvironment(environment string) *DeployExecutor
WithEnvironment sets the environment name for the DeployExecutor instance and returns the same instance.
func (*DeployExecutor) WithRetry ¶ added in v0.57.0
func (d *DeployExecutor) WithRetry(maxRetries int, delay time.Duration, shouldRetry func(error) bool) *DeployExecutor
WithRetry configures retry behavior for transient deployment failures, replacing the default transient image pull retry set by NewDeployExecutor. maxRetries is the number of additional attempts after the first failure. delay is the wait time between attempts. shouldRetry determines whether a given error is eligible for retry.
type DeploymentErrorDetail ¶
type DeploymentErrorDetail struct {
// The error code to match.
Code string
// The message to match. If provided, this will be matched against a substring of the error.
MessageContains string
// The details to match. If provided, this will be matched against the details of the error.
Details []DeploymentErrorDetail
}
DeploymentErrorDetail describes an error that can be matched against the output.
func (DeploymentErrorDetail) Matches ¶
func (detail DeploymentErrorDetail) Matches(candidate *v1.ErrorDetails) bool
type FuncExecutor ¶ added in v0.46.0
type FuncExecutor struct {
Description string
// contains filtered or unexported fields
}
FuncExecutor implements the Executor interface. It encapsulates a function to be executed in a test step and includes a description.
func NewFuncExecutor ¶ added in v0.46.0
func NewFuncExecutor(fn func(ctx context.Context, t *testing.T, opts test.TestOptions)) FuncExecutor
NewFuncExecutor initializes and returns a new FuncExecutor with the given function and a default description.
func (FuncExecutor) Execute ¶ added in v0.46.0
func (f FuncExecutor) Execute(ctx context.Context, t *testing.T, opts test.TestOptions)
Execute runs the encapsulated function with the provided context, testing instance, and test options.
func (FuncExecutor) GetDescription ¶ added in v0.46.0
func (f FuncExecutor) GetDescription() string
GetDescription returns the description of the test step encapsulated by the FuncExecutor.