Skip to content

Commit

Permalink
Add workflow for nightly tests
Browse files Browse the repository at this point in the history
This commit adds a workflow that sets up a complete dapr install
from dapr's source. This includes setting up all components and
adding the applications.

Signed-off-by: Hal Spang <[email protected]>
  • Loading branch information
halspang authored and wcs1only committed Jan 14, 2022
1 parent fe7c0f4 commit 605756e
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 5 deletions.
182 changes: 182 additions & 0 deletions .github/workflows/dapr-longhaul-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: dapr-longhaul-nightly

on:
schedule:
- cron: '0 7 * * *'

jobs:
test-nightly:
name: update dapr runtime
runs-on: ubuntu-latest
env:
GOVER: 1.16
KUBECTLVER: v1.19.3
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_REGISTRY: ${{ secrets.DOCKER_REGISTRY_ID }}
DAPR_TEST_REGISTRY: ${{ secrets.DOCKER_REGISTRY_ID }}
DAPR_REGISTRY_PASS: ${{ secrets.DOCKER_REGISTRY_PASS }}
HELMVER: v3.4.0
MAX_TEST_TIMEOUT: 5400
HA_MODE: true
DAPR_TAG : dev
TEST_OUTPUT_FILE_PREFIX: test_report
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
DAPR_NAMESPACE: dapr-system
DAPR_MONITORING: dapr-monitoring
DAPR_COMPONENTS: dapr-components
TEST_CLUSTER: daprnightly
TEST_RESOURCE_GROUP: dapr-test
DAPR_CHECKOUT_REPO: dapr/dapr
DAPR_CHECKOUT_REF: refs/heads/master
APP_NAMESPACE: longhaul-test
steps:
# Environment setup.
- name: Set up container log path
run: |
echo "DAPR_CONTAINER_LOG_PATH=$GITHUB_WORKSPACE/container_logs/${{ matrix.target_os }}_${{ matrix.target_arch }}" | sed 's/\\/\//g' >> $GITHUB_ENV
shell: bash
- name: Set up Go ${{ env.GOVER }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOVER }}
- name: Checkout dapr/dapr
uses: actions/checkout@v2
with:
repository: ${{ env.DAPR_CHECKOUT_REPO }}
ref: ${{ env.DAPR_CHECKOUT_REF }}
path: dapr
- name: Checkout dapr/test-infra
uses: actions/checkout@v2
with:
repository: dapr/test-infra
ref: refs/heads/master
path: longhaul
- uses: azure/setup-kubectl@v1
with:
version: ${{ env.KUBECTLVER }}
id: install
- name: Set up Helm ${{ env.HELMVER }}
uses: azure/setup-helm@v1
with:
version: ${{ env.HELMVER }}
- name: Azure login
run: |
az login --service-principal -u ${{ secrets.AZURE_LOGIN_USER }} -p ${{ secrets.AZURE_LOGIN_PASS }} --tenant ${{ secrets.AZURE_TENANT }} --output none
- name: Find the test cluster
run: az aks get-credentials -n ${{ env.TEST_CLUSTER }} -g ${{ env.TEST_RESOURCE_GROUP }}
shell: bash
# Setup docker and build image
- name: docker login
run: |
docker login -u ${{ env.DAPR_REGISTRY }} -p ${{ env.DAPR_REGISTRY_PASS }}
- name: Build dapr and its docker image and push them to test registry
working-directory: ./dapr
run: |
make build
make docker-build
make docker-push
# Setup monitoring
- name: Create monitoring namespace if it doesn't exist
run: |
kubectl get namespace | grep ${{ env.DAPR_MONITORING }} || kubectl create namespace ${{ env.DAPR_MONITORING }}
- name: check if grafana already exists
if: env.TEST_CLUSTER != ''
run: |
helm list -n ${{ env.DAPR_MONITORING }} | grep grafana && echo "GRAF_PRESENT=true" >> $GITHUB_ENV || echo "Grafana not present."
- name: Preparing ${{ env.TEST_CLUSTER }} cluster for test by installing grafana if not present
if: env.TEST_CLUSTER != '' && env.GRAF_PRESENT != 'true'
run: |
helm repo add grafana https://grafana.github.io/helm-charts
helm upgrade --install grafana grafana/grafana -n ${{ env.DAPR_MONITORING }}
kubectl get pods -n ${{ env.DAPR_MONITORING }}
- name: check if prometheus already exists
if: env.TEST_CLUSTER != ''
run: |
helm list -n ${{ env.DAPR_MONITORING }} | grep prometheus && echo "PROM_PRESENT=true" >> $GITHUB_ENV || echo "Prometheus not present."
- name: Preparing ${{ env.TEST_CLUSTER }} cluster for test by installing prometheus if not present
if: env.TEST_CLUSTER != '' && env.PROM_PRESENT != 'true'
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm upgrade --install dapr-prom prometheus-community/prometheus -n ${{ env.DAPR_MONITORING }}
kubectl get pods -n ${{ env.DAPR_MONITORING }}
# Deploy dapr to k8s
- name: Create dapr namespace, if it doesn't exist
run: |
kubectl get namespace | grep ${{ env.DAPR_NAMESPACE }} || kubectl create namespace ${{ env.DAPR_NAMESPACE }}
- name: Deploy dapr to ${{ env.TEST_CLUSTER }} cluster
if: env.TEST_CLUSTER != ''
working-directory: ./dapr
run: |
helm list -n ${{ env.DAPR_NAMESPACE }} | grep dapr && helm uninstall -n ${{ env.DAPR_NAMESPACE }} dapr || echo "Dapr not present, no need to uninstall."
make docker-deploy-k8s
# Deploy external components
- name: Create component namespace, if it doesn't exist
run: |
kubectl get namespace | grep ${{ env.DAPR_COMPONENTS }} || kubectl create namespace ${{ env.DAPR_COMPONENTS }}
- name: Check for redis
if: env.TEST_CLUSTER != ''
run: |
helm list -n ${{ env.DAPR_COMPONENTS }} | grep dapr-redis && echo "REDIS_PRESENT=true" >> $GITHUB_ENV || echo "Redis not present."
- name: Start redis if not present
if: env.REDIS_PRESENT != 'true'
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install dapr-redis bitnami/redis --namespace ${{ env.DAPR_COMPONENTS }} --wait
kubectl delete secret dapr-redis -n ${{ env.APP_NAMESPACE }} --ignore-not-found
kubectl get secret dapr-redis -n ${{ env.DAPR_COMPONENTS }} -o yaml | grep -v 'namespace:' | kubectl apply -f - -n ${{ env.APP_NAMESPACE }}
- name: Check for kafka
if: env.TEST_CLUSTER != ''
run: |
helm list -n ${{ env.DAPR_COMPONENTS }} | grep dapr-kafka && echo "KAFKA_PRESENT=true" >> $GITHUB_ENV || echo "Kafka not present."
- name: Start kafka if not present
if: env.KAFKA_PRESENT != 'true'
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install dapr-kafka bitnami/kafka --wait --namespace ${{ env.DAPR_COMPONENTS }}
# Deploy all longhaul tests/components
- name: Create app namespace, if it doesn't exist
run: |
kubectl get namespace | grep ${{ env.APP_NAMESPACE }} || kubectl create namespace ${{ env.APP_NAMESPACE }}
- name: Apply secret access roles # Required to access k8s in the non-standard namespace.
if: env.TEST_CLUSTER != ''
working-directory: ./longhaul
run: |
kubectl apply -f ./longhaul-test/secret-access-role.yml -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/secret-access-role-binding.yml -n ${{ env.APP_NAMESPACE }}
- name: Deploy components
if: env.TEST_CLUSTER != ''
working-directory: ./longhaul
run: |
kubectl apply -f ./longhaul-test/azure-nightly-keyvault.yml -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/azure-service-bus-pubsub.yml -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/binding.yaml -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/redis-pubsub.yaml -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/redis-statestore.yaml -n ${{ env.APP_NAMESPACE }}
- name: Deploy test applications
if: env.TEST_CLUSTER != ''
working-directory: ./longhaul
run: |
kubectl apply -f ./longhaul-test/feed-generator-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/feed-generator-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/hashtag-actor-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/hashtag-actor-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/hashtag-counter-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/hashtag-counter-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/message-analyzer-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/message-analyzer-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/pubsub-workflow-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/pubsub-workflow-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/snapshot-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/snapshot-app -n ${{ env.APP_NAMESPACE }}
kubectl apply -f ./longhaul-test/validation-worker-deploy.yml -n ${{ env.APP_NAMESPACE }} && kubectl rollout restart deploy/validation-worker-app -n ${{ env.APP_NAMESPACE }}
4 changes: 2 additions & 2 deletions .github/workflows/pubsub-workflow-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ on:
- master
paths:
- 'pubsub-workflow/**'
- '.github/workflows/**'
- '.github/workflows/pubsub-workflow-build.yml'
pull_request:
branches:
- master
paths:
- 'pubsub-workflow/**'
- '.github/workflows/**'
- '.github/workflows/pubsub-workflow-build.yml'

jobs:
build:
Expand Down
21 changes: 21 additions & 0 deletions longhaul-test/azure-nightly-keyvault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: longhaul-kv
namespace: longhaul-test
spec:
type: secretstores.azure.keyvault
version: v1
metadata:
- name: vaultName
value: nightly-keyvault
- name: azureTenantId
value: "72f988bf-86f1-41af-91ab-2d7cd011db47"
- name: azureClientId
value: "58a55e48-ccb3-4782-9429-fb36f8c59dda"
- name: azureClientSecret
secretKeyRef:
name: keyvault-client-secret
key: clientSecret
auth:
secretStore: kubernetes
6 changes: 5 additions & 1 deletion longhaul-test/redis-pubsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ spec:
- name: redisHost
value: dapr-redis-master.dapr-components.svc.cluster.local:6379
- name: redisPassword
value: ""
secretKeyRef:
name: dapr-redis
key: redis-password
auth:
secretStore: kubernetes
8 changes: 6 additions & 2 deletions longhaul-test/redis-statestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ spec:
- name: redisHost
value: dapr-redis-master.dapr-components.svc.cluster.local:6379
- name: redisPassword
value: ""
secretKeyRef:
name: dapr-redis
key: redis-password
- name: actorStateStore
value: "true"
value: "true"
auth:
secretStore: kubernetes

0 comments on commit 605756e

Please sign in to comment.