Project: Dapr (App Definition and Development / Application Definition & Image Build)
File: running-perf-tests.md

Performance tests are designed to let you evaluate the latency, resource usage and processing times for Dapr in your environment for a given hardware. The following describes how to run performance tests in a local dev environment and run them through CI: - Kubernetes cluster (Minikube and Kind are valid options too). To setup a new Kind cluster and local registry, run `make setup-kind`. Set up . Create your DockerHub ID Create dapr-tests namespace ```bash kubectl create namespace dapr-tests ``` Set the environment variables If using Kind, run `make describe-kind-env` and copy-and-paste the export commands displayed. ```bash export DAPRREGISTRY=docker.io/yourdockerhub_id export DAPR_TAG=dev export DAPR_NAMESPACE=dapr-tests export DAPRTESTENV=minikube export DAPRPERFQPS export DAPRPERFCONNECTIONS export DAPRTESTDURATION export DAPRPAYLOADSIZE export DAPRSIDECARCPU_LIMIT export DAPRSIDECARMEMORY_LIMIT export DAPRSIDECARCPU_REQUEST export DAPRSIDECARMEMORY_REQUEST ``` Run the below commands to build and deploy dapr from your local disk ```bash make build-linux make docker-build make docker-push make docker-deploy-k8s make setup-3rd-party ``` ```bash make setup-app-configurations ``` ```bash export DAPRDISABLETELEMETRY=true ``` ```bash make setup-disable-mtls ``` ```bash make setup-test-components ``` Build docker images from apps and push the images to test docker hub. ```bash make build-perf-app-all make push-perf-app-all ``` You can also build and push the test apps individually. ```bash make build-perf-app-<app-name> make push-perf-app-<app-name> ``` `<app-name>` can be found at If you are building test apps individually, you need to build and push the tester app also: tester (`build-perf-app-tester` and `push-perf-app-tester`) for Fortio based tests k6-custom (`build-perf-app-k6-custom` and `push-perf-app-k6-custom`) for k6 based tests If you are running k6 based tests, install the k6-operator. ```bash make setup-test-env-k6 ``` ```bash make test-perf-all ``` You can also run selected tests using environment variables `DAPR_PERF TEST``. ```bash export DAPRPERFTEST="<app-name-1> <app-name-2>" make test-perf-all ``` Then it will run the tests defined in `DAPRPERFTEST`. `<app-name>` can be found at For example, if you only want to run `actoridscale` and `workflows` tests, you can do ```bash export DAPRPERFTEST="actoridscale workflows" make test-perf-all ``` Once you finished your testing, it's recommended to remove old test data, so it's easier to find the new

You can run ```bash make test-clean ``` 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-perf comment to the Pull Request. ```bash export DAPRPERFMETRICSPROMETHEUSPUSHGATEWAY_URL="http://localhost:9091" ``` Install the following in your Kubernetes cluster: Prometheus Pushgateway Grafana Create a new namesapce: ```bash DAPRPERFMETRICS_NAMESPACE=dapr-perf-metrics kubectl create namespace $DAPRPERFMETRICS_NAMESPACE ``` ```bash helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm install --namespace $DAPRPERFMETRICS_NAMESPACE prometheus prometheus-community/prometheus ``` The Prometheus installation above comes with a pushgateway. Forward port 9091 from your local machine to the prometheus-pushgateway pod and access it on `http://localhost:9091` ```bash kubectl port-forward --namespace $DAPRPERFMETRICS_NAMESPACE deployment/prometheus-prometheus-pushgateway 9091 ``` Create a `grafana.yaml` file with the following configurations: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: grafana namespace: dapr-perf-metrics spec: replicas: 1 selector: matchLabels: app: grafana template: metadata: labels:grafana app: grafana spec: containers: name: grafana image: grafana/grafana:latest ports: containerPort: 3000 apiVersion: v1 kind: Service metadata: name: grafana namespace: dapr-perf-metrics spec: type: LoadBalancer ports: port: 80 targetPort: 3000 protocol: TCP selector: app: grafana ``` Apply the configurations ```bash kubectl apply -f grafana.yaml ``` Forward port 3000 from your local machine to the pod where Grafana is running. ```bash kubectl port-forward --namespace $DAPRPERFMETRICS_NAMESPACE deployment/grafana 3000 ``` The Grafana server can now be accessed on localhost:3000 Login to Grafana with the default username and password 'admin' for both. Now go to data sources and connect Prometheus as a data source. The HTTP URL will be the ClusterIP of the prometheus-server pod running on Kubernetes which can be obtained by the command: ```bash kubectl get svc --namespace $DAPRPERFMETRICS_NAMESPACE ``` On running the perf-tests now, the metrics are collected from pushgateway by Prometheus and is made available for visualization as a dashboard by importing the above template in Grafana. <img width="1267" alt="grafanadashboard" src="./img/grafanadashboard.png">