Documentation
¶
Index ¶
- func TruncateLogLines(content []byte, maxLines int) []byte
- type ArtifactInventory
- type Collector
- type Config
- type MetadataBuilder
- type RunMetadata
- type Storage
- func (s *Storage) CreateTestDir(testName string) (string, error)
- func (s *Storage) GetRunDir() string
- func (s *Storage) GetRunID() string
- func (s *Storage) WriteFile(testDir, category, filename string, content []byte) error
- func (s *Storage) WriteFileInRunDir(filename string, content []byte) error
- func (s *Storage) WriteStream(testDir, category, filename string, reader io.Reader, maxLines int) error
- type TestInfo
- type TestMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TruncateLogLines ¶
TruncateLogLines truncates log output to specified number of lines Takes the LAST N lines (most recent logs are most relevant for debugging)
Types ¶
type ArtifactInventory ¶
type ArtifactInventory struct {
PodCount int `json:"pod_count"`
LogFiles []string `json:"log_files"`
ResourceFiles []string `json:"resource_files"`
EventFiles []string `json:"event_files"`
TotalSizeBytes int64 `json:"total_size_bytes"`
CollectionTime string `json:"collection_time"` // Human-readable duration
}
ArtifactInventory tracks what artifacts were collected
type Collector ¶
type Collector interface {
// Initialize sets up the collector for a test run
Initialize(runID string) error
// CollectForTest collects artifacts for a test
CollectForTest(ctx context.Context, testInfo TestInfo) error
// Close finalizes the collector and writes summary
Close() error
}
Collector manages artifact collection for e2e tests
func NewCollector ¶
NewCollector creates a new artifact collector
type Config ¶
type Config struct {
// Collection control
Enabled bool // Master switch for artifact collection
CollectOnFailureOnly bool // Collect artifacts only for failed tests
CollectMinimalOnly bool // Collect only P0 artifacts (fast path)
// Storage paths
BaseDir string // Base directory for artifact storage
// Size limits (prevent artifact bloat)
MaxLogLines int // Maximum log lines per pod
MaxResourceSize int64 // Maximum size for single resource (bytes)
MaxTotalSize int64 // Maximum total size per test (bytes)
// Timeouts
CollectionTimeout time.Duration // Maximum time to collect artifacts
// Filters
NamespacePatterns []string // Namespace patterns to collect from
PodLabelSelectors []string // Pod label selectors for filtering
}
Config defines artifact collection behavior
func LoadConfigFromEnv ¶
func LoadConfigFromEnv() Config
LoadConfigFromEnv loads configuration from environment variables Following Phase 1 pattern: ENV-based config with sensible defaults
type MetadataBuilder ¶
type MetadataBuilder struct {
// contains filtered or unexported fields
}
MetadataBuilder helps build and write metadata files
func NewMetadataBuilder ¶
func NewMetadataBuilder(storage *Storage) *MetadataBuilder
NewMetadataBuilder creates a new metadata builder
func (*MetadataBuilder) WriteRunMetadata ¶
func (m *MetadataBuilder) WriteRunMetadata(meta RunMetadata) error
WriteRunMetadata writes run metadata to JSON file
func (*MetadataBuilder) WriteTestMetadata ¶
func (m *MetadataBuilder) WriteTestMetadata(meta TestMetadata, testDir string) error
WriteTestMetadata writes test metadata to JSON file
type RunMetadata ¶
type RunMetadata struct {
RunID string `json:"run_id"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
TotalTests int `json:"total_tests"`
FailedTests int `json:"failed_tests"`
PassedTests int `json:"passed_tests"`
Environment map[string]string `json:"environment"`
ArtifactsDir string `json:"artifacts_dir"`
// Git information for tracking test run version
GitCommit string `json:"git_commit,omitempty"`
GitBranch string `json:"git_branch,omitempty"`
GitDirty string `json:"git_dirty,omitempty"` // "dirty", "staged", or empty if clean
Description string `json:"description,omitempty"` // Optional user description
}
RunMetadata contains metadata about an entire test run
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage handles filesystem operations for artifact collection
func NewStorage ¶
NewStorage creates a new storage instance with specified configuration
func (*Storage) CreateTestDir ¶
CreateTestDir creates a directory for a specific test
func (*Storage) WriteFile ¶
WriteFile writes content to a file within a test directory with size limits testDir: test-specific directory name (e.g., "test-normal-mode") category: subdirectory within test dir (e.g., "logs", "resources", "events") filename: name of the file to write
func (*Storage) WriteFileInRunDir ¶
WriteFileInRunDir writes a file directly in the run directory (not test-specific) Used for run-level metadata
type TestInfo ¶
type TestInfo struct {
Name string
Namespace string
Failed bool
FailureMessage string
Duration time.Duration
StartTime time.Time
EndTime time.Time
Labels []string
// Test sequence tracking (for degradation analysis)
SequenceNumber int // Which test in the run (1, 2, 3...)
OperatorAge time.Duration // How long operator has been running
// Kubernetes context
KubectlClient *kubectl.Client
}
TestInfo contains information about a test execution
type TestMetadata ¶
type TestMetadata struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration_ms"` // in milliseconds for JSON
Failed bool `json:"failed"`
FailureMessage string `json:"failure_message,omitempty"`
Labels []string `json:"labels"`
// Test sequence tracking (for degradation analysis)
TestSequenceNumber int `json:"test_sequence_number"` // Which test in the run (1, 2, 3...)
OperatorAge time.Duration `json:"operator_age_seconds"` // How long operator has been running
// Collected artifacts inventory
Artifacts ArtifactInventory `json:"artifacts"`
}
TestMetadata contains metadata about a single test execution
func BuildTestMetadata ¶
func BuildTestMetadata(info TestInfo, artifacts ArtifactInventory) TestMetadata
BuildTestMetadata creates TestMetadata from TestInfo