Documentation
¶
Index ¶
- Constants
- Variables
- func CheckLimitedSupportCount(ctx context.Context, internalClusterID string, expectedTotal int, ...)
- func CheckMfnriCount(ctx context.Context, mcClusterID string, expectedFiringCount int, ...)
- func CheckServiceLogCount(ctx context.Context, clusterUUID string, preCount, expectedNew int, ...)
- func CreateDefaultNotification(ctx context.Context, k8sClient crClient.Client, ...) error
- func CreateNetworkPolicy(ctx context.Context, client *resources.Resources, ...) error
- func GetLimitedSupportCount(ctx context.Context, internalClusterID string, ocmConnection *sdk.Connection) (int, error)
- func GetMfnriCount(ctx context.Context, mcClusterID string, k8sClient crClient.Client) (int, int, error)
- func GetServiceLogCount(ctx context.Context, clusterUUID string, ocmConnection *sdk.Connection) (int, error)
- func NewFleetNotification() ocmagentv1alpha1.FleetNotification
- func NewManagedFleetNotification(limited_support bool) ocmagentv1alpha1.ManagedFleetNotification
- func NewManagedFleetNotificationRecord() ocmagentv1alpha1.ManagedFleetNotificationRecord
- func NewManagedFleetNotificationRecordWithStatus() ocmagentv1alpha1.ManagedFleetNotificationRecord
- func NewTestAlert(resolved bool, fleet bool) template.Alert
- func NewTestServiceLog(summary, desc, clusterUUID string, ...) *slv1.LogEntry
- func PostAlert(ctx context.Context, alert AlertPayload, httpClient *http.Client, ...) error
- type Alert
- type AlertPayload
- type AlertResponse
Constants ¶
const (
// Used to map between alert and notification
TestNotificationName = "test-notification"
)
Variables ¶
var ( Context = context.TODO() Scheme = setScheme(runtime.NewScheme()) TestManagedClusterID = "test-managed-cluster-id" TestHostedClusterID = "test-hosted-cluster-id" TestNotification = ocmagentv1alpha1.Notification{ Name: TestNotificationName, Summary: "test-summary [namespace: '${namespace}']", ActiveDesc: "test-active-desc [description: '${description}', overriden-key: '${overriden-key}', recursive-key: '${recursive-key}']", ResolvedDesc: "test-resolved-desc [description: '${description}', overriden-key: '${overriden-key}']", Severity: "test-severity", ResendWait: 1, LogType: "test-type", References: []ocmagentv1alpha1.NotificationReferenceType{ "http://some.awesome.com/reference", "https://another.great.com/resource", }, } ServiceLogSummary = "test-summary [namespace: 'openshift-monitoring']" ServiceLogActiveDesc = "test-active-desc [description: 'alert-desc', overriden-key: 'label-value', recursive-key: '_${recursive-key}_']" ServiceLogResolvedDesc = "test-resolved-desc [description: 'alert-desc', overriden-key: 'label-value']" ServiceLogFleetDesc = "test-notification [description: 'alert-desc', overriden-key: 'label-value']" NotificationWithoutResolvedBody = ocmagentv1alpha1.Notification{ Name: TestNotificationName, Summary: "test-summary", ActiveDesc: "test-active-desc", Severity: "test-severity", ResendWait: 1, } TestNotificationRecord = ocmagentv1alpha1.NotificationRecord{ Name: TestNotificationName, ServiceLogSentCount: 0, Conditions: []ocmagentv1alpha1.NotificationCondition{ { Type: ocmagentv1alpha1.ConditionAlertFiring, Status: corev1.ConditionTrue, }, { Type: ocmagentv1alpha1.ConditionAlertResolved, Status: corev1.ConditionFalse, }, { Type: ocmagentv1alpha1.ConditionServiceLogSent, Status: corev1.ConditionTrue, }, }, } TestManagedNotification = ocmagentv1alpha1.ManagedNotification{ ObjectMeta: metav1.ObjectMeta{ Name: "test-mn", Namespace: "openshift-ocm-agent-operator", }, Spec: ocmagentv1alpha1.ManagedNotificationSpec{ Notifications: []ocmagentv1alpha1.Notification{TestNotification}, }, Status: ocmagentv1alpha1.ManagedNotificationStatus{ NotificationRecords: ocmagentv1alpha1.NotificationRecords{ TestNotificationRecord, }, }, } TestManagedNotificationWithoutStatus = ocmagentv1alpha1.ManagedNotification{ ObjectMeta: metav1.ObjectMeta{ Name: "test-mn", Namespace: "openshift-ocm-agent-operator", }, Spec: ocmagentv1alpha1.ManagedNotificationSpec{ Notifications: []ocmagentv1alpha1.Notification{TestNotification}, }, } TestManagedNotificationList = &ocmagentv1alpha1.ManagedNotificationList{ Items: []ocmagentv1alpha1.ManagedNotification{ TestManagedNotification, }, } )
Functions ¶
func CheckLimitedSupportCount ¶
func CheckLimitedSupportCount(ctx context.Context, internalClusterID string, expectedTotal int, ocmConnection *sdk.Connection)
CheckLimitedSupportCount verifies the limited support count matches expectations
func CheckMfnriCount ¶
func CheckMfnriCount(ctx context.Context, mcClusterID string, expectedFiringCount int, expectedResolvedCount int, k8sClient crClient.Client)
CheckMfnriCount compares firing notification sent count with expected count for a cluster
func CheckServiceLogCount ¶
func CheckServiceLogCount(ctx context.Context, clusterUUID string, preCount, expectedNew int, ocmConnection *sdk.Connection)
CheckServiceLogCount verifies the service log count matches expectations
func CreateDefaultNotification ¶
func CreateDefaultNotification(ctx context.Context, k8sClient crClient.Client, namespace, ocmAgentManagedNotification, testNotificationName string) error
CreateDefaultNotification creates a managed notification CRD for testing
func CreateNetworkPolicy ¶
func CreateNetworkPolicy(ctx context.Context, client *resources.Resources, networkPolicyName, namespace string) error
CreateNetworkPolicy creates a network policy which allow all traffic to ocm-agent for testing.
func GetLimitedSupportCount ¶
func GetLimitedSupportCount(ctx context.Context, internalClusterID string, ocmConnection *sdk.Connection) (int, error)
GetLimitedSupportCount gets the count of limited support records for a cluster
func GetMfnriCount ¶
func GetMfnriCount(ctx context.Context, mcClusterID string, k8sClient crClient.Client) (int, int, error)
GetMfnriCount gets the count of firing notification sent for a cluster
func GetServiceLogCount ¶
func GetServiceLogCount(ctx context.Context, clusterUUID string, ocmConnection *sdk.Connection) (int, error)
GetServiceLogCount gets the count of service logs for a cluster
func NewFleetNotification ¶
func NewFleetNotification() ocmagentv1alpha1.FleetNotification
func NewManagedFleetNotification ¶
func NewManagedFleetNotification(limited_support bool) ocmagentv1alpha1.ManagedFleetNotification
func NewManagedFleetNotificationRecord ¶
func NewManagedFleetNotificationRecord() ocmagentv1alpha1.ManagedFleetNotificationRecord
func NewManagedFleetNotificationRecordWithStatus ¶
func NewManagedFleetNotificationRecordWithStatus() ocmagentv1alpha1.ManagedFleetNotificationRecord
func NewTestServiceLog ¶
func NewTestServiceLog(summary, desc, clusterUUID string, severity ocmagentv1alpha1.NotificationSeverity, logType string, references []ocmagentv1alpha1.NotificationReferenceType) *slv1.LogEntry
Types ¶
type Alert ¶
type Alert struct {
Status string `json:"status"`
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
StartsAt string `json:"startsAt"`
EndsAt string `json:"endsAt"`
GeneratorURL string `json:"generatorURL"`
ManagedFleetNotificationTemplate string `json:"managedFleetNotificationTemplate"`
MCClusterID string `json:"_mc_id"`
ClusterID string `json:"_id"`
Source string `json:"source"`
}
E2E Test Structs Alert represents the structure of an alert sent to OCM Agent
type AlertPayload ¶
type AlertPayload struct {
Receiver string `json:"receiver"`
Status string `json:"status"`
Alerts []Alert `json:"alerts"`
GroupLabels map[string]string `json:"groupLabels"`
CommonLabels map[string]string `json:"commonLabels"`
CommonAnnotations map[string]string `json:"commonAnnotations"`
ExternalURL string `json:"externalURL"`
}
AlertPayload represents the structure of an alert sent to OCM Agent
func CreateBiAlert ¶
func CreateBiAlert(alertStatus, alertName, managedNotificationTemplate string) AlertPayload
CreateBiAlert creates an alert payload with two alerts
func CreateFleetAlert ¶
func CreateFleetAlert(alertStatus, alertName, managementClusterID, managedFleetNotificationTemplate, externalClusterID string) AlertPayload
CreateFleetAlert creates an alert payload for fleet mode
func CreateSingleAlert ¶
func CreateSingleAlert(alertStatus, alertName, managedNotificationTemplate string) AlertPayload
CreateSingleAlert creates an alert payload similar to the shell script create-alert.sh
type AlertResponse ¶
type AlertResponse struct {
Status string `json:"status"`
}
AlertResponse represents the response from the OCM Agent