diff --git a/.github/workflows/dapr-longhaul-nightly.yml b/.github/workflows/dapr-longhaul-nightly.yml new file mode 100644 index 00000000..84eb386e --- /dev/null +++ b/.github/workflows/dapr-longhaul-nightly.yml @@ -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 }} diff --git a/.github/workflows/pubsub-workflow-build.yml b/.github/workflows/pubsub-workflow-build.yml index 7f5306cc..a3c1058a 100644 --- a/.github/workflows/pubsub-workflow-build.yml +++ b/.github/workflows/pubsub-workflow-build.yml @@ -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: diff --git a/longhaul-test/azure-nightly-keyvault.yml b/longhaul-test/azure-nightly-keyvault.yml new file mode 100644 index 00000000..07163a7f --- /dev/null +++ b/longhaul-test/azure-nightly-keyvault.yml @@ -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 diff --git a/longhaul-test/redis-pubsub.yaml b/longhaul-test/redis-pubsub.yaml index c3419d32..97cc3d92 100644 --- a/longhaul-test/redis-pubsub.yaml +++ b/longhaul-test/redis-pubsub.yaml @@ -15,4 +15,8 @@ spec: - name: redisHost value: dapr-redis-master.dapr-components.svc.cluster.local:6379 - name: redisPassword - value: "" \ No newline at end of file + secretKeyRef: + name: dapr-redis + key: redis-password +auth: + secretStore: kubernetes diff --git a/longhaul-test/redis-statestore.yaml b/longhaul-test/redis-statestore.yaml index e8955fec..0709dbfa 100644 --- a/longhaul-test/redis-statestore.yaml +++ b/longhaul-test/redis-statestore.yaml @@ -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" \ No newline at end of file + value: "true" +auth: + secretStore: kubernetes \ No newline at end of file