Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// User is the configuration for the user to create.
User createusers.Config `json:"user"`
// Workspace is the configuration for the workspace to create. The workspace
// will be built using the new user.
//
// OrganizationID is ignored and set to the new user's organization ID.
Workspace workspacebuild.Config `json:"workspace"`
// WorkspaceJobTimeout is how long to wait for any one workspace job
// (start or stop) to complete.
WorkspaceJobTimeout time.Duration `json:"workspace_job_timeout"`
// AutostartDelay is how long after all the workspaces have been stopped
// to schedule them to be started again.
AutostartDelay time.Duration `json:"autostart_delay"`
// AutostartBuildTimeout is how long to wait for the autostart build to
// complete after it has been triggered. This should be longer than
// WorkspaceJobTimeout to account for potential queueing time in high-load
// scenarios where provisioner capacity is limited.
AutostartBuildTimeout time.Duration `json:"autostart_build_timeout"`
// SetupBarrier is used to ensure all runners own stopped workspaces
// before setting the autostart schedule on each.
SetupBarrier *sync.WaitGroup `json:"-"`
// BuildUpdates is a channel that receives workspace build updates for
// this specific workspace. The channel is pre-created and keyed by the
// deterministic workspace name.
BuildUpdates <-chan codersdk.WorkspaceBuildUpdate `json:"-"`
// ResultSink is a channel where the runner sends its result upon completion.
// This allows the CLI to aggregate results from all concurrent runners.
ResultSink chan<- RunResult `json:"-"`
}
type RunResult ¶ added in v2.32.0
type RunResult struct {
// WorkspaceID is the ID of the workspace that was tested.
WorkspaceID uuid.UUID
// WorkspaceName is the name of the workspace that was tested.
WorkspaceName string
// ConfigTime is when UpdateWorkspaceAutostart was called to set the
// autostart schedule.
ConfigTime time.Time
// ScheduledTime is the time the workspace was scheduled to autostart.
ScheduledTime time.Time
// CompletionTime is when the autostart build completed successfully.
CompletionTime time.Time
// Success indicates whether the autostart build completed successfully.
Success bool
// Error contains the error message if Success is false.
Error string
}
RunResult captures timing and outcome information for a single autostart test run.
func (RunResult) EndToEndLatency ¶ added in v2.32.0
EndToEndLatency returns the total time from setting the autostart config to the autostart build completing.
func (RunResult) TriggerToCompletionLatency ¶ added in v2.32.0
TriggerToCompletionLatency returns the time from the scheduled autostart time to completion. This includes queueing time plus build execution time.
type RunResults ¶ added in v2.32.0
type RunResults struct {
TotalRuns int
SuccessfulRuns int
FailedRuns int
// Individual run results.
Runs []RunResult
// Aggregate latency statistics (end-to-end).
EndToEndLatencyP50 time.Duration
EndToEndLatencyP95 time.Duration
EndToEndLatencyP99 time.Duration
// Aggregate latency statistics (trigger to completion).
TriggerToCompletionP50 time.Duration
TriggerToCompletionP95 time.Duration
TriggerToCompletionP99 time.Duration
}
RunResults contains the aggregated metrics from all autostart test runs.
func NewRunResults ¶ added in v2.32.0
func NewRunResults(runs []RunResult) RunResults
NewRunResults creates a RunResults from a slice of RunResult.
func (RunResults) MarshalJSON ¶ added in v2.32.0
func (r RunResults) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler to provide custom JSON output.
func (RunResults) PrintText ¶ added in v2.32.0
func (r RunResults) PrintText(w io.Writer)
PrintText writes the results in a human-readable text format.
func (RunResults) ToHarnessResults ¶ added in v2.32.0
func (r RunResults) ToHarnessResults() harness.Results
ToHarnessResults converts autostart-specific results into the standard harness.Results format for use with existing output functions.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
type WorkspaceDispatcher ¶ added in v2.32.0
type WorkspaceDispatcher struct {
// Channels maps workspace names to their respective update channels.
Channels map[string]chan codersdk.WorkspaceBuildUpdate
}
WorkspaceDispatcher manages the distribution of workspace build updates from a single source channel to multiple per-workspace channels.
func NewWorkspaceDispatcher ¶ added in v2.32.0
func NewWorkspaceDispatcher(workspaceNames []string) *WorkspaceDispatcher
NewWorkspaceDispatcher creates a new dispatcher for the given workspace names. Each workspace gets a buffered channel that can hold all expected updates during the autostart test lifecycle: - initial build (~3 updates: pending, running, succeeded) - stop build (~3 updates: pending, running, succeeded) - autostart build (~3 updates: pending, running, succeeded) Total: ~9 updates. We use a buffer of 16 to provide headroom for timing variations.
func (*WorkspaceDispatcher) Start ¶ added in v2.32.0
func (d *WorkspaceDispatcher) Start(ctx context.Context, source <-chan codersdk.WorkspaceBuildUpdate)
Start begins listening for workspace build updates and dispatching them to the appropriate workspace channels. It runs in a goroutine and returns immediately. When the source channel closes, all workspace channels are closed automatically.