e2eframework

package module
v0.76.0-devel Latest Latest
Warning

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

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

README

Dynamic infrastructures for test

This repository contains IaC code based on Pulumi to provision dynamic test infrastructures for testing.

Prerequisites

To run scripts and code in this repository, you will need:

  • Go 1.22 or later. You'll also need to set your $GOPATH and have $GOPATH/bin in your path.

  • Python 3.9+ along with development libraries for tooling.

  • account-admin role on AWS agent-sandbox account. Ensure it by running aws-vault login sso-agent-sandbox-account-admin

  • dda installed on your laptop

    aws-vault login sso-agent-sandbox-account-admin
    

This guide is tested on MacOS.

List of Linux dependencies
sudo apt install libnotify-bin

Quick start guide

  1. Clone this repository
cd ~/dd && git clone git@github.com:DataDog/datadog-agent.git
  1. Install Python dependencies
cd ~/dd/datadog-agent/test/e2e-framework && dda -v self dep sync -f legacy-e2e -f legacy-github
  1. Add a PULUMI_CONFIG_PASSPHRASE to your Terminal rc file. Create a random password using 1Password and store it there
export PULUMI_CONFIG_PASSPHRASE=<random password stored in 1Password>
  1. Run and follow the setup script
dda inv setup
Create an environment for manual tests

Invoke tasks help deploying most common environments - VMs, Docker, ECS, EKS. Run dda inv -l to learn more.

To get the list of available tasks

❯ dda inv -l

Run any -h on any of the available tasks for more information

MacOS support

The aws.create-vm task should allow you to spin up a MacOS instance using -o macos flag. Note that spinning such an instance is expensive because it requires a dedicated host. When you have one running please reuse it instead of creating new instances every time you need it. The cleaner will automatically get rid of the dedicated hosts.

Troubleshooting

Environment and configuration

The setup.debug invoke task will check for common mistakes such as key unavailable in configured AWS region, ssh-agent not running, invalid key format, and more.

aws-vault exec sso-agent-sandbox-account-admin -- dda inv setup.debug
aws-vault exec sso-agent-sandbox-account-admin -- dda inv setup --debug --no-interactive

Interact with Pulumi

Note: For most of the users interacting with Pulumi directly should not be required, you should be able to rely exclusively on the available tasks.

Pulumi: Stack & Storage

Pulumi requires to store/retrieve the state of your Stack. In Pulumi, Stack objects represent your actual deployment:

  • A Stack references a Project (a folder with a Pulumi.yaml, for instance root folder of this repo)
  • A Stack references a configuration file called Pulumi.<stack_name>.yaml This file holds your Stack configuration. If it does not exist, it will be created. If it exists and you input some settings through the command line, using -c, it will update the Stack file.

When performing operations on a Stack, Pulumi will need to store a state somewhere (the Stack state). Normally the state should be stored in a durable storage (e.g. S3-like), but for testing purposes local filesystem could be used.

To choose a default storage provider, use pulumi login (should be only done once):

# Using local filesystem (state will be stored in ~/.pulumi)
pulumi login --local

# Using storage on Cloud Storage (GCP)
# You need to create the bucket on sandbox.
# You also need to have sandbox as your current tenant in gcloud CLI.
pulumi login gs://<your_name>-pulumi

More information about state can be retrieved at: https://www.pulumi.com/docs/intro/concepts/state/

Finally, Pulumi is encrypting secrets in your Pulumi.<stack_name>.yaml (if entered as such). To do that, it requires a password. For dev purposes, you can simply store the password in the PULUMI_CONFIG_PASSPHRASE variable in your ~/.zshrc.

Creating a stack with pulumi up

In this example, we're going to create an ECS Cluster:

# You need to have a DD APIKey in variable DD_API_KEY
pulumi up -C test/e2e-framework/run -c scenario=aws/ecs -c ddinfra:aws/defaultKeyPairName=<your_exisiting_aws_keypair_name> -c ddinfra:env=aws/agent-sandbox -c ddagent:apiKey=$DD_API_KEY -s <your_name>-ecs-test

In case of failure, you may update some parameters or configuration and run the command again. Note that all -c parameters have been set in your Pulumi.<stack_name>.yaml file.

NOTE: Do not commit your Stack file.

Destroying a stack

Once you're finished with the test environment you've created, you can safely delete it. To do this, we'll use the destroy operation referencing our Stack file:

