testutils

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContains

func AssertContains(t *testing.T, alerts []Alert, expectedRuleName string, expectedCommand string, expectedContainerName string, expectedFailOnProfile []bool)

func AssertNetworkNeighborhoodContains

func AssertNetworkNeighborhoodContains(t *testing.T, nn *v1beta1.NetworkNeighborhood, containerName string, expectedEgress, expectedIngress []string)

func AssertNetworkNeighborhoodNotContains

func AssertNetworkNeighborhoodNotContains(t *testing.T, nn *v1beta1.NetworkNeighborhood, containerName string, notExpectedEgress, notExpectedIngress []string)

func AssertNotContains

func AssertNotContains(t *testing.T, alerts []Alert, notExpectedRuleName string, notExpectedCommand string, notExpectedContainerName string, notExpectedFailOnProfile []bool)

func AssertUIDFieldsPopulated added in v0.3.6

func AssertUIDFieldsPopulated(t *testing.T, alerts []Alert, namespace string)

AssertUIDFieldsPopulated verifies that pod_uid and workload_uid fields are populated in alerts

func ExecIntoPod

func ExecIntoPod(podName, podNamespace string, command []string, container string) (string, string, error)

func GetNodeAgentAverageCPUUsage

func GetNodeAgentAverageCPUUsage(start, end time.Time) (map[string]float64, error)

func IncreaseNodeAgentSniffingTime

func IncreaseNodeAgentSniffingTime(newDuration string)

func PlotNodeAgentPrometheusCPUUsage

func PlotNodeAgentPrometheusCPUUsage(testcase string, startTime, endTime time.Time) error

func PrintAppLogs added in v0.3.3

func PrintAppLogs(t *testing.T, app string)

func RestartDaemonSet added in v0.2.317

func RestartDaemonSet(namespace, name string) error

func RestartDeployment added in v0.2.335

func RestartDeployment(namespace, name string) error

func RunCommand

func RunCommand(name string, args ...string) int

Types

type Alert

type Alert struct {
	Labels map[string]string `json:"labels"`
}

Alert structure based on the expected JSON format from Alertmanager

func GetAlerts

func GetAlerts(namespace string) ([]Alert, error)

GetAlerts retrieves and filters alerts from Alertmanager

func GetMalwareAlerts

func GetMalwareAlerts(namespace string) ([]Alert, error)

type TestNamespace

type TestNamespace struct {
	Name string
	// contains filtered or unexported fields
}

func NewNamespace

func NewNamespace(name string) TestNamespace

func NewRandomNamespace

func NewRandomNamespace() TestNamespace

type TestWorkload

type TestWorkload struct {
	Namespace       string
	UnstructuredObj *unstructured.Unstructured
	WorkloadObj     *workloadinterface.Workload
	// contains filtered or unexported fields
}

func CreateWorkloadsInPath

func CreateWorkloadsInPath(namespace, dir string) ([]TestWorkload, error)

func NewTestWorkload

func NewTestWorkload(namespace, resourcePath string) (*TestWorkload, error)

func NewTestWorkloadFromK8sIdentifiers added in v0.2.335

func NewTestWorkloadFromK8sIdentifiers(namespace, kind, name string) (*TestWorkload, error)

func (*TestWorkload) Delete added in v0.2.340

func (w *TestWorkload) Delete() error

func (*TestWorkload) ExecIntoPod

func (w *TestWorkload) ExecIntoPod(command []string, container string) (string, string, error)

func (*TestWorkload) GetApplicationProfile

func (w *TestWorkload) GetApplicationProfile() (*v1beta1.ApplicationProfile, error)

func (*TestWorkload) GetNetworkNeighborhood

func (w *TestWorkload) GetNetworkNeighborhood() (*v1beta1.NetworkNeighborhood, error)

func (*TestWorkload) GetPods

func (w *TestWorkload) GetPods() ([]v1.Pod, error)

func (*TestWorkload) GetWorkloadEvents added in v0.2.340

func (w *TestWorkload) GetWorkloadEvents() ([]eventsv1.Event, error)

func (*TestWorkload) WaitForApplicationProfile

func (w *TestWorkload) WaitForApplicationProfile(maxRetries uint64, expectedStatus string) error

func (*TestWorkload) WaitForApplicationProfileCompletion

func (w *TestWorkload) WaitForApplicationProfileCompletion(maxRetries uint64) error

func (*TestWorkload) WaitForApplicationProfileCompletionWithBlacklist added in v0.2.335

func (w *TestWorkload) WaitForApplicationProfileCompletionWithBlacklist(maxRetries uint64, blacklist []string) error

func (*TestWorkload) WaitForNetworkNeighborhood

func (w *TestWorkload) WaitForNetworkNeighborhood(maxRetries uint64, expectedStatus string) error

func (*TestWorkload) WaitForNetworkNeighborhoodCompletion

func (w *TestWorkload) WaitForNetworkNeighborhoodCompletion(maxRetries uint64) error

func (*TestWorkload) WaitForNetworkNeighborhoodCompletionWithBlacklist added in v0.2.335

func (w *TestWorkload) WaitForNetworkNeighborhoodCompletionWithBlacklist(maxRetries uint64, blacklist []string) error

func (*TestWorkload) WaitForReady

func (w *TestWorkload) WaitForReady(maxRetries uint64) error

type WorkloadMetrics

type WorkloadMetrics struct {
	Name       string
	Timestamps []float64
	Values     []float64
}

func PlotNodeAgentPrometheusMemoryUsage

func PlotNodeAgentPrometheusMemoryUsage(testcase string, startTime, endTime time.Time) ([]WorkloadMetrics, error)

Jump to

Keyboard shortcuts

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