Skip to content

Latest commit

 

History

History
147 lines (104 loc) · 4.64 KB

running-e2e-test.md

File metadata and controls

147 lines (104 loc) · 4.64 KB

Running End-To-End Tests

E2E tests are designed for verifying the functional correctness by replicating end-user behavior from app deployment. This describes how to run e2e tests in local dev environment and run them through CI

Run E2E tests in local dev environment

Prerequisites

  • Set up Dapr development environment
  • Install the latest Helm v3
  • Create your DockerHub ID
  • Set the environment variables
    export DAPR_REGISTRY=docker.io/your_dockerhub_id
    export DAPR_TAG=dev
    export DAPR_NAMESPACE=dapr-tests
    export DAPR_MTLS_ENABLED=true
    
    # If you want to run tests against Windows or arm kubernetes clusters, uncomment and set these
    # export TARGET_OS=linux
    # export TARGET_ARCH=amd64
    
    # If you are cross compiling (building on MacOS/Windows and running against a Linux Kubernetes cluster
    # or vice versa) uncomment and set these
    # export GOOS=linux
    # export GOARCH=amd64
    
    # Do not set DAPR_TEST_ENV if you do not use minikube
    export DAPR_TEST_ENV=minikube
    

If you are using minikube, you'll need to set the IP address for the minikube control plane.

export MINIKUBE_NODE_IP=your_k8s_master_ip

# Set the below environment variables if you want to use the different registry and tag for test apps
# export DAPR_TEST_REGISTRY=docker.io/your_dockerhub_id
# export DARP_TEST_TAG=dev
# export DAPR_TEST_REGISTRY_SECRET=yourself_private_image_secret
```

Option 1: Build, deploy, and run Dapr and e2e tests

If you are starting from scratch and just want to build dapr, deploy it, and run the e2e tests to your kubernetes cluster, do the following:

  1. Uninstall dapr, dapr-kafka, dapr-redis services, if it exists Make sure you have DAPR_NAMESPACE set properly before you do this!
helm uninstall dapr dapr-kafka dapr-redis -n $DAPR_NAMESPACE
  1. Remove the test namespace, if it exists
make delete-test-namespace
  1. Build, deploy, run tests from start to finish
make e2e-build-deploy-run

Option 2: Step by step guide

We also have individual targets to allow for quick iteration on parts of deployment and testing. To follow all or part of these steps individually, do the following:

Create dapr-tests namespace

make create-test-namespace

Install redis and kafka for state, pubsub, and binding building block

make setup-helm-init
make setup-test-env-redis

# This may take a few minutes.  You can skip kafka install if you do not use bindings for your tests.
make setup-test-env-kafka

Run the below commands to build and deploy dapr from your local disk

# Build Linux binaries
make build-linux

# Build Docker image with Linux binaries
make docker-build

# Push docker image to your dockerhub registry
make docker-push

# Deploy Dapr runtime to your cluster
make docker-deploy-k8s

Optional: Apply this configuration to disable mTLS

make setup-disable-mtls

Register the default component configurations for testing

make setup-test-components

Build and push test apps to docker hub

Build docker images from apps and push the images to test docker hub

# build e2e apps docker image under apps/
make build-e2e-app-all

# push e2e apps docker image to docker hub
make push-e2e-app-all

Run end-to-end test

Run end-to-end tests

# start e2e test
make test-e2e-all

Cleanup local environment

To completely remove Dapr, test dependencies, and any lingering e2e test apps: Make sure you have DAPR_NAMESPACE set properly before you do this!

# Uninstall dapr, dapr-kafka, dapr-redis services
helm uninstall dapr dapr-kafka dapr-redis -n $DAPR_NAMESPACE

# Remove the test namespace
make delete-test-namespace

Run E2E tests through GitHub Actions

To keep the build infrastructure simple, Dapr uses dapr-test GitHub Actions Workflow to run e2e tests using one of AKS clusters. A separate workflow also runs E2E in KinD clusters.

Once a contributor creates a pull request, E2E tests on KinD clusters are automatically executed for faster feedback. In order to run the E2E tests on AKS, ask a maintainer or approver to add /ok-to-test comment to the Pull Request.