Documentation ¶
Overview ¶
This package contains various helper functions for writing Tetragon e2e tests, including many setup and feature functions.
Index ¶
- Variables
- func CreateExportDir(ctx context.Context, t *testing.T) (context.Context, error)
- func CreateNamespace(namespace string, waitForCreation bool) env.Func
- func DeleteNamespace(namespace string, waitForDeletion bool) env.Func
- func DumpBin(port int, podName string, exportDir string)
- func ExecInPod(ctx context.Context, client klient.Client, namespace, pod, container string, ...) error
- func ExecInPodCombinedOutput(ctx context.Context, client klient.Client, namespace, pod, container string, ...) ([]byte, error)
- func ExecInPodOutput(ctx context.Context, client klient.Client, namespace, pod, container string, ...) ([]byte, error)
- func GetClusterName() string
- func GetExportDir(ctx context.Context) (string, error)
- func GetMinKernelVersion(t *testing.T, testenv env.Environment) string
- func GetTempKindClusterName(ctx context.Context) string
- func LoadCRDFile(namespace string, file string, waitForPods bool) env.Func
- func LoadCRDString(namespace string, yamlStr string, waitForPods bool) env.Func
- func LoadObjects(namespace string, objs []k8s.Object, waitForPods bool) env.Func
- func MaybeCreateTempKindCluster(testenv env.Environment, namePrefix string) env.Func
- func NewObjectList(objs []k8s.Object) k8s.ObjectList
- func PortForwardPod(testenv env.Environment, pod *corev1.Pod, out, outErr *os.File, retries uint, ...) env.Func
- func PortForwardTetragonPods(testenv env.Environment) env.Func
- func RunCommand(ctx context.Context, client klient.Client, ...) ([]byte, error)
- func SetMinKernelVersion() env.Func
- func StartGopsDumper(ctx context.Context, exportDir string, interval time.Duration)
- func StartMetricsDumper(ctx context.Context, exportDir string, interval time.Duration)
- func UnloadCRDFile(namespace string, file string, waitForDeletion bool) env.Func
- func UnloadCRDString(namespace string, yamlStr string, waitForDeletion bool) env.Func
- func UnloadObjects(namespace string, objs []k8s.Object, waitForDeletion bool) env.Func
- type TestEnvFunc
Constants ¶
This section is empty.
Variables ¶
var ( TetragonContainerName = "tetragon" TetragonJsonPathname = "/var/run/cilium/tetragon/tetragon.log" )
Functions ¶
func CreateExportDir ¶
func CreateNamespace ¶
CreateNamespace is a wrapper around envfuncs.CreateNamespace with optional support to wait for namespace creation.
func DeleteNamespace ¶
DeleteNamespace is a wrapper around envfuncs.DeleteNamespace with optional support to wait for namespace deletion.
func DumpBin ¶
DumpBin dumps the Tetragon binary from gops. We keep this separate from dumpGops because it is a more expensive operation and dumps something that is not expected to change. Therefore we only want to call this once per test.
func ExecInPodCombinedOutput ¶
func ExecInPodOutput ¶
func GetClusterName ¶
func GetClusterName() string
GetClusterName fetches the cluster name configured with -cluster-name.
func GetMinKernelVersion ¶
func GetMinKernelVersion(t *testing.T, testenv env.Environment) string
func GetTempKindClusterName ¶
GetTempKindClusterName returns the name of the temporary kind cluster if it exists, otherwise it returns an empty string.
func LoadCRDFile ¶
LoadCRDFile decodes a CRD file and calls LoadObjects on the result.
func LoadCRDString ¶
LoadCRDString decodes a CRD from a yaml string and calls LoadObjects on the result.
func LoadObjects ¶
LoadObjects loads a list of k8s.Object and optionally waits for all resources to be created and pods to be ready.
func MaybeCreateTempKindCluster ¶
func MaybeCreateTempKindCluster(testenv env.Environment, namePrefix string) env.Func
MaybeCreateTempKindCluster creates a new temporary kind cluster in case no kubeconfig file is specified on the command line.
func NewObjectList ¶
func NewObjectList(objs []k8s.Object) k8s.ObjectList
NewObjectList creates a new k8s.ObjectList from a list of k8s.Object
func PortForwardPod ¶
func PortForwardPod(testenv env.Environment, pod *corev1.Pod, out, outErr *os.File, retries uint, retryBackoff time.Duration, ports ...string) env.Func
PortForwardPod forwards one or more ports to a given pod. Port forwards are automatically cleaned up when the test exits. Ports should be specified in the form "src:dst" where "src" and "dst" are port numbers.
out and outErr are pointers to os.File that should be used by the portforwarder for its stdout and stderr respectively. These can be set to nil to ignore output.
retries and retryBackoff can be used to configure how many times this function should retry on failure to set up the port forward and how long it should wait between retries.
func PortForwardTetragonPods ¶
func PortForwardTetragonPods(testenv env.Environment) env.Func
PortForwardTetragonPods forwards gRPC and metrics ports for Tetragon pods.
func RunCommand ¶
func RunCommand(ctx context.Context, client klient.Client, podNamespace, podName, containerName string, cmd string, args ...string) ([]byte, error)
RunCommand runs a command in a pod and returns the combined stdout and stderr delimited by markers as a byte slice. For lower level control use the ExecInPod* helpers instead.
func SetMinKernelVersion ¶
func StartGopsDumper ¶
StartGopsDumper starts a goroutine that dumps gops information at a regular interval until the context is done. We want to do this in case the pod crashes or gets restarted during a failing test. This way we can at least have a snapshot of the gops dumps to look back on.
func StartMetricsDumper ¶
StartMetricsDumper starts a goroutine that dumps metrics at a regular interval until the context is done. We want to do this in case the pod crashes or gets restarted during a failing test. This way we can at least have a snapshot of the metrics to look back on.
func UnloadCRDFile ¶
UnloadCRDFile decodes a CRD file and calls UnloadObjects on the result.
func UnloadCRDString ¶
UnloadCRDString decodes a CRD yaml string and calls UnloadObjects on the result.