Documentation
¶
Index ¶
- Constants
- func ApplyYAML(path string) error
- func CreateCronJob(name, namespace, schedule string, successfulImage bool) error
- func CreateNamespace(name string) error
- func CreateTestSecret(name, namespace string, data map[string]string) error
- func DeleteNamespace(name string) error
- func DeleteResource(kind, name, namespace string) error
- func DeleteYAML(path string) error
- func GetCronJobMonitor(name, namespace string) (*guardianv1alpha1.CronJobMonitor, error)
- func GetMonitorCronJobCount(name, namespace string) (int, error)
- func ResourceExists(kind, name, namespace string) bool
- func TriggerCronJob(cronJobName, namespace string) (string, error)
- func WaitForChannelReady(name string, timeout time.Duration)
- func WaitForJobCompletion(jobName, namespace string, timeout time.Duration) error
- func WaitForMonitorPhase(name, namespace string, phase string, timeout time.Duration)
- type AlertPayload
- type MockWebhookReceiver
- func (r *MockWebhookReceiver) ClearAlerts()
- func (r *MockWebhookReceiver) GetAlertCount() int
- func (r *MockWebhookReceiver) GetAlerts() []AlertPayload
- func (r *MockWebhookReceiver) GetURL() string
- func (r *MockWebhookReceiver) Start() error
- func (r *MockWebhookReceiver) Stop() error
- func (r *MockWebhookReceiver) WaitForAlert(timeout time.Duration) bool
- func (r *MockWebhookReceiver) WaitForAlertCount(count int, timeout time.Duration) bool
Constants ¶
const ( // DefaultTimeout is the default timeout for waiting operations DefaultTimeout = 2 * time.Minute // DefaultInterval is the default polling interval DefaultInterval = time.Second // TestNamespace is the namespace for E2E tests TestNamespace = "cronjob-guardian-e2e" )
Variables ¶
This section is empty.
Functions ¶
func CreateCronJob ¶
CreateCronJob creates a CronJob in the specified namespace
func CreateNamespace ¶
CreateNamespace creates a test namespace
func CreateTestSecret ¶
CreateTestSecret creates a secret for testing
func DeleteResource ¶
DeleteResource deletes a Kubernetes resource
func DeleteYAML ¶
DeleteYAML deletes resources defined in a YAML file
func GetCronJobMonitor ¶
func GetCronJobMonitor(name, namespace string) (*guardianv1alpha1.CronJobMonitor, error)
GetCronJobMonitor retrieves a CronJobMonitor by name
func GetMonitorCronJobCount ¶
GetMonitorCronJobCount returns the number of CronJobs tracked by a monitor
func ResourceExists ¶
ResourceExists checks if a resource exists
func TriggerCronJob ¶
TriggerCronJob manually triggers a CronJob by creating a Job
func WaitForChannelReady ¶
WaitForChannelReady waits for an AlertChannel to become ready
func WaitForJobCompletion ¶
WaitForJobCompletion waits for a job to complete (success or failure)
Types ¶
type AlertPayload ¶
type AlertPayload struct {
Type string `json:"type"`
Severity string `json:"severity"`
Title string `json:"title"`
Message string `json:"message"`
CronJob string `json:"cronjob"`
Namespace string `json:"namespace"`
ReceivedAt time.Time `json:"received_at"`
RawBody []byte `json:"-"`
}
AlertPayload represents an alert received by the mock receiver
type MockWebhookReceiver ¶
type MockWebhookReceiver struct {
// contains filtered or unexported fields
}
MockWebhookReceiver is a test HTTP server that receives webhook alerts
func NewMockWebhookReceiver ¶
func NewMockWebhookReceiver(port int) *MockWebhookReceiver
NewMockWebhookReceiver creates a new mock webhook receiver
func (*MockWebhookReceiver) ClearAlerts ¶
func (r *MockWebhookReceiver) ClearAlerts()
ClearAlerts clears all received alerts
func (*MockWebhookReceiver) GetAlertCount ¶
func (r *MockWebhookReceiver) GetAlertCount() int
GetAlertCount returns the number of received alerts
func (*MockWebhookReceiver) GetAlerts ¶
func (r *MockWebhookReceiver) GetAlerts() []AlertPayload
GetAlerts returns all received alerts
func (*MockWebhookReceiver) GetURL ¶
func (r *MockWebhookReceiver) GetURL() string
GetURL returns the webhook URL
func (*MockWebhookReceiver) Start ¶
func (r *MockWebhookReceiver) Start() error
Start starts the mock webhook receiver
func (*MockWebhookReceiver) Stop ¶
func (r *MockWebhookReceiver) Stop() error
Stop stops the mock webhook receiver
func (*MockWebhookReceiver) WaitForAlert ¶
func (r *MockWebhookReceiver) WaitForAlert(timeout time.Duration) bool
WaitForAlert waits for at least one alert to be received
func (*MockWebhookReceiver) WaitForAlertCount ¶
func (r *MockWebhookReceiver) WaitForAlertCount(count int, timeout time.Duration) bool
WaitForAlertCount waits for a specific number of alerts