Documentation
¶
Index ¶
- type CleanupOptions
- type Config
- type Deployer
- func (d *Deployer) Cleanup(ctx context.Context, opts CleanupOptions) error
- func (d *Deployer) CleanupJob(ctx context.Context) error
- func (d *Deployer) CleanupRBAC(ctx context.Context) error
- func (d *Deployer) Deploy(ctx context.Context) error
- func (d *Deployer) DeployJob(ctx context.Context) error
- func (d *Deployer) EnsureRBAC(ctx context.Context) error
- func (d *Deployer) GetPodLogs(ctx context.Context) (string, error)
- func (d *Deployer) GetResult(ctx context.Context) (*ValidationResult, error)
- func (d *Deployer) StreamLogs(ctx context.Context) error
- func (d *Deployer) WaitForCompletion(ctx context.Context, timeout time.Duration) error
- type GoTestEvent
- type TestResult
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupOptions ¶
type CleanupOptions struct {
// Enabled determines whether to cleanup resources
Enabled bool
}
CleanupOptions controls what resources to remove during cleanup.
type Config ¶
type Config struct {
// Namespace is where the validation Job will be deployed
Namespace string
// JobName is the name of the Kubernetes Job
JobName string
// Image is the container image to use (should contain aicr CLI)
Image string
// ImagePullSecrets for pulling the image from private registries
ImagePullSecrets []string
// ServiceAccountName for the Job pods
ServiceAccountName string
// Tolerations for scheduling on tainted nodes
Tolerations []corev1.Toleration
// Affinity specifies pod scheduling affinity rules.
// Used to prefer CPU nodes for non-GPU validation Jobs.
Affinity *corev1.Affinity
// SnapshotConfigMap is the ConfigMap containing the snapshot data
SnapshotConfigMap string
// RecipeConfigMap is the ConfigMap containing the recipe data
RecipeConfigMap string
// TestPackage is the Go package path used to derive the pre-compiled test binary name.
// filepath.Base(TestPackage) + ".test" gives the binary (e.g. "readiness.test").
TestPackage string
// TestPattern is the test name pattern to run (passed to -run flag)
// Example: "TestGpuHardwareDetection"
TestPattern string
// ExpectedTests is the number of tests expected to run.
// If set and actual tests differ, validation fails.
ExpectedTests int
// Timeout for the Job to complete
Timeout time.Duration
// Cleanup determines whether to remove Job and RBAC on completion
Cleanup bool
// Debug enables debug logging
Debug bool
}
Config holds the configuration for deploying a validation agent Job.
type Deployer ¶
type Deployer struct {
// contains filtered or unexported fields
}
Deployer manages the deployment and lifecycle of validation agent Jobs.
func NewDeployer ¶
func NewDeployer(clientset kubernetes.Interface, config Config) *Deployer
NewDeployer creates a new validation agent Deployer.
func (*Deployer) Cleanup ¶
func (d *Deployer) Cleanup(ctx context.Context, opts CleanupOptions) error
Cleanup removes the validation Job and RBAC resources. For multi-phase validation, prefer CleanupJob() per phase, then CleanupRBAC() once at end.
func (*Deployer) CleanupJob ¶
CleanupJob removes the validation Job. Use this after each phase in multi-phase validation to clean up per-phase Jobs.
func (*Deployer) CleanupRBAC ¶
CleanupRBAC removes RBAC resources (ServiceAccount, Role, RoleBinding). Use this once at the end of multi-phase validation after all Jobs are done.
func (*Deployer) Deploy ¶
Deploy deploys the validation agent with all required resources (RBAC + Job). For multi-phase validation, prefer using EnsureRBAC() once, then DeployJob() per phase.
func (*Deployer) DeployJob ¶
DeployJob deploys the validation Job. Assumes RBAC resources already exist (call EnsureRBAC first). This deletes any existing Job with the same name before creating a new one.
func (*Deployer) EnsureRBAC ¶
EnsureRBAC creates RBAC resources (ServiceAccount, Role, RoleBinding). This is idempotent - safe to call multiple times, reuses existing resources. For multi-phase validation, call this once before running multiple Jobs.
func (*Deployer) GetPodLogs ¶
GetPodLogs retrieves all pod logs as a string. This is useful for capturing logs when a Job fails for debugging.
func (*Deployer) GetResult ¶
func (d *Deployer) GetResult(ctx context.Context) (*ValidationResult, error)
GetResult retrieves the validation result from the Job's pod logs.
func (*Deployer) StreamLogs ¶
StreamLogs streams logs from the validation Job pod to the provided writer.
type GoTestEvent ¶
type GoTestEvent struct {
Time time.Time
Action string
Package string
Test string
Output string
Elapsed float64
}
GoTestEvent represents a single event from go test -json output.
type TestResult ¶
type TestResult struct {
// Name is the test function name (e.g., "TestGpuHardwareDetection")
Name string
// Status is the test result (pass/fail/skip)
Status string
// Duration is how long the test took
Duration time.Duration
// Output contains the test output lines
Output []string
}
TestResult represents the result of a single test function.
type ValidationResult ¶
type ValidationResult struct {
// CheckName is the name of the check that was run
CheckName string
// Phase is the validation phase
Phase string
// Status is the result status (pass/fail/skip)
Status string
// Message provides details about the result
Message string
// Duration is how long the check took
Duration time.Duration
// Details contains structured data about the result
Details map[string]interface{}
// Tests contains individual test results when parsing go test JSON output
// Each entry represents a single test function that was executed
Tests []TestResult
}
ValidationResult represents the result of running validation checks.