framework

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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 ApplyYAML

func ApplyYAML(path string) error

ApplyYAML applies a YAML file using kubectl

func CreateCronJob

func CreateCronJob(name, namespace, schedule string, successfulImage bool) error

CreateCronJob creates a CronJob in the specified namespace

func CreateNamespace

func CreateNamespace(name string) error

CreateNamespace creates a test namespace

func CreateTestSecret

func CreateTestSecret(name, namespace string, data map[string]string) error

CreateTestSecret creates a secret for testing

func DeleteNamespace

func DeleteNamespace(name string) error

DeleteNamespace deletes a namespace

func DeleteResource

func DeleteResource(kind, name, namespace string) error

DeleteResource deletes a Kubernetes resource

func DeleteYAML

func DeleteYAML(path string) error

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

func GetMonitorCronJobCount(name, namespace string) (int, error)

GetMonitorCronJobCount returns the number of CronJobs tracked by a monitor

func ResourceExists

func ResourceExists(kind, name, namespace string) bool

ResourceExists checks if a resource exists

func TriggerCronJob

func TriggerCronJob(cronJobName, namespace string) (string, error)

TriggerCronJob manually triggers a CronJob by creating a Job

func WaitForChannelReady

func WaitForChannelReady(name string, timeout time.Duration)

WaitForChannelReady waits for an AlertChannel to become ready

func WaitForJobCompletion

func WaitForJobCompletion(jobName, namespace string, timeout time.Duration) error

WaitForJobCompletion waits for a job to complete (success or failure)

func WaitForMonitorPhase

func WaitForMonitorPhase(name, namespace string, phase string, timeout time.Duration)

WaitForMonitorPhase waits for a CronJobMonitor to reach a specific phase

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL