testutils

package
v0.2.213 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 37 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)

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)

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 PrintNodeAgentLogs

func PrintNodeAgentLogs(t *testing.T)

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 (*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) WaitForApplicationProfile

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

func (*TestWorkload) WaitForApplicationProfileCompletion

func (w *TestWorkload) WaitForApplicationProfileCompletion(maxRetries uint64) 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) 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