pulumi destroy -s <your_name>-ecs-test

Note that we don't need to use -c again as the configuration values were put into the Stack file. This will destroy all cloud resources associated to the Stack, but the state itself (mostly empty) will still be there. To remove the stack state:

pulumi stack rm <your_name>-ecs-test

Quick start: A VM with Docker(/Compose) with Agent deployed

# You need to have a DD APIKey in variable DD_API_KEY
pulumi up -C test/e2e-framework/run -c scenario=aws/dockervm -c ddinfra:aws/defaultKeyPairName=<your_exisiting_aws_keypair_name> -c ddinfra:env=aws/agent-sandbox -c ddagent:apiKey=$DD_API_KEY -c ddinfra:aws/defaultPrivateKeyPath=$HOME/.ssh/id_rsa -s <your_name>-docker

Quick start: Create an ECS EC2 (Windows/Linux) + Fargate (Linux) Cluster

# You need to have a DD APIKey in variable DD_API_KEY
pulumi up -C test/e2e-framework/run -c scenario=aws/ecs -c ddinfra:aws/defaultKeyPairName=<your_exisiting_aws_keypair_name> -c ddinfra:env=aws/agent-sandbox -c ddagent:apiKey=$DD_API_KEY -s <your_name>-ecs

Quick start: Create an EKS (Linux/Windows) + Fargate (Linux) Cluster + Agent (Helm)

# You need to have a DD APIKey AND APPKey in variable DD_API_KEY / DD_APP_KEY
pulumi up -C test/e2e-framework/run -c scenario=aws/eks -c ddinfra:aws/defaultKeyPairName=<your_exisiting_aws_keypair_name> -c ddinfra:env=aws/agent-sandbox -c ddagent:apiKey=$DD_API_KEY -c ddagent:appKey=$DD_APP_KEY -s <your_name>-eks

Quick start: Create a GKE Standard + Agent (Helm) or a GKE Autopilot + Agent (Helm)

Prerequisites:

  • Install the GKE authentication plugin: gcloud components install gke-gcloud-auth-plugin
  • Add the plugin to your PATH: export PATH="/opt/homebrew/share/google-cloud-sdk/bin:$PATH"
  • Authenticate with GCP: gcloud auth application-default login
# You need to have a DD APIKey AND APPKey in variable DD_API_KEY / DD_APP_KEY
# GKE Standard
pulumi up -C test/e2e-framework/run -c scenario=gcp/gke -c ddinfra:env=gcp/agent-sandbox -c ddinfra:gcp/defaultPublicKeyPath=$HOME/.ssh/id_ed25519.pub -c ddagent:apiKey=$DD_API_KEY -c ddagent:appKey=$DD_APP_KEY -s <your_name>-gke

# GKE Autopilot
pulumi up -C test/e2e-framework/run -c scenario=gcp/gke -c ddinfra:env=gcp/agent-sandbox -c ddinfra:gcp/defaultPublicKeyPath=$HOME/.ssh/id_ed25519.pub -c ddinfra:gcp/gke/enableAutopilot=true -c ddagent:apiKey=$DD_API_KEY -c ddagent:appKey=$DD_APP_KEY -s <your_name>-gke-autopilot

Quick start: Create an OpenShift Cluster + Agent (Helm) on an OpenShift Cluster

# You need to have a DD APIKey AND APPKey in variable DD_API_KEY / DD_APP_KEY
pulumi up -C test/e2e-framework/run -c scenario=gcp/openshiftvm -c ddinfra:env=gcp/agent-sandbox -c ddinfra:gcp/openshift/pullSecretPath=<your_pull_secret_path -c ddinfra:gcp/enableNestedVirtualization=true -c ddinfra:gcp/defaultInstanceType=n2-standard-8 -c ddinfra:gcp/defaultPublicKeyPath=$HOME/.ssh/id_ed25519.pub -c ddagent:apiKey=$DD_API_KEY  -c ddagent:appKey=$DD_APP_KEY -s <your_name>-openshift

Documentation

Overview

Package e2eframework is the entry point for the e2e-framework.

Directories

