From cb76fbaf66f211d0afa1d212d9b556b4bafc2c7e Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 29 Jul 2024 15:02:12 -0700 Subject: [PATCH 1/8] Removing readiness and liveness probes from eshop Signed-off-by: willdavsmith --- samples/eshop/services/basket.bicep | 10 ---------- samples/eshop/services/catalog.bicep | 10 ---------- samples/eshop/services/identity.bicep | 10 ---------- samples/eshop/services/ordering.bicep | 10 ---------- samples/eshop/services/payment.bicep | 10 ---------- samples/eshop/services/seq.bicep | 4 ---- samples/eshop/services/web.bicep | 10 ---------- samples/eshop/services/webhooks.bicep | 10 ---------- samples/eshop/services/webshopping.bicep | 14 -------------- samples/eshop/services/webstatus.bicep | 4 ---- 10 files changed, 92 deletions(-) diff --git a/samples/eshop/services/basket.bicep b/samples/eshop/services/basket.bicep index c3b9e327..61349b16 100644 --- a/samples/eshop/services/basket.bicep +++ b/samples/eshop/services/basket.bicep @@ -61,16 +61,6 @@ resource basket 'Applications.Core/containers@2023-10-01-preview' = { port: 9103 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { diff --git a/samples/eshop/services/catalog.bicep b/samples/eshop/services/catalog.bicep index ec78da17..de2ab66e 100644 --- a/samples/eshop/services/catalog.bicep +++ b/samples/eshop/services/catalog.bicep @@ -64,16 +64,6 @@ resource catalog 'Applications.Core/containers@2023-10-01-preview' = { port: 9101 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { sql: { diff --git a/samples/eshop/services/identity.bicep b/samples/eshop/services/identity.bicep index e95c4638..231fefcb 100644 --- a/samples/eshop/services/identity.bicep +++ b/samples/eshop/services/identity.bicep @@ -52,16 +52,6 @@ resource identity 'Applications.Core/containers@2023-10-01-preview' = { port: 5105 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { redis: { diff --git a/samples/eshop/services/ordering.bicep b/samples/eshop/services/ordering.bicep index edf366a3..a4719657 100644 --- a/samples/eshop/services/ordering.bicep +++ b/samples/eshop/services/ordering.bicep @@ -143,16 +143,6 @@ resource orderingsignalrhub 'Applications.Core/containers@2023-10-01-preview' = port: 5112 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { redis: { diff --git a/samples/eshop/services/payment.bicep b/samples/eshop/services/payment.bicep index 32c6c38f..f6a11aae 100644 --- a/samples/eshop/services/payment.bicep +++ b/samples/eshop/services/payment.bicep @@ -44,16 +44,6 @@ resource payment 'Applications.Core/containers@2023-10-01-preview' = { port: 5108 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } } } diff --git a/samples/eshop/services/seq.bicep b/samples/eshop/services/seq.bicep index 32090891..8f8a9dd1 100644 --- a/samples/eshop/services/seq.bicep +++ b/samples/eshop/services/seq.bicep @@ -22,10 +22,6 @@ resource seq 'Applications.Core/containers@2023-10-01-preview' = { port: 5340 } } - livenessProbe:{ - kind:'tcp' - containerPort:80 - } } } } diff --git a/samples/eshop/services/web.bicep b/samples/eshop/services/web.bicep index 4a2af4a6..447660c4 100644 --- a/samples/eshop/services/web.bicep +++ b/samples/eshop/services/web.bicep @@ -46,16 +46,6 @@ resource webspa 'Applications.Core/containers@2023-10-01-preview' = { port: 5104 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { redis: { diff --git a/samples/eshop/services/webhooks.bicep b/samples/eshop/services/webhooks.bicep index 6a65df17..b8677f3f 100644 --- a/samples/eshop/services/webhooks.bicep +++ b/samples/eshop/services/webhooks.bicep @@ -54,16 +54,6 @@ resource webhooks 'Applications.Core/containers@2023-10-01-preview' = { port: 5113 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { sql: { diff --git a/samples/eshop/services/webshopping.bicep b/samples/eshop/services/webshopping.bicep index a27f37bc..b92a59b8 100644 --- a/samples/eshop/services/webshopping.bicep +++ b/samples/eshop/services/webshopping.bicep @@ -47,16 +47,6 @@ resource webshoppingagg 'Applications.Core/containers@2023-10-01-preview' = { port: 5121 } } - livenessProbe: { - kind: 'httpGet' - path: '/liveness' - containerPort: 80 - } - readinessProbe: { - kind: 'httpGet' - path: '/hc' - containerPort: 80 - } } connections: { identity: { @@ -96,10 +86,6 @@ resource webshoppingapigw 'Applications.Core/containers@2023-10-01-preview' = { port: 15202 } } - livenessProbe: { - kind: 'tcp' - containerPort: 80 - } } } } diff --git a/samples/eshop/services/webstatus.bicep b/samples/eshop/services/webstatus.bicep index b2f7fe10..344bf226 100644 --- a/samples/eshop/services/webstatus.bicep +++ b/samples/eshop/services/webstatus.bicep @@ -51,10 +51,6 @@ resource webstatus 'Applications.Core/containers@2023-10-01-preview' = { port: 8107 } } - livenessProbe: { - kind: 'tcp' - containerPort: 80 - } } } } From a85e4e8a8f93569a4a81359b29306051984538ae Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 08:58:38 -0700 Subject: [PATCH 2/8] test Signed-off-by: willdavsmith --- .github/workflows/test.yaml | 41 +++++++++++++------------------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fb434133..85bd005e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -98,6 +98,7 @@ jobs: AZURE_LOCATION: westus3 AWS_REGION: us-west-2 AWS_ZONES: us-west-2a,us-west-2b,us-west-2c + if: ${{ github.event_name == 'pull_request' && matrix.runOnPullRequest == 'false' }} steps: # Setup the test assets and configuration - name: Generate output variables @@ -105,12 +106,6 @@ jobs: run: | RUN_IDENTIFIER=${{ env.RUN_IDENTIFIER }}-${{ matrix.name }} - if [[ "${{ github.event_name }}" == "pull_request" && "${{ matrix.runOnPullRequest }}" == "false" ]]; then - RUN_TEST=false - else - RUN_TEST=true - fi - if [[ "${{ matrix.enableDapr }}" == "true" ]]; then ENABLE_DAPR=true else @@ -121,42 +116,37 @@ jobs: echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT echo "TEST_AZURE_RESOURCE_GROUP=rg-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT - echo "RUN_TEST=${RUN_TEST}" >> $GITHUB_OUTPUT echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT - name: Checkout code - if: steps.gen-id.outputs.RUN_TEST == 'true' uses: actions/checkout@v4 - name: Ensure inputs.version is valid semver - if: steps.gen-id.outputs.RUN_TEST == 'true' && inputs.version != '' + if: inputs.version != '' run: | python ./.github/scripts/validate_semver.py ${{ inputs.version }} - name: Setup Node - if: steps.gen-id.outputs.RUN_TEST == 'true' uses: actions/setup-node@v4 with: node-version: 20 - name: az CLI login - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'azure' + if: matrix.credential == 'azure' run: | az login --service-principal \ --username ${{ secrets.AZURE_SP_TESTS_APPID }} \ --password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \ --tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }} - name: Configure AWS - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'aws' + if: matrix.credential == 'aws' run: | aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws configure set region ${{ env.AWS_REGION }} aws configure set output json - name: Download k3d - if: steps.gen-id.outputs.RUN_TEST == 'true' run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash - name: Create k3d cluster - if: steps.gen-id.outputs.RUN_TEST == 'true' run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-create sampleregistry:51351 - name: Build images - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.images != '' + if: matrix.images != '' run: | # split images and directories into arrays IFS=',' read -ra images <<< "${{ matrix.images }}" @@ -172,7 +162,7 @@ jobs: done # Create and install test environment - name: Create Azure resource group - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'azure' + if: matrix.credential == 'azure' id: create-azure-resource-group run: | current_time=$(date +%s) @@ -186,7 +176,7 @@ jobs: sleep 5 done - name: Create EKS Cluster - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'aws' + if: matrix.credential == 'aws' id: create-eks run: | curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp @@ -205,12 +195,11 @@ jobs: timeout-minutes: 60 continue-on-error: false - name: Install Dapr - if: steps.gen-id.outputs.RUN_TEST == 'true' && steps.gen-id.outputs.ENABLE_DAPR == 'true' + if: steps.gen-id.outputs.ENABLE_DAPR == 'true' run: | helm repo add dapr https://dapr.github.io/helm-charts/ helm install dapr dapr/dapr --version=1.6 --namespace dapr-system --create-namespace --wait - name: Download rad CLI - if: steps.gen-id.outputs.RUN_TEST == 'true' run: | RADIUS_VERSION="${{ inputs.version }}" if [[ -z "${{ inputs.version }}" ]]; then @@ -218,7 +207,6 @@ jobs: fi ./.github/scripts/install-radius.sh $RADIUS_VERSION - name: Initialize default environment - if: steps.gen-id.outputs.RUN_TEST == 'true' run: | if [[ "${{ matrix.credential }}" == "aws" ]]; then rad install kubernetes @@ -235,7 +223,7 @@ jobs: rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:latest --resource-type Applications.Datastores/sqlDatabases rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:latest --resource-type Applications.Messaging/rabbitMQQueues - name: Configure cloud credentials - if: steps.gen-id.outputs.RUN_TEST == 'true' && ( matrix.credential == 'azure' || matrix.credential == 'aws') + if: matrix.credential == 'azure' || matrix.credential == 'aws' run: | if [[ "${{ matrix.credential }}" == "azure" ]]; then rad env update default --azure-subscription-id ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} --azure-resource-group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} @@ -247,7 +235,7 @@ jobs: fi ## This step is temporary until we have Recipe Packs for Azure & AWS and update the eShop sample - name: Initialize eShop environments - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.app == 'eshop' + if: matrix.app == 'eshop' run: | if [[ "${{ matrix.credential }}" == "azure" ]]; then rad deploy ./samples/eshop/environments/azure.bicep -p azureResourceGroup=${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} -p azureSubscriptionId=${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} @@ -258,7 +246,6 @@ jobs: # Deploy application and run tests # Retry the deployment step in case of transient failures - name: Deploy app - if: steps.gen-id.outputs.RUN_TEST == 'true' id: deploy-app uses: nick-fields/retry@v3 with: @@ -267,7 +254,7 @@ jobs: retry_wait_seconds: 30 command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }} - name: Run Playwright Test - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != '' + if: matrix.uiTestFile != '' id: run-playwright-test run: | if [[ "${{ matrix.container }}" != "" ]]; then @@ -329,13 +316,13 @@ jobs: run: gh issue create --title "Samples deployment failed for ${{ matrix.name }}" --body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." --repo ${{ github.repository }} --label test-failure # Cleanup - name: Delete app - if: steps.gen-id.outputs.RUN_TEST == 'true' && steps.deploy-app.outcome == 'success' + if: steps.deploy-app.outcome == 'success' run: | if command -v rad &> /dev/null; then rad app delete ${{ matrix.app }} -y fi - name: Delete Azure resource group - if: steps.gen-id.outputs.RUN_TEST == 'true' && steps.create-azure-resource-group.outcome == 'success' + if: steps.create-azure-resource-group.outcome == 'success' run: | # Delete Azure resources created by the test # if deletion fails, purge workflow will purge the resource group and its resources later @@ -344,7 +331,7 @@ jobs: --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} \ --yes - name: Delete AWS Resources - if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'aws' && steps.deploy-app.outcome == 'success' + if: matrix.credential == 'aws' && steps.deploy-app.outcome == 'success' run: | # Delete all AWS resources created by the test ./.github/scripts/delete-aws-resources.sh '/planes/radius/local/resourcegroups/default/providers/Applications.Core/applications/${{ matrix.app }}' From 027fd74cd6ae454b70ba12baf3a93bcf5d36b044 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 10:00:43 -0700 Subject: [PATCH 3/8] test Signed-off-by: willdavsmith --- .github/scripts/generate-test-variables.sh | 37 +++ .github/workflows/run-test.yaml | 312 +++++++++++++++++++++ .github/workflows/test.yaml | 272 ++---------------- 3 files changed, 369 insertions(+), 252 deletions(-) create mode 100644 .github/scripts/generate-test-variables.sh create mode 100644 .github/workflows/run-test.yaml diff --git a/.github/scripts/generate-test-variables.sh b/.github/scripts/generate-test-variables.sh new file mode 100644 index 00000000..14eac861 --- /dev/null +++ b/.github/scripts/generate-test-variables.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# ------------------------------------------------------------ +# Copyright 2023 The Radius 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. +# ------------------------------------------------------------ + +set -ex + +MATRIX=$1 +RUN_IDENTIFIER=$2 + +MATRIX=${{ fromJSON(inputs.matrix) }} +RUN_IDENTIFIER=${{ inputs.RUN_IDENTIFIER }}- + +if [[ "${{ matrix.enableDapr }}" == "true" ]]; then + ENABLE_DAPR=true +else + ENABLE_DAPR=false +fi + +# Set output variables to be used in the other jobs +echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT +echo "TEST_AZURE_RESOURCE_GROUP=rg-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT +echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT +echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml new file mode 100644 index 00000000..593e743e --- /dev/null +++ b/.github/workflows/run-test.yaml @@ -0,0 +1,312 @@ +name: Test Samples (k3d and EKS) + +on: + workflow_call: + inputs: + version: + description: "Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge). Defaults to edge." + required: false + default: "edge" + type: string + run-identifier: + required: true + type: string + name: + required: true + type: string + os: + required: true + type: string + runOnPullRequest: + required: true + type: boolean + app: + required: true + type: string + env: + required: true + type: string + path: + required: true + type: string + deployArgs: + required: true + type: string + exposeArgs: + required: true + type: string + uiTestFile: + required: true + type: string + port: + required: true + type: number + container: + required: true + type: string + enableDapr: + required: true + type: boolean + images: + required: true + type: string + directories: + required: true + type: string + credential: + required: true + type: string +jobs: + test: + runs-on: ${{ inputs.os }} + env: + BRANCH: ${{ github.base_ref || github.ref_name }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AZURE_LOCATION: westus3 + AWS_REGION: us-west-2 + AWS_ZONES: us-west-2a,us-west-2b,us-west-2c + if: | + github.event_name == 'schedule' || + github.event_name == 'workflow_dispatch' || + (github.event_name == 'pull_request' && inputs.runOnPullRequest == true) + steps: + # Setup the test assets and configuration + - name: Generate output variables + id: gen-id + run: | + RUN_IDENTIFIER=${{ inputs.run-identifier }}-${{ inputs.name }} + + if [[ "${{ inputs.enableDapr }}" == "true" ]]; then + ENABLE_DAPR=true + else + ENABLE_DAPR=false + fi + + # Set output variables to be used in the other jobs + echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT + echo "TEST_AZURE_RESOURCE_GROUP=rg-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT + echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT + echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT + - name: Checkout code + uses: actions/checkout@v4 + - name: Ensure inputs.version is valid semver + if: inputs.version != '' + run: | + python ./.github/scripts/validate_semver.py ${{ inputs.version }} + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: az CLI login + if: inputs.credential == 'azure' + run: | + az login --service-principal \ + --username ${{ secrets.AZURE_SP_TESTS_APPID }} \ + --password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \ + --tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }} + - name: Configure AWS + if: inputs.credential == 'aws' + run: | + aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws configure set region ${{ env.AWS_REGION }} + aws configure set output json + - name: Download k3d + run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash + - name: Create k3d cluster + run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-create sampleregistry:51351 + - name: Build images + if: inputs.images != '' + run: | + # split images and directories into arrays + IFS=',' read -ra images <<< "${{ inputs.images }}" + IFS=',' read -ra directories <<< "${{ inputs.directories }}" + echo "Building images: $images" + echo "Directories: $directories" + for index in "${!images[@]}"; do + image=${images[$index]} + directory=${directories[$index]} + echo "Building image $image from directory $directory" + docker build -t localhost:51351/$image:latest $directory + docker push localhost:51351/$image:latest + done + # Create and install test environment + - name: Create Azure resource group + if: inputs.credential == 'azure' + id: create-azure-resource-group + run: | + current_time=$(date +%s) + az group create \ + --location ${{ env.AZURE_LOCATION }} \ + --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} \ + --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} \ + --tags creationTime=$current_time + while [ $(az group exists --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }}) = false ]; do + echo "Waiting for resource group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} to be created..." + sleep 5 + done + - name: Create EKS Cluster + if: inputs.credential == 'aws' + id: create-eks + run: | + curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp + sudo mv /tmp/eksctl /usr/local/bin + eksctl create cluster \ + --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} \ + --nodes-min 1 --nodes-max 2 --node-type t3.large \ + --zones ${{ env.AWS_ZONES }} \ + --managed \ + --region ${{ env.AWS_REGION }} + while [[ "$(eksctl get cluster ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }} -o json | jq -r .[0].Status)" != "ACTIVE" ]]; do + echo "Waiting for EKS cluster to be created..." + sleep 60 + done + aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} + timeout-minutes: 60 + continue-on-error: false + - name: Install Dapr + if: steps.gen-id.outputs.ENABLE_DAPR == 'true' + run: | + helm repo add dapr https://dapr.github.io/helm-charts/ + helm install dapr dapr/dapr --version=1.6 --namespace dapr-system --create-namespace --wait + - name: Download rad CLI + run: | + RADIUS_VERSION="${{ inputs.version }}" + if [[ -z "${{ inputs.version }}" ]]; then + RADIUS_VERSION=edge + fi + ./.github/scripts/install-radius.sh $RADIUS_VERSION + - name: Initialize default environment + run: | + if [[ "${{ inputs.credential }}" == "aws" ]]; then + rad install kubernetes + else + rad install kubernetes --set rp.publicEndpointOverride=localhost + fi + rad group create default + rad workspace create kubernetes default --group default + rad group switch default + rad env create default + rad env switch default + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:latest --resource-type Applications.Datastores/redisCaches + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:latest --resource-type Applications.Datastores/mongoDatabases + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:latest --resource-type Applications.Datastores/sqlDatabases + rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:latest --resource-type Applications.Messaging/rabbitMQQueues + - name: Configure cloud credentials + if: inputs.credential == 'azure' || inputs.credential == 'aws' + run: | + if [[ "${{ inputs.credential }}" == "azure" ]]; then + rad env update default --azure-subscription-id ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} --azure-resource-group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} + rad credential register azure sp --client-id ${{ secrets.AZURE_SP_TESTS_APPID }} --client-secret ${{ secrets.AZURE_SP_TESTS_PASSWORD }} --tenant-id ${{ secrets.AZURE_SP_TESTS_TENANTID }} + fi + if [[ "${{ inputs.credential }}" == "aws" ]]; then + rad env update default --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.AWS_ACCOUNT_ID }} + rad credential register aws --access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.AWS_SECRET_ACCESS_KEY }} + fi + ## This step is temporary until we have Recipe Packs for Azure & AWS and update the eShop sample + - name: Initialize eShop environments + if: inputs.app == 'eshop' + run: | + if [[ "${{ inputs.credential }}" == "azure" ]]; then + rad deploy ./samples/eshop/environments/azure.bicep -p azureResourceGroup=${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} -p azureSubscriptionId=${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} + elif [[ "${{ inputs.credential }}" == "aws" ]]; then + rad deploy ./samples/eshop/environments/aws.bicep -p awsAccountId=${{ secrets.AWS_ACCOUNT_ID }} -p awsRegion=${{ env.AWS_REGION }} -p eksClusterName=${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} + fi + rad env switch ${{ inputs.env }} + # Deploy application and run tests + # Retry the deployment step in case of transient failures + - name: Deploy app + id: deploy-app + uses: nick-fields/retry@v3 + with: + timeout_minutes: 30 + max_attempts: 3 + retry_wait_seconds: 30 + command: rad deploy ${{ inputs.path }} ${{ inputs.deployArgs }} + - name: Run Playwright Test + if: inputs.uiTestFile != '' + id: run-playwright-test + run: | + if [[ "${{ inputs.container }}" != "" ]]; then + rad resource expose containers ${{ inputs.container }} ${{ inputs.exposeArgs }} --port ${{ inputs.port }} & + export ENDPOINT="http://localhost:3000/" + else + endpoint="$(rad app status -a ${{ inputs.app }} | sed 's/ /\n/g' | grep http)" + echo "Endpoint: $endpoint" + export ENDPOINT=$endpoint + fi + + cd playwright/ + npm ci + npx playwright install --with-deps + npx playwright test ${{ inputs.uiTestFile }} --retries 3 + - name: Upload Playwright Results + uses: actions/upload-artifact@v4 + if: always() && (steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure') + with: + name: playwright-report-${{ inputs.name }} + path: playwright/playwright-report/ + retention-days: 30 + if-no-files-found: error + - name: Upload Playwright Videos + uses: actions/upload-artifact@v4 + if: always() && steps.run-playwright-test.outcome == 'failure' + with: + name: playwright-video-${{ inputs.name }} + path: playwright/test-results/ + retention-days: 30 + if-no-files-found: error + # Handle failures + - name: Get Pod logs for failed tests + id: get-pod-logs + if: failure() && (steps.run-playwright-test.outcome == 'failure' || steps.deploy-app.outcome == 'failure') + run: | + # Create pod-logs directory + mkdir -p playwright/pod-logs/${{ inputs.name }} + # Get pod logs and save to file + namespace="${{ inputs.env }}-${{ inputs.app }}" + label="radapp.io/application=${{ inputs.app }}" + pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}')) + for pod_name in "${pod_names[@]}"; do + kubectl logs $pod_name -n $namespace > playwright/pod-logs/${{ inputs.name }}/${pod_name}.txt + done + echo "Pod logs saved to playwright/pod-logs/${{ inputs.name }}/" + # Get kubernetes events and save to file + kubectl get events -n $namespace > playwright/pod-logs/${{ inputs.name }}/events.txt + - name: Upload Pod logs for failed tests + uses: actions/upload-artifact@v4 + if: failure() && steps.get-pod-logs.outcome == 'success' + with: + name: ${{ inputs.name }}-pod-logs + path: playwright/pod-logs/${{ inputs.name }} + retention-days: 30 + if-no-files-found: error + - name: Create GitHub issue on failure + if: failure() && github.event_name == 'schedule' + run: gh issue create --title "Samples deployment failed for ${{ inputs.name }}" --body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." --repo ${{ github.repository }} --label test-failure + # Cleanup + - name: Delete app + if: steps.deploy-app.outcome == 'success' + run: | + if command -v rad &> /dev/null; then + rad app delete ${{ inputs.app }} -y + fi + - name: Delete Azure resource group + if: steps.create-azure-resource-group.outcome == 'success' + run: | + # Delete Azure resources created by the test + # if deletion fails, purge workflow will purge the resource group and its resources later + az group delete \ + --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} \ + --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} \ + --yes + - name: Delete AWS Resources + if: inputs.credential == 'aws' && steps.deploy-app.outcome == 'success' + run: | + # Delete all AWS resources created by the test + ./.github/scripts/delete-aws-resources.sh '/planes/radius/local/resourcegroups/default/providers/Applications.Core/applications/${{ inputs.app }}' + - name: Delete EKS Cluster ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} + if: steps.create-eks.outcome == 'success' + run: | + echo "Deleting EKS cluster: ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}" + eksctl delete cluster --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }} --wait --force diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 85bd005e..6a3c3ee5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,15 +22,31 @@ on: - edge schedule: # Run every day at 12 PM - cron: "0 12 * * *" -env: - RUN_IDENTIFIER: samplestest-${{ github.run_id }}-${{ github.run_attempt }} jobs: test: - name: Sample tests - runs-on: ${{ matrix.os }} + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ inputs.version }} + run-identifier: samplestest-${{ github.run_id }}-${{ github.run_attempt }} + name: ${{ matrix.name }} + os: ${{ matrix.os }} + runOnPullRequest: ${{ matrix.runOnPullRequest }} + app: ${{ matrix.app }} + env: ${{ matrix.env }} + path: ${{ matrix.path }} + deployArgs: ${{ matrix.deployArgs }} + exposeArgs: ${{ matrix.exposeArgs }} + uiTestFile: ${{ matrix.uiTestFile }} + port: ${{ matrix.port }} + container: ${{ matrix.container }} + enableDapr: ${{ matrix.enableDapr }} + images: ${{ matrix.images }} + directories: ${{ matrix.directories }} + credential: ${{ matrix.credential }} strategy: fail-fast: false matrix: + target: [dev, stage, prod] include: - name: demo os: ubuntu-latest @@ -92,251 +108,3 @@ jobs: uiTestFile: tests/eshop/eshop.app.spec.ts credential: aws enableDapr: false - env: - BRANCH: ${{ github.base_ref || github.ref_name }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - AZURE_LOCATION: westus3 - AWS_REGION: us-west-2 - AWS_ZONES: us-west-2a,us-west-2b,us-west-2c - if: ${{ github.event_name == 'pull_request' && matrix.runOnPullRequest == 'false' }} - steps: - # Setup the test assets and configuration - - name: Generate output variables - id: gen-id - run: | - RUN_IDENTIFIER=${{ env.RUN_IDENTIFIER }}-${{ matrix.name }} - - if [[ "${{ matrix.enableDapr }}" == "true" ]]; then - ENABLE_DAPR=true - else - ENABLE_DAPR=false - fi - - # Set output variables to be used in the other jobs - echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT - echo "TEST_AZURE_RESOURCE_GROUP=rg-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT - echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT - echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT - - name: Checkout code - uses: actions/checkout@v4 - - name: Ensure inputs.version is valid semver - if: inputs.version != '' - run: | - python ./.github/scripts/validate_semver.py ${{ inputs.version }} - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: az CLI login - if: matrix.credential == 'azure' - run: | - az login --service-principal \ - --username ${{ secrets.AZURE_SP_TESTS_APPID }} \ - --password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \ - --tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }} - - name: Configure AWS - if: matrix.credential == 'aws' - run: | - aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} - aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws configure set region ${{ env.AWS_REGION }} - aws configure set output json - - name: Download k3d - run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash - - name: Create k3d cluster - run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-create sampleregistry:51351 - - name: Build images - if: matrix.images != '' - run: | - # split images and directories into arrays - IFS=',' read -ra images <<< "${{ matrix.images }}" - IFS=',' read -ra directories <<< "${{ matrix.directories }}" - echo "Building images: $images" - echo "Directories: $directories" - for index in "${!images[@]}"; do - image=${images[$index]} - directory=${directories[$index]} - echo "Building image $image from directory $directory" - docker build -t localhost:51351/$image:latest $directory - docker push localhost:51351/$image:latest - done - # Create and install test environment - - name: Create Azure resource group - if: matrix.credential == 'azure' - id: create-azure-resource-group - run: | - current_time=$(date +%s) - az group create \ - --location ${{ env.AZURE_LOCATION }} \ - --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} \ - --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} \ - --tags creationTime=$current_time - while [ $(az group exists --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }}) = false ]; do - echo "Waiting for resource group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} to be created..." - sleep 5 - done - - name: Create EKS Cluster - if: matrix.credential == 'aws' - id: create-eks - run: | - curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp - sudo mv /tmp/eksctl /usr/local/bin - eksctl create cluster \ - --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} \ - --nodes-min 1 --nodes-max 2 --node-type t3.large \ - --zones ${{ env.AWS_ZONES }} \ - --managed \ - --region ${{ env.AWS_REGION }} - while [[ "$(eksctl get cluster ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }} -o json | jq -r .[0].Status)" != "ACTIVE" ]]; do - echo "Waiting for EKS cluster to be created..." - sleep 60 - done - aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} - timeout-minutes: 60 - continue-on-error: false - - name: Install Dapr - if: steps.gen-id.outputs.ENABLE_DAPR == 'true' - run: | - helm repo add dapr https://dapr.github.io/helm-charts/ - helm install dapr dapr/dapr --version=1.6 --namespace dapr-system --create-namespace --wait - - name: Download rad CLI - run: | - RADIUS_VERSION="${{ inputs.version }}" - if [[ -z "${{ inputs.version }}" ]]; then - RADIUS_VERSION=edge - fi - ./.github/scripts/install-radius.sh $RADIUS_VERSION - - name: Initialize default environment - run: | - if [[ "${{ matrix.credential }}" == "aws" ]]; then - rad install kubernetes - else - rad install kubernetes --set rp.publicEndpointOverride=localhost - fi - rad group create default - rad workspace create kubernetes default --group default - rad group switch default - rad env create default - rad env switch default - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:latest --resource-type Applications.Datastores/redisCaches - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:latest --resource-type Applications.Datastores/mongoDatabases - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:latest --resource-type Applications.Datastores/sqlDatabases - rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:latest --resource-type Applications.Messaging/rabbitMQQueues - - name: Configure cloud credentials - if: matrix.credential == 'azure' || matrix.credential == 'aws' - run: | - if [[ "${{ matrix.credential }}" == "azure" ]]; then - rad env update default --azure-subscription-id ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} --azure-resource-group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} - rad credential register azure sp --client-id ${{ secrets.AZURE_SP_TESTS_APPID }} --client-secret ${{ secrets.AZURE_SP_TESTS_PASSWORD }} --tenant-id ${{ secrets.AZURE_SP_TESTS_TENANTID }} - fi - if [[ "${{ matrix.credential }}" == "aws" ]]; then - rad env update default --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.AWS_ACCOUNT_ID }} - rad credential register aws --access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.AWS_SECRET_ACCESS_KEY }} - fi - ## This step is temporary until we have Recipe Packs for Azure & AWS and update the eShop sample - - name: Initialize eShop environments - if: matrix.app == 'eshop' - run: | - if [[ "${{ matrix.credential }}" == "azure" ]]; then - rad deploy ./samples/eshop/environments/azure.bicep -p azureResourceGroup=${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} -p azureSubscriptionId=${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} - elif [[ "${{ matrix.credential }}" == "aws" ]]; then - rad deploy ./samples/eshop/environments/aws.bicep -p awsAccountId=${{ secrets.AWS_ACCOUNT_ID }} -p awsRegion=${{ env.AWS_REGION }} -p eksClusterName=${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} - fi - rad env switch ${{ matrix.env }} - # Deploy application and run tests - # Retry the deployment step in case of transient failures - - name: Deploy app - id: deploy-app - uses: nick-fields/retry@v3 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 30 - command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }} - - name: Run Playwright Test - if: matrix.uiTestFile != '' - id: run-playwright-test - run: | - if [[ "${{ matrix.container }}" != "" ]]; then - rad resource expose containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} & - export ENDPOINT="http://localhost:3000/" - else - endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)" - echo "Endpoint: $endpoint" - export ENDPOINT=$endpoint - fi - - cd playwright/ - npm ci - npx playwright install --with-deps - npx playwright test ${{ matrix.uiTestFile }} --retries 3 - - name: Upload Playwright Results - uses: actions/upload-artifact@v4 - if: always() && (steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure') - with: - name: playwright-report-${{ matrix.name }} - path: playwright/playwright-report/ - retention-days: 30 - if-no-files-found: error - - name: Upload Playwright Videos - uses: actions/upload-artifact@v4 - if: always() && steps.run-playwright-test.outcome == 'failure' - with: - name: playwright-video-${{ matrix.name }} - path: playwright/test-results/ - retention-days: 30 - if-no-files-found: error - # Handle failures - - name: Get Pod logs for failed tests - id: get-pod-logs - if: failure() && (steps.run-playwright-test.outcome == 'failure' || steps.deploy-app.outcome == 'failure') - run: | - # Create pod-logs directory - mkdir -p playwright/pod-logs/${{ matrix.name }} - # Get pod logs and save to file - namespace="${{ matrix.env }}-${{ matrix.app }}" - label="radapp.io/application=${{ matrix.app }}" - pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}')) - for pod_name in "${pod_names[@]}"; do - kubectl logs $pod_name -n $namespace > playwright/pod-logs/${{ matrix.name }}/${pod_name}.txt - done - echo "Pod logs saved to playwright/pod-logs/${{ matrix.name }}/" - # Get kubernetes events and save to file - kubectl get events -n $namespace > playwright/pod-logs/${{ matrix.name }}/events.txt - - name: Upload Pod logs for failed tests - uses: actions/upload-artifact@v4 - if: failure() && steps.get-pod-logs.outcome == 'success' - with: - name: ${{ matrix.name }}-pod-logs - path: playwright/pod-logs/${{ matrix.name }} - retention-days: 30 - if-no-files-found: error - - name: Create GitHub issue on failure - if: failure() && github.event_name == 'schedule' - run: gh issue create --title "Samples deployment failed for ${{ matrix.name }}" --body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." --repo ${{ github.repository }} --label test-failure - # Cleanup - - name: Delete app - if: steps.deploy-app.outcome == 'success' - run: | - if command -v rad &> /dev/null; then - rad app delete ${{ matrix.app }} -y - fi - - name: Delete Azure resource group - if: steps.create-azure-resource-group.outcome == 'success' - run: | - # Delete Azure resources created by the test - # if deletion fails, purge workflow will purge the resource group and its resources later - az group delete \ - --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} \ - --name ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} \ - --yes - - name: Delete AWS Resources - if: matrix.credential == 'aws' && steps.deploy-app.outcome == 'success' - run: | - # Delete all AWS resources created by the test - ./.github/scripts/delete-aws-resources.sh '/planes/radius/local/resourcegroups/default/providers/Applications.Core/applications/${{ matrix.app }}' - - name: Delete EKS Cluster ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} - if: steps.create-eks.outcome == 'success' - run: | - echo "Deleting EKS cluster: ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}" - eksctl delete cluster --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }} --wait --force From 828b6010fa79832094d858917134c6d7deedad21 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 10:01:32 -0700 Subject: [PATCH 4/8] test Signed-off-by: willdavsmith --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6a3c3ee5..fa5a3bf2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -46,7 +46,6 @@ jobs: strategy: fail-fast: false matrix: - target: [dev, stage, prod] include: - name: demo os: ubuntu-latest From 727c341c098fbe1e66101991660f1b9b6e59f199 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 10:11:16 -0700 Subject: [PATCH 5/8] test Signed-off-by: willdavsmith --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fa5a3bf2..f6972aaf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -91,7 +91,7 @@ jobs: enableDapr: false - name: eshop-azure os: ubuntu-latest-m - runOnPullRequest: false + runOnPullRequest: true app: eshop env: azure path: ./samples/eshop/eshop.bicep From 2019eda7d5b13d78fd9cff42428d1952d0a9d75d Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 10:45:05 -0700 Subject: [PATCH 6/8] test Signed-off-by: willdavsmith --- .github/workflows/run-test.yaml | 16 +-- .github/workflows/test.yaml | 179 +++++++++++++++++--------------- 2 files changed, 105 insertions(+), 90 deletions(-) diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml index 593e743e..b8f34d70 100644 --- a/.github/workflows/run-test.yaml +++ b/.github/workflows/run-test.yaml @@ -30,31 +30,31 @@ on: required: true type: string deployArgs: - required: true + required: false type: string exposeArgs: - required: true + required: false type: string uiTestFile: - required: true + required: false type: string port: - required: true + required: false type: number container: - required: true + required: false type: string enableDapr: required: true type: boolean images: - required: true + required: false type: string directories: - required: true + required: false type: string credential: - required: true + required: false type: string jobs: test: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f6972aaf..d123fb05 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,88 +22,103 @@ on: - edge schedule: # Run every day at 12 PM - cron: "0 12 * * *" +env: + VERSION: ${{ github.env.VERSION }} + RUN_IDENTIFIER: samplestest-${{ github.run_id }}-${{ github.run_attempt }} jobs: - test: + test-demo: + name: Test Demo Application uses: ./.github/workflows/run-test.yaml with: - version: ${{ inputs.version }} - run-identifier: samplestest-${{ github.run_id }}-${{ github.run_attempt }} - name: ${{ matrix.name }} - os: ${{ matrix.os }} - runOnPullRequest: ${{ matrix.runOnPullRequest }} - app: ${{ matrix.app }} - env: ${{ matrix.env }} - path: ${{ matrix.path }} - deployArgs: ${{ matrix.deployArgs }} - exposeArgs: ${{ matrix.exposeArgs }} - uiTestFile: ${{ matrix.uiTestFile }} - port: ${{ matrix.port }} - container: ${{ matrix.container }} - enableDapr: ${{ matrix.enableDapr }} - images: ${{ matrix.images }} - directories: ${{ matrix.directories }} - credential: ${{ matrix.credential }} - strategy: - fail-fast: false - matrix: - include: - - name: demo - os: ubuntu-latest - runOnPullRequest: true - app: demo - env: default - path: ./samples/demo/app.bicep - deployArgs: --application demo -p image=sampleregistry:5000/samples/demo - exposeArgs: --application demo - uiTestFile: tests/demo/demo.app.spec.ts - port: 3000 - container: demo - enableDapr: false - images: samples/demo - directories: samples/demo/ - - name: dapr - os: ubuntu-latest-m - runOnPullRequest: true - app: dapr - env: default - path: ./samples/dapr/dapr.bicep - deployArgs: -p frontendImage=sampleregistry:5000/samples/dapr-frontend -p backendImage=sampleregistry:5000/samples/dapr-backend - enableDapr: true - images: samples/dapr-frontend,samples/dapr-backend - directories: samples/dapr/ui/,samples/dapr/nodeapp/ - - name: volumes - os: ubuntu-latest - runOnPullRequest: true - app: myapp - env: default - path: ./samples/volumes/app.bicep - deployArgs: -p image=sampleregistry:5000/samples/volumes - enableDapr: false - images: samples/volumes - directories: samples/volumes/ - - name: eshop-containers - os: ubuntu-latest-m - runOnPullRequest: true - app: eshop - env: default - path: ./samples/eshop/eshop.bicep - uiTestFile: tests/eshop/eshop.app.spec.ts - enableDapr: false - - name: eshop-azure - os: ubuntu-latest-m - runOnPullRequest: true - app: eshop - env: azure - path: ./samples/eshop/eshop.bicep - uiTestFile: tests/eshop/eshop.app.spec.ts - credential: azure - enableDapr: false - - name: eshop-aws - os: ubuntu-latest-m - runOnPullRequest: false - app: eshop - env: aws - path: ./samples/eshop/eshop.bicep - uiTestFile: tests/eshop/eshop.app.spec.ts - credential: aws - enableDapr: false + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: demo + os: ubuntu-latest + runOnPullRequest: true + app: demo + env: default + path: ./samples/demo/app.bicep + deployArgs: --application demo -p image=sampleregistry:5000/samples/demo + exposeArgs: --application demo + uiTestFile: tests/demo/demo.app.spec.ts + port: 3000 + container: demo + enableDapr: false + images: samples/demo + directories: samples/demo/ + test-dapr: + name: Test Dapr Application + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: dapr + os: ubuntu-latest-m + runOnPullRequest: true + app: dapr + env: default + path: ./samples/dapr/dapr.bicep + deployArgs: -p frontendImage=sampleregistry:5000/samples/dapr-frontend -p backendImage=sampleregistry:5000/samples/dapr-backend + enableDapr: true + images: samples/dapr-frontend,samples/dapr-backend + directories: samples/dapr/ui/,samples/dapr/nodeapp/ + test-volumes: + name: Test Volume Application + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: volumes + os: ubuntu-latest + runOnPullRequest: true + app: myapp + env: default + path: ./samples/volumes/app.bicep + deployArgs: -p image=sampleregistry:5000/samples/volumes + enableDapr: false + images: samples/volumes + directories: samples/volumes/ + test-eshop-containers: + name: Test eShop Application (Containers) + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: eshop-containers + os: ubuntu-latest-m + runOnPullRequest: true + app: eshop + env: default + path: ./samples/eshop/eshop.bicep + uiTestFile: tests/eshop/eshop.app.spec.ts + enableDapr: false + test-eshop-azure: + name: Test eShop Application (Containers) + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: eshop-azure + os: ubuntu-latest-m + runOnPullRequest: true + app: eshop + env: azure + path: ./samples/eshop/eshop.bicep + uiTestFile: tests/eshop/eshop.app.spec.ts + credential: azure + enableDapr: false + test-eshop-aws: + name: Test eShop Application (AWS) + uses: ./.github/workflows/run-test.yaml + with: + version: ${{ github.env.VERSION }} + run-identifier: ${{ github.env.RUN_IDENTIFIER }} + name: eshop-aws + os: ubuntu-latest-m + runOnPullRequest: false + app: eshop + env: aws + path: ./samples/eshop/eshop.bicep + uiTestFile: tests/eshop/eshop.app.spec.ts + credential: aws + enableDapr: false From e916a28f76d469f952c3f3bd2e12de694cf2165c Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 30 Jul 2024 10:52:01 -0700 Subject: [PATCH 7/8] test Signed-off-by: willdavsmith --- .github/scripts/generate-test-variables.sh | 37 ---------------------- .github/workflows/run-test.yaml | 4 +++ .github/workflows/test.yaml | 14 ++++---- 3 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 .github/scripts/generate-test-variables.sh diff --git a/.github/scripts/generate-test-variables.sh b/.github/scripts/generate-test-variables.sh deleted file mode 100644 index 14eac861..00000000 --- a/.github/scripts/generate-test-variables.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# ------------------------------------------------------------ -# Copyright 2023 The Radius 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. -# ------------------------------------------------------------ - -set -ex - -MATRIX=$1 -RUN_IDENTIFIER=$2 - -MATRIX=${{ fromJSON(inputs.matrix) }} -RUN_IDENTIFIER=${{ inputs.RUN_IDENTIFIER }}- - -if [[ "${{ matrix.enableDapr }}" == "true" ]]; then - ENABLE_DAPR=true -else - ENABLE_DAPR=false -fi - -# Set output variables to be used in the other jobs -echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT -echo "TEST_AZURE_RESOURCE_GROUP=rg-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT -echo "TEST_EKS_CLUSTER_NAME=eks-${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT -echo "ENABLE_DAPR=${ENABLE_DAPR}" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml index b8f34d70..daaec11e 100644 --- a/.github/workflows/run-test.yaml +++ b/.github/workflows/run-test.yaml @@ -58,6 +58,7 @@ on: type: string jobs: test: + name: Test Sample Application runs-on: ${{ inputs.os }} env: BRANCH: ${{ github.base_ref || github.ref_name }} @@ -240,6 +241,9 @@ jobs: npm ci npx playwright install --with-deps npx playwright test ${{ inputs.uiTestFile }} --retries 3 + + kubectl get pods -A + kubectl describe pods -A - name: Upload Playwright Results uses: actions/upload-artifact@v4 if: always() && (steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure') diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d123fb05..a6a6ebeb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ on: schedule: # Run every day at 12 PM - cron: "0 12 * * *" env: - VERSION: ${{ github.env.VERSION }} + VERSION: ${{ github.env.VERSION }} RUN_IDENTIFIER: samplestest-${{ github.run_id }}-${{ github.run_attempt }} jobs: test-demo: @@ -50,7 +50,7 @@ jobs: name: Test Dapr Application uses: ./.github/workflows/run-test.yaml with: - version: ${{ github.env.VERSION }} + version: ${{ github.env.VERSION }} run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: dapr os: ubuntu-latest-m @@ -66,7 +66,7 @@ jobs: name: Test Volume Application uses: ./.github/workflows/run-test.yaml with: - version: ${{ github.env.VERSION }} + version: ${{ github.env.VERSION }} run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: volumes os: ubuntu-latest @@ -82,7 +82,7 @@ jobs: name: Test eShop Application (Containers) uses: ./.github/workflows/run-test.yaml with: - version: ${{ github.env.VERSION }} + version: ${{ github.env.VERSION }} run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: eshop-containers os: ubuntu-latest-m @@ -93,10 +93,10 @@ jobs: uiTestFile: tests/eshop/eshop.app.spec.ts enableDapr: false test-eshop-azure: - name: Test eShop Application (Containers) + name: Test eShop Application (Azure) uses: ./.github/workflows/run-test.yaml with: - version: ${{ github.env.VERSION }} + version: ${{ github.env.VERSION }} run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: eshop-azure os: ubuntu-latest-m @@ -111,7 +111,7 @@ jobs: name: Test eShop Application (AWS) uses: ./.github/workflows/run-test.yaml with: - version: ${{ github.env.VERSION }} + version: ${{ github.env.VERSION }} run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: eshop-aws os: ubuntu-latest-m From 1771d3e81e92c59df37afab2b8a84e956afdf54d Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Mon, 5 Aug 2024 10:33:49 -0700 Subject: [PATCH 8/8] test Signed-off-by: willdavsmith --- .github/workflows/run-test.yaml | 6 +++-- .github/workflows/test.yaml | 2 +- samples.generated.sln | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 samples.generated.sln diff --git a/.github/workflows/run-test.yaml b/.github/workflows/run-test.yaml index daaec11e..b992b1f2 100644 --- a/.github/workflows/run-test.yaml +++ b/.github/workflows/run-test.yaml @@ -58,7 +58,7 @@ on: type: string jobs: test: - name: Test Sample Application + name: ${{ inputs.name }} runs-on: ${{ inputs.os }} env: BRANCH: ${{ github.base_ref || github.ref_name }} @@ -241,7 +241,9 @@ jobs: npm ci npx playwright install --with-deps npx playwright test ${{ inputs.uiTestFile }} --retries 3 - + - name: TEST + if: always() + run: | kubectl get pods -A kubectl describe pods -A - name: Upload Playwright Results diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a6a6ebeb..4ab64a18 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -100,7 +100,7 @@ jobs: run-identifier: ${{ github.env.RUN_IDENTIFIER }} name: eshop-azure os: ubuntu-latest-m - runOnPullRequest: true + runOnPullRequest: false app: eshop env: azure path: ./samples/eshop/eshop.bicep diff --git a/samples.generated.sln b/samples.generated.sln new file mode 100644 index 00000000..b06ee3ff --- /dev/null +++ b/samples.generated.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9FECD800-787B-43AB-91AB-1FCA6D8C706B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "aws", "samples\aws\aws.csproj", "{B888C9C2-A702-4C85-B79D-A6B78A502EC5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dapr", "dapr", "{8D89BA31-9946-4CBE-83E8-C58B235718B0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ui", "samples\dapr\ui\ui.csproj", "{2F991A30-981C-42C1-8CDF-B27E7BD19885}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B888C9C2-A702-4C85-B79D-A6B78A502EC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B888C9C2-A702-4C85-B79D-A6B78A502EC5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B888C9C2-A702-4C85-B79D-A6B78A502EC5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B888C9C2-A702-4C85-B79D-A6B78A502EC5}.Release|Any CPU.Build.0 = Release|Any CPU + {2F991A30-981C-42C1-8CDF-B27E7BD19885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F991A30-981C-42C1-8CDF-B27E7BD19885}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F991A30-981C-42C1-8CDF-B27E7BD19885}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F991A30-981C-42C1-8CDF-B27E7BD19885}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {B888C9C2-A702-4C85-B79D-A6B78A502EC5} = {9FECD800-787B-43AB-91AB-1FCA6D8C706B} + {8D89BA31-9946-4CBE-83E8-C58B235718B0} = {9FECD800-787B-43AB-91AB-1FCA6D8C706B} + {2F991A30-981C-42C1-8CDF-B27E7BD19885} = {8D89BA31-9946-4CBE-83E8-C58B235718B0} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0F0C3D93-3216-4F82-ADD1-7D9A7A48DEDC} + EndGlobalSection +EndGlobal