Documentation
¶
Overview ¶
Package ssi provides end to end tests for Single Step Instrumentation. It focuses on user configuration and how that impacts targeting in Kubernetes.
Index ¶
- Constants
- Variables
- func FindPodInNamespace(t *testing.T, client kubeClient.Interface, namespace string, appName string) *corev1.Pod
- func FindTracesForService(t *testing.T, intake *fakeintake.Client, serviceName string) []*trace.TracerPayload
- func GetPodsInNamespace(t *testing.T, client kubeClient.Interface, namespace string) []corev1.Pod
- func Provisioner(opts ProvisionerOptions) provisioners.TypedProvisioner[environments.Kubernetes]
- func RestartPod(t *testing.T, client kubeClient.Interface, namespace string, appName string)
- func WaitForAdmissionWebhookReady(t *testing.T, client kubeClient.Interface)
- func WaitForMutatedPodInNamespace(t *testing.T, client kubeClient.Interface, namespace string, appName string) *corev1.Pod
- type PreAgentHook
- type ProvisionerOptions
- type ProvisionerType
Constants ¶
const DefaultAppName = "test-app"
Variables ¶
var DefaultExpectedContainers = []string{DefaultAppName}
Functions ¶
func FindPodInNamespace ¶
func FindTracesForService ¶
func FindTracesForService(t *testing.T, intake *fakeintake.Client, serviceName string) []*trace.TracerPayload
func GetPodsInNamespace ¶
func Provisioner ¶ added in v0.77.0
func Provisioner(opts ProvisionerOptions) provisioners.TypedProvisioner[environments.Kubernetes]
Provisioner returns a Kubernetes provisioner based on E2E_PROVISIONER and E2E_DEV_LOCAL parameters. Supported provisioners: "kind" (default), "kind-local", "eks", "gke", "gke-autopilot", "aks", "openshift", "openshift-local". E2E_DEV_LOCAL=true is a shortcut for E2E_PROVISIONER=kind-local.
func RestartPod ¶
RestartPod deletes the pod backing appName so its Deployment recreates it, forcing a fresh pass through the admission webhook. It blocks until a new running pod (different from the deleted one) is observed.
func WaitForAdmissionWebhookReady ¶
func WaitForAdmissionWebhookReady(t *testing.T, client kubeClient.Interface)
WaitForAdmissionWebhookReady blocks until the Datadog mutating webhook configuration exists. The cluster agent creates it only after acquiring leadership and reconciling the admission controller, which on slow clusters (e.g. GKE Autopilot, where nodes are provisioned on demand) can lag well behind the Helm release being reported ready.
func WaitForMutatedPodInNamespace ¶
func WaitForMutatedPodInNamespace(t *testing.T, client kubeClient.Interface, namespace string, appName string) *corev1.Pod
WaitForMutatedPodInNamespace returns a pod matching appName in the namespace that has been processed by the APM admission webhook (i.e. carries at least one internal.apm.datadoghq.com/* annotation).
Pod mutation annotations are set at admission time (pod creation), so a pod that was admitted before the webhook was serving is never processed retroactively (failurePolicy is Ignore). This happens for the application pods created during provisioning on slow clusters (e.g. GKE Autopilot) where the cluster agent admission controller comes up well after the Helm release is ready.
To get a mutated pod we therefore wait (without restarting) for the webhook to exist, then recreate the pod so it goes through it. A short retry absorbs the brief gap between the webhook configuration being created and its endpoint actually serving. On clusters where the webhook was already serving, the first matching pod is returned without any restart.
Types ¶
type PreAgentHook ¶ added in v0.79.0
type PreAgentHook func(e config.Env, kubeProvider *kubernetes.Provider) error
PreAgentHook lets tests inject setup after the provider is ready and before agent installation.
type ProvisionerOptions ¶ added in v0.77.0
type ProvisionerOptions struct {
AgentOptions []kubernetesagentparams.Option
PreAgentHook PreAgentHook
WorkloadAppFunc kubeComp.WorkloadAppFunc
AgentDependentWorkloadAppFunc kubeComp.AgentDependentWorkloadAppFunc
}
ProvisionerOptions contains the common options for Kubernetes provisioners.
type ProvisionerType ¶ added in v0.78.0
type ProvisionerType string
ProvisionerType represents the type of Kubernetes provisioner to use.
const ( // ProvisionerKindAWS uses Kind running on an AWS VM (default). ProvisionerKindAWS ProvisionerType = "kind" // ProvisionerKindLocal uses Kind running locally. ProvisionerKindLocal ProvisionerType = "kind-local" // ProvisionerEKS uses Amazon EKS. ProvisionerEKS ProvisionerType = "eks" // ProvisionerAKS uses Azure Kubernetes Service. ProvisionerAKS ProvisionerType = "aks" // ProvisionerGKE uses Google Kubernetes Engine. ProvisionerGKE ProvisionerType = "gke" // ProvisionerGKEAutopilot uses Google Kubernetes Engine in Autopilot mode. ProvisionerGKEAutopilot ProvisionerType = "gke-autopilot" // ProvisionerOpenShift uses OpenShift VM on GCP. ProvisionerOpenShift ProvisionerType = "openshift" // ProvisionerOpenShiftLocal uses local OpenShift (CRC). ProvisionerOpenShiftLocal ProvisionerType = "openshift-local" )