Path Synopsis
datadog/apps/singlestep
Package singlestep provides a scenario to use for Single Step Instrumentation based tests.
Package singlestep provides a scenario to use for Single Step Instrumentation based tests.
ecs
iis
Package iis contains code for the IIS component
Package iis contains code for the IIS component
os
resources
aws
gcp
Package main is the entry point for the e2e-framework.
Package main is the entry point for the e2e-framework.
scenarios
aws/ec2docker
Package ec2docker contains the definition of the AWS Docker environment.
Package ec2docker contains the definition of the AWS Docker environment.
testing
components
Package components contains the definitions of the different components that can be used in a test.
Package components contains the definitions of the different components that can be used in a test.
e2e
Package e2e provides the API to manage environments and organize E2E tests.
Package e2e provides the API to manage environments and organize E2E tests.
environments
Package environments contains the definitions of the different environments that can be used in a test.
Package environments contains the definitions of the different environments that can be used in a test.
provisioners
Package provisioners contains the definitions of the different provisioners that can be used in a test to setup an environment.
Package provisioners contains the definitions of the different provisioners that can be used in a test to setup an environment.
provisioners/aws/docker
Package awsdocker contains the definition of the AWS Docker environment.
Package awsdocker contains the definition of the AWS Docker environment.
provisioners/aws/ecs
Package ecs contains the definition of the AWS ECS environment.
Package ecs contains the definition of the AWS ECS environment.
provisioners/aws/host
Package awshost contains the definition of the AWS Host environment.
Package awshost contains the definition of the AWS Host environment.
provisioners/aws/host/windows
Package winawshost contains the definition of the AWS Windows Host environment.
Package winawshost contains the definition of the AWS Windows Host environment.
provisioners/aws/kubernetes/eks
Package awskubernetes contains the provisioner for the Kubernetes based environments
Package awskubernetes contains the provisioner for the Kubernetes based environments
provisioners/aws/kubernetes/kindvm
Package kindvm contains the provisioner for the Kind-on-VM Kubernetes based environments
Package kindvm contains the provisioner for the Kind-on-VM Kubernetes based environments
provisioners/azure/host/linux
Package azurehost contains the definition of the Azure Host environment.
Package azurehost contains the definition of the Azure Host environment.
provisioners/azure/host/windows
Package winazurehost contains the definition of the Azure Windows Host environment.
Package winazurehost contains the definition of the Azure Windows Host environment.
provisioners/azure/kubernetes
Package azurekubernetes contains the provisioner for Azure Kubernetes Service (AKS)
Package azurekubernetes contains the provisioner for Azure Kubernetes Service (AKS)
provisioners/gcp/host/linux
Package gcphost contains the definition of the GCP Host environment.
Package gcphost contains the definition of the GCP Host environment.
provisioners/gcp/kubernetes
Package gcpkubernetes contains the provisioner for Google Kubernetes Engine (GKE)
Package gcpkubernetes contains the provisioner for Google Kubernetes Engine (GKE)
provisioners/local/host
Package localhost contains the provisioner for the local Host based environments
Package localhost contains the provisioner for the local Host based environments
provisioners/local/kubernetes
Package localkubernetes contains the provisioner for the local Kubernetes based environments
Package localkubernetes contains the provisioner for the local Kubernetes based environments
runner
Package runner implements local and ci profile runners
Package runner implements local and ci profile runners
runner/parameters
Package parameters implements parameters for profiles
Package parameters implements parameters for profiles
testcommon/check
Package check contains the code to parse the check command output
Package check contains the code to parse the check command output
utils/clients
Package clients implements utility clients
Package clients implements utility clients
utils/common
Package common implements utilities shared across the e2e tests
Package common implements utilities shared across the e2e tests
utils/e2e/client
Package client contains the definitions of the different clients that can be used in a test.
Package client contains the definitions of the different clients that can be used in a test.
utils/e2e/client/agentclient
Package agentclient provides an interface to run Agent commands.
Package agentclient provides an interface to run Agent commands.
utils/e2e/client/agentclientparams
Package agentclientparams implements function parameters for [e2e.Agent]
Package agentclientparams implements function parameters for [e2e.Agent]
utils/infra
Package infra implements utilities to interact with a Pulumi infrastructure
Package infra implements utilities to interact with a Pulumi infrastructure
utils/k8s
Package k8s contains utility functions for interacting with Kubernetes clusters.
Package k8s contains utility functions for interacting with Kubernetes clusters.
utils/optional
Package optional provides generic function to handle optional parameters.
Package optional provides generic function to handle optional parameters.

Jump to

Keyboard shortcuts

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