From bface4ba4c9d254a3ebe9573b24ff246526bcae1 Mon Sep 17 00:00:00 2001 From: ytimocin Date: Tue, 9 Jul 2024 14:50:40 -0700 Subject: [PATCH] Fixing a format issue Signed-off-by: ytimocin --- .../actions/process-test-results/action.yaml | 18 +- .../scripts/publish-test-terraform-recipes.py | 18 +- ...l-test.yaml => functional-test-cloud.yaml} | 79 +-- .../workflows/functional-test-noncloud.yaml | 461 +++--------------- .github/workflows/long-running-azure.yaml | 10 +- build/recipes.mk | 1 - build/test.mk | 2 +- .../cloud/resources/microsoftsql_test.go | 1 + .../cloud/resources/mongodb_test.go | 72 +++ .../cloud/resources/redis_test.go | 101 ++++ ...atastoresrp-resources-mongodb-recipe.bicep | 18 +- ...resrp-resources-redis-default-recipe.bicep | 0 .../datastoresrp-resources-redis-recipe.bicep | 12 +- .../noncloud/resources/mongodb_test.go | 46 -- .../noncloud/resources/redis_test.go | 75 --- ...srp-resources-mongodb-recipe-context.bicep | 83 ---- .../datastoresrp-resources-redis-manual.bicep | 6 +- ...oresrp-resources-simulatedenv-recipe.bicep | 18 +- .../datastoresrp-resources-sqldb-manual.bicep | 2 +- .../datastoresrp-rs-mongodb-manual.bicep | 2 - 20 files changed, 345 insertions(+), 680 deletions(-) rename .github/workflows/{functional-test.yaml => functional-test-cloud.yaml} (95%) create mode 100644 test/functional-portable/datastoresrp/cloud/resources/mongodb_test.go create mode 100644 test/functional-portable/datastoresrp/cloud/resources/redis_test.go rename test/functional-portable/datastoresrp/{noncloud => cloud}/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep (83%) rename test/functional-portable/datastoresrp/{noncloud => cloud}/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep (100%) rename test/functional-portable/datastoresrp/{noncloud => cloud}/resources/testdata/datastoresrp-resources-redis-recipe.bicep (79%) delete mode 100644 test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep diff --git a/.github/actions/process-test-results/action.yaml b/.github/actions/process-test-results/action.yaml index 4ed388cd6a4..43463d5b546 100644 --- a/.github/actions/process-test-results/action.yaml +++ b/.github/actions/process-test-results/action.yaml @@ -10,30 +10,30 @@ description: | test results format which is what we require. GOTESTSUM_OPTS: '--junitfile ./dist/unit_test_results_raw.xml' - + Then running 'make ' will do the right thing :) inputs: test_group_name: - description: 'Name to use for reporting (eg: Unit Tests)' + description: "Name to use for reporting (eg: Unit Tests)" required: true artifact_name: - description: 'Name to use for uploading artifacts (eg: unit_test_results)' + description: "Name to use for uploading artifacts (eg: unit_test_results)" required: true result_directory: - description: 'Directory containing result XML files. These should be in jUnit format. See the description of the action.' + description: "Directory containing result XML files. These should be in jUnit format. See the description of the action." required: true runs: using: "composite" steps: # The test results file output by gotestsum is missing file and line number on the XML elements # which is needed for the annotations to work. This script adds the missing information. - - name: 'Transform ${{ inputs.test_group_name }} Results' + - name: "Transform ${{ inputs.test_group_name }} Results" # Always is REQUIRED here. Otherwise, the action will be skipped when the unit tests fail, which # defeats the purpose. YES it is counterintuitive. This applies to all of the actions in this file. if: always() - id: 'process_files' - shell: 'bash' + id: "process_files" + shell: "bash" working-directory: ${{ github.workspace }} env: INPUT_DIRECTORY: ${{ inputs.result_directory }} @@ -52,14 +52,14 @@ runs: python3 ./.github/scripts/transform_test_results.py $GITHUB_WORKSPACE "$INPUT_FILE" "$OUTPUT_FILE" echo "wrote ${OUTPUT_FILE}" done - - name: 'Create ${{ inputs.test_group_name }} Result Report' + - name: "Create ${{ inputs.test_group_name }} Result Report" uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: check_name: ${{ inputs.test_group_name }} files: | ${{ inputs.result_directory }}/processed/*.xml - - name: 'Upload ${{ inputs.test_group_name }} Results' + - name: "Upload ${{ inputs.test_group_name }} Results" uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/scripts/publish-test-terraform-recipes.py b/.github/scripts/publish-test-terraform-recipes.py index 5b272036c78..15a64d907cf 100755 --- a/.github/scripts/publish-test-terraform-recipes.py +++ b/.github/scripts/publish-test-terraform-recipes.py @@ -5,7 +5,7 @@ # 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 @@ -35,13 +35,14 @@ # Write output to stdout all of the time, and the step summary if we're in Github Actions. step_summary = os.getenv("GITHUB_STEP_SUMMARY") with open(step_summary, "a") if step_summary else contextlib.suppress() as output: - + def log(message): print(message, flush=True) if step_summary: output.write(message + "\n") - log("Publishing recipes from " + recipe_root + " to " + namespace + "/" + config_map_name) + log("Publishing recipes from " + recipe_root + + " to " + namespace + "/" + config_map_name) # Get the list of subfolders in the recipe root. Each one is a recipe. recipe_dirs = [f.path for f in os.scandir(recipe_root) if f.is_dir()] @@ -60,22 +61,25 @@ def log(message): log("Processing recipe: " + recipe_dir) # Make the zip. - output_filename = shutil.make_archive(os.path.join(tmp_dir, os.path.basename(recipe_dir)), 'zip', recipe_dir) + output_filename = shutil.make_archive(os.path.join( + tmp_dir, os.path.basename(recipe_dir)), 'zip', recipe_dir) log("Created zip file: " + output_filename) # Add to config entries config_entries[os.path.basename(recipe_dir)] = output_filename # Delete the configmap if it already exists - args = ["kubectl", "delete", "configmap", config_map_name, "--namespace", namespace, "--ignore-not-found=true"] + args = ["kubectl", "delete", "configmap", config_map_name, + "--namespace", namespace, "--ignore-not-found=true"] process = subprocess.run(args) process.check_returncode() # Create the configmap - args = ["kubectl", "create", "configmap", config_map_name, "--namespace", namespace] + args = ["kubectl", "create", "configmap", + config_map_name, "--namespace", namespace] for recipe_name, zip_file in config_entries.items(): args.append("--from-file=" + recipe_name + ".zip=" + zip_file) process = subprocess.run(args) process.check_returncode() - log("Created configmap: " + namespace + "/" + config_map_name) \ No newline at end of file + log("Created configmap: " + namespace + "/" + config_map_name) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test-cloud.yaml similarity index 95% rename from .github/workflows/functional-test.yaml rename to .github/workflows/functional-test-cloud.yaml index d522955fe5a..71a8e0aa05f 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test-cloud.yaml @@ -4,7 +4,7 @@ # 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 @@ -14,12 +14,13 @@ # limitations under the License. # ------------------------------------------------------------ -name: Functional tests +name: Functional Tests (with Cloud Resources) permissions: id-token: write # Required for requesting the JWT - contents: read # Required for listing the commits + contents: read # Required for listing the commits packages: write # Required for uploading the package + checks: write # Required for creating a check run on: # Enable manual trigger @@ -33,31 +34,31 @@ on: repository_dispatch: types: [de-functional-test] workflow_run: - workflows: ['Approve Functional Tests'] + workflows: ["Approve Functional Tests"] types: - completed env: # Go version - GOVER: '1.22.2' + GOVER: "1.22.2" GOPROXY: https://proxy.golang.org # gotestsum version - see: https://github.com/gotestyourself/gotestsum - GOTESTSUM_VER: 1.10.0 + GOTESTSUM_VER: 1.12.0 # Helm version - HELM_VER: 'v3.12.0' + HELM_VER: "v3.12.0" # KinD cluster version - KIND_VER: 'v0.20.0' + KIND_VER: "v0.20.0" # Dapr version - DAPR_VER: '1.12.0' - DAPR_DASHBOARD_VER: '0.14.0' + DAPR_VER: "1.12.0" + DAPR_DASHBOARD_VER: "0.14.0" # Kubectl version - KUBECTL_VER: 'v1.25.0' + KUBECTL_VER: "v1.25.0" # Azure Keyvault CSI driver chart version - AZURE_KEYVAULT_CSI_DRIVER_VER: '1.4.2' + AZURE_KEYVAULT_CSI_DRIVER_VER: "1.4.2" # Azure workload identity webhook chart version - AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: '1.1.0' + AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: "1.1.0" # Container registry for storing container images CONTAINER_REGISTRY: ghcr.io/radius-project/dev # Container registry for storing Bicep recipe artifacts @@ -71,11 +72,11 @@ env: # The Radius helm chart location. RADIUS_CHART_LOCATION: deploy/Chart/ # The region for AWS resources - AWS_REGION: 'us-west-2' + AWS_REGION: "us-west-2" # The AWS account ID - AWS_ACCOUNT_ID: '${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}' + AWS_ACCOUNT_ID: "${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}" # The current GitHub action link - ACTION_LINK: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + ACTION_LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Server where terraform test modules are deployed TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" # The functional test GitHub app id @@ -91,8 +92,8 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || github.event_name == 'workflow_run' env: - DE_IMAGE: 'ghcr.io/radius-project/deployment-engine' - DE_TAG: 'latest' + DE_IMAGE: "ghcr.io/radius-project/deployment-engine" + DE_TAG: "latest" outputs: REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }} UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }} @@ -106,7 +107,7 @@ jobs: - name: Get GitHub app token uses: tibdex/github-app-token@v2 id: get_installation_token - with: + with: app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - name: Set up checkout target (scheduled) @@ -117,16 +118,16 @@ jobs: - name: Set up checkout target (pull_request) if: github.event_name == 'pull_request' run: | - echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - name: Use custom actions uses: actions/checkout@v4 - - name: 'Download PR data artifacts' + - name: "Download PR data artifacts" if: github.event_name == 'workflow_run' uses: ./.github/actions/download-pr-data-artifact id: get-pr-number - - name: 'Set PR context (workflow_run)' + - name: "Set PR context (workflow_run)" if: github.event_name == 'workflow_run' uses: actions/github-script@v7 with: @@ -175,7 +176,7 @@ jobs: fi UNIQUE_ID=func$(echo $BASE_STR | sha1sum | head -c 10) echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV - + # Set output variables to be used in the other jobs echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT echo "UNIQUE_ID=${UNIQUE_ID}" >> $GITHUB_OUTPUT @@ -194,7 +195,7 @@ jobs: header: teststatus-${{ github.run_id }} number: ${{ env.PR_NUMBER }} hide: true - hide_classify: 'OUTDATED' + hide_classify: "OUTDATED" message: | ## Radius functional test overview @@ -223,7 +224,7 @@ jobs: * deployment-engine test image location: `${{ env.DE_IMAGE }}:${{ env.DE_TAG }}` - + ## Test Status - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -345,14 +346,14 @@ jobs: - name: Get GitHub app token uses: tibdex/github-app-token@v2 id: get_installation_token - with: + with: app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - uses: LouisBrunner/checks-action@v2.0.0 if: always() with: token: ${{ steps.get_installation_token.outputs.token }} - name: 'Functional Test Run' + name: "Functional Test Run" status: in_progress repo: ${{ github.repository }} sha: ${{ env.CHECKOUT_REF }} @@ -577,15 +578,15 @@ jobs: BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} GH_TOKEN: ${{ steps.get_installation_token.outputs.token }} - GOTESTSUM_OPTS: '--junitfile ./dist/functional_test/results.xml' + GOTESTSUM_OPTS: "--junitfile ./dist/functional_test/results.xml" - name: Process Functional Test Results uses: ./.github/actions/process-test-results # In case of failure, upload functional_test_results to artifacts so that they are not erased by subsequent runs. if: failure() && github.repository == 'radius-project/radius' with: - test_group_name: 'Functional Tests - ${{ matrix.name }}' - artifact_name: 'functional_test_results_${{ matrix.name }}' - result_directory: 'dist/functional_test/' + test_group_name: "Functional Tests - ${{ matrix.name }}" + artifact_name: "functional_test_results_${{ matrix.name }}" + result_directory: "dist/functional_test/" - uses: azure/setup-kubectl@v4 if: always() with: @@ -620,7 +621,7 @@ jobs: echo "Pod logs saved to recipes/pod-logs/" # Get kubernetes events and save to file kubectl get events -n $namespace > recipes/pod-logs/events.txt - - name: Upload Terraform recipe publishing logs + - name: Upload Terraform recipe publishing logs uses: actions/upload-artifact@v4 if: always() with: @@ -676,7 +677,7 @@ jobs: - name: Get GitHub app token uses: tibdex/github-app-token@v2 id: get_installation_token - with: + with: app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - name: Get tests job status @@ -703,7 +704,7 @@ jobs: if: always() with: token: ${{ steps.get_installation_token.outputs.token }} - name: 'Functional Test Run' + name: "Functional Test Run" repo: ${{ github.repository }} sha: ${{ env.CHECKOUT_REF }} status: completed @@ -725,11 +726,11 @@ jobs: response = await github.rest.actions.listWorkflowRuns({ owner: context.repo.owner, repo: context.repo.repo, - workflow_id: 'functional-test.yaml', + workflow_id: 'functional-test-cloud.yaml', event: 'schedule', per_page: 10 }); - + failureCount = 1; for (const run of response.data.workflow_runs) { if (run.conclusion === 'failure') { @@ -751,4 +752,4 @@ jobs: title: `Scheduled functional test failed - Run ID: ${context.runId}`, labels: ['bug', 'test-failure'], body: `## Bug information \n\nThis bug is generated automatically if the scheduled functional test fails at least ${process.env.ISSUE_CREATE_THRESHOLD} times in a row. The Radius functional test operates on a schedule of every 4 hours during weekdays and every 12 hours over the weekend. It's important to understand that the test may fail due to workflow infrastructure issues, like network problems, rather than the flakiness of the test itself. For the further investigation, please visit [here](${process.env.ACTION_LINK}).` - }) \ No newline at end of file + }) diff --git a/.github/workflows/functional-test-noncloud.yaml b/.github/workflows/functional-test-noncloud.yaml index dcf4ab26cca..881961cd7ae 100644 --- a/.github/workflows/functional-test-noncloud.yaml +++ b/.github/workflows/functional-test-noncloud.yaml @@ -14,12 +14,13 @@ # limitations under the License. # ------------------------------------------------------------ -name: Functional tests - Non-Cloud +name: Functional Tests (with Non-Cloud Resources) permissions: id-token: write # Required for requesting the JWT contents: read # Required for listing the commits packages: write # Required for uploading the package + checks: write # Required for creating a check run on: # Enable manual trigger @@ -47,28 +48,20 @@ on: env: # Go version GOVER: "1.22.2" - # Go proxy - GOPROXY: https://proxy.golang.org - # gotestsum version - see: https://github.com/gotestyourself/gotestsum - GOTESTSUM_VER: 1.10.0 # Helm version HELM_VER: "v3.12.0" # KinD cluster version - KIND_VER: "v0.20.0" + KIND_VER: "v0.23.0" # Dapr version DAPR_VER: "1.12.0" # Dapr dashboard version DAPR_DASHBOARD_VER: "0.14.0" # Kubectl version KUBECTL_VER: "v1.25.0" - # Azure Keyvault CSI driver chart version - AZURE_KEYVAULT_CSI_DRIVER_VER: "1.4.2" - # Azure workload identity webhook chart version - AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: "1.1.0" # Container registry for storing container images - CONTAINER_REGISTRY: ghcr.io/radius-project/dev + CONTAINER_REGISTRY: ghcr.io/${{ github.repository_owner }}/dev # Container registry for storing Bicep recipe artifacts - BICEP_RECIPE_REGISTRY: ghcr.io/radius-project/dev + BICEP_RECIPE_REGISTRY: ghcr.io/${{ github.repository_owner }}/dev # The radius functional test timeout FUNCTIONALTEST_TIMEOUT: 30m # The base directory for storing test logs @@ -79,8 +72,6 @@ env: ACTION_LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Server where terraform test modules are deployed TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" - # The functional test GitHub app id - FUNCTIONAL_TEST_APP_ID: 425843 # Private Git repository where terraform module for testing is stored. TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules//kubernetes-redis" # The number of failed tests to report. @@ -95,39 +86,9 @@ jobs: DE_TAG: "latest" outputs: REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }} - UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }} - PR_NUMBER: ${{ steps.gen-id.outputs.PR_NUMBER }} - CHECKOUT_REPO: ${{ steps.gen-id.outputs.CHECKOUT_REPO }} - CHECKOUT_REF: ${{ steps.gen-id.outputs.CHECKOUT_REF }} - RAD_CLI_ARTIFACT_NAME: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} DE_IMAGE: ${{ steps.gen-id.outputs.DE_IMAGE }} DE_TAG: ${{ steps.gen-id.outputs.DE_TAG }} steps: - - name: Get GitHub app token - uses: tibdex/github-app-token@v2 - id: get_installation_token - with: - app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} - private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - - name: Set up checkout target (scheduled) - if: github.event_name == 'schedule' - run: | - echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV - - name: Set up checkout target (pull_request) - if: github.event_name == 'pull_request' - run: | - echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - - name: Use custom actions - uses: actions/checkout@v4 - - name: Set up checkout target (pull_request) - if: github.event_name == 'pull_request' - run: | - echo "CHECKOUT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - name: Set DE image and tag (repository_dispatch from de-functional-test) if: github.event_name == 'repository_dispatch' uses: actions/github-script@v7 @@ -145,15 +106,13 @@ jobs: `CHECKOUT_REF=refs/heads/main` ); } + - name: Check out code uses: actions/checkout@v4 with: repository: ${{ env.CHECKOUT_REPO }} ref: ${{ env.CHECKOUT_REF }} - - name: Set up Go ${{ env.GOVER }} - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GOVER }} + - name: Generate ID for release id: gen-id run: | @@ -163,148 +122,13 @@ jobs: BASE_STR="${GITHUB_RUN_NUMBER}|${BASE_STR}" fi UNIQUE_ID=func$(echo $BASE_STR | sha1sum | head -c 10) - # `-nc` stands for non-cloud. echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV # Set output variables to be used in the other jobs echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT - echo "UNIQUE_ID=${UNIQUE_ID}" >> $GITHUB_OUTPUT - echo "CHECKOUT_REPO=${{ env.CHECKOUT_REPO }}" >> $GITHUB_OUTPUT - echo "CHECKOUT_REF=${{ env.CHECKOUT_REF }}" >> $GITHUB_OUTPUT - echo "RAD_CLI_ARTIFACT_NAME=rad_cli_linux_amd64" >> $GITHUB_OUTPUT - echo "PR_NUMBER=${{ env.PR_NUMBER }}" >> $GITHUB_OUTPUT echo "DE_IMAGE=${{ env.DE_IMAGE }}" >> $GITHUB_OUTPUT echo "DE_TAG=${{ env.DE_TAG }}" >> $GITHUB_OUTPUT - - uses: marocchino/sticky-pull-request-comment@v2 - if: env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - hide: true - hide_classify: "OUTDATED" - message: | - ## Radius functional test (non-cloud) overview - - :mag: **[Go to test action run](${{ env.ACTION_LINK }})** - - | Name | Value | - |------|-------| - |**Repository** | ${{ steps.gen-id.outputs.CHECKOUT_REPO }} | - |**Commit ref** | ${{ steps.gen-id.outputs.CHECKOUT_REF }} | - |**Unique ID** | ${{ steps.gen-id.outputs.UNIQUE_ID }} | - |**Image tag** | ${{ steps.gen-id.outputs.REL_VERSION }} | - -
- Click here to see the list of tools in the current test run - - * gotestsum ${{ env.GOTESTSUM_VER }} - * KinD: ${{ env.KIND_VER }} - * Dapr: ${{ env.DAPR_VER }} - * Azure KeyVault CSI driver: ${{ env.AZURE_KEYVAULT_CSI_DRIVER_VER }} - * Azure Workload identity webhook: ${{ env.AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER }} - * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/:${{ env.REL_VERSION }}` - * Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/.zip` (in cluster) - * applications-rp test image location: `${{ env.CONTAINER_REGISTRY }}/applications-rp:${{ env.REL_VERSION }}` - * controller test image location: `${{ env.CONTAINER_REGISTRY }}/controller:${{ env.REL_VERSION }}` - * ucp test image location: `${{ env.CONTAINER_REGISTRY }}/ucpd:${{ env.REL_VERSION }}` - * deployment-engine test image location: `${{ env.DE_IMAGE }}:${{ env.DE_TAG }}` - -
- - ## Test Status - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: marocchino/sticky-pull-request-comment@v2 - if: env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :hourglass: Building Radius and pushing container images for functional tests... - - name: Build and Push container images - run: | - make build && make docker-build && make docker-push - env: - DOCKER_REGISTRY: ${{ env.CONTAINER_REGISTRY }} - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - - name: Upload CLI binary - uses: actions/upload-artifact@v4 - with: - name: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} - path: | - ./dist/linux_amd64/release/rad - - uses: marocchino/sticky-pull-request-comment@v2 - if: success() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :white_check_mark: Container images build succeeded - - uses: marocchino/sticky-pull-request-comment@v2 - if: failure() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :x: Container images build failed - - uses: marocchino/sticky-pull-request-comment@v2 - if: env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :hourglass: Publishing Bicep Recipes for functional tests... - - name: Publish Bicep Test Recipes - run: | - mkdir ./bin - cp ./dist/linux_amd64/release/rad ./bin/rad - chmod +x ./bin/rad - export PATH=$GITHUB_WORKSPACE/bin:$PATH - which rad || { echo "cannot find rad"; exit 1; } - rad bicep download - rad version - make publish-test-bicep-recipes - env: - BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} - BICEP_RECIPE_TAG_VERSION: ${{ env.REL_VERSION }} - - uses: marocchino/sticky-pull-request-comment@v2 - if: success() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :white_check_mark: Recipe publishing succeeded - - uses: marocchino/sticky-pull-request-comment@v2 - if: failure() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :x: Test recipe publishing failed + tests: name: Run ${{ matrix.name }} functional tests needs: build @@ -317,55 +141,48 @@ jobs: cli-noncloud, corerp-noncloud, daprrp-noncloud, - datastoresrp-noncloud, kubernetes-noncloud, msgrp-noncloud, samples-noncloud, ucp-noncloud, + datastoresrp-noncloud, ] runs-on: ${{ matrix.os }} env: - UNIQUE_ID: ${{ needs.build.outputs.UNIQUE_ID }} REL_VERSION: ${{ needs.build.outputs.REL_VERSION }} - CHECKOUT_REPO: ${{ needs.build.outputs.CHECKOUT_REPO }} - CHECKOUT_REF: ${{ needs.build.outputs.CHECKOUT_REF }} - PR_NUMBER: ${{ needs.build.outputs.PR_NUMBER }} - RAD_CLI_ARTIFACT_NAME: ${{ needs.build.outputs.RAD_CLI_ARTIFACT_NAME }} BICEP_RECIPE_TAG_VERSION: ${{ needs.build.outputs.REL_VERSION }} DE_IMAGE: ${{ needs.build.outputs.DE_IMAGE }} DE_TAG: ${{ needs.build.outputs.DE_TAG }} steps: - - name: Get GitHub app token - uses: tibdex/github-app-token@v2 - id: get_installation_token - with: - app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} - private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - - uses: LouisBrunner/checks-action@v2.0.0 - if: always() - with: - token: ${{ steps.get_installation_token.outputs.token }} - name: "Functional Test Run" - status: in_progress - repo: ${{ github.repository }} - sha: ${{ env.CHECKOUT_REF }} - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - - name: Checkout + - name: Set up checkout target (scheduled) + if: github.event_name == 'schedule' + run: | + echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV + + - name: Set up checkout target (pull_request) + if: github.event_name == 'pull_request' + run: | + echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + + - name: Use custom actions uses: actions/checkout@v4 - with: - repository: ${{ env.CHECKOUT_REPO }} - ref: ${{ env.CHECKOUT_REF }} + - name: Checkout samples repo uses: actions/checkout@v4 - if: matrix.name == 'samples' + if: matrix.name == 'samples-noncloud' with: repository: radius-project/samples ref: refs/heads/edge path: samples + - name: Set up Go ${{ env.GOVER }} uses: actions/setup-go@v5 with: go-version: ${{ env.GOVER }} + - name: Get Go Cache path id: go-cache-paths run: | @@ -374,6 +191,7 @@ jobs: echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT sudo rm -rf $(go env GOMODCACHE) + - uses: actions/cache@v4 with: path: | @@ -382,108 +200,50 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - name: Download rad CLI - uses: actions/download-artifact@v4 - with: - name: ${{ env.RAD_CLI_ARTIFACT_NAME }} - path: bin - - name: Login to Azure - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_SP_TESTS_APPID }} - tenant-id: ${{ secrets.AZURE_SP_TESTS_TENANTID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} - - uses: marocchino/sticky-pull-request-comment@v2 - continue-on-error: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :hourglass: Starting ${{ matrix.name }} functional tests... + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push container images + run: | + make build && make docker-build && make docker-push + env: + DOCKER_REGISTRY: ${{ env.CONTAINER_REGISTRY }} + DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} + + - name: Install rad CLI + run: | + mkdir ./bin + cp ./dist/linux_amd64/release/rad ./bin/rad + chmod +x ./bin/rad + export PATH=$GITHUB_WORKSPACE/bin:$PATH + which rad || { echo "cannot find rad"; exit 1; } + rad bicep download + rad version + - uses: azure/setup-helm@v4 with: version: ${{ env.HELM_VER }} + - name: Create KinD cluster run: | curl -sSLo "kind" "https://github.com/kubernetes-sigs/kind/releases/download/${{ env.KIND_VER }}/kind-linux-amd64" chmod +x ./kind - # Populate the following environment variables for Azure workload identity from secrets. - # AZURE_OIDC_ISSUER_PUBLIC_KEY - # AZURE_OIDC_ISSUER_PRIVATE_KEY - # AZURE_OIDC_ISSUER - eval "export $(echo "${{ secrets.FUNCTEST_AZURE_OIDC_JSON }}" | jq -r 'to_entries | map("\(.key)=\(.value)") | @sh')" - - AUTHKEY=$(echo -n "${{ github.actor }}:${{ secrets.GH_RAD_CI_BOT_PAT }}" | base64) - echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"${AUTHKEY}\"}}}" > "./ghcr_secret.json" - - # Create KinD cluster with OIDC Issuer keys - echo $AZURE_OIDC_ISSUER_PUBLIC_KEY | base64 -d > sa.pub - echo $AZURE_OIDC_ISSUER_PRIVATE_KEY | base64 -d > sa.key - cat < func-nc/radius-logs-events/${{ matrix.name }}/events.txt + - name: Upload Pod logs for failed tests uses: actions/upload-artifact@v4 if: always() && steps.radius-logs-events.outcome == 'success' @@ -585,6 +349,7 @@ jobs: path: func-nc/radius-logs-events/${{ matrix.name }} retention-days: 30 if-no-files-found: error + - name: Collect Pod details if: always() run: | @@ -594,12 +359,14 @@ jobs: kubectl get pods -A >> $POD_STATE_LOG_FILENAME echo "kubectl describe pods -A" >> $POD_STATE_LOG_FILENAME kubectl describe pods -A >> $POD_STATE_LOG_FILENAME + - name: Upload container logs if: always() uses: actions/upload-artifact@v4 with: name: ${{ matrix.name }}_container_logs path: ./${{ env.RADIUS_CONTAINER_LOG_BASE }} + - name: Get Terraform recipe publishing logs if: always() run: | @@ -615,6 +382,7 @@ jobs: echo "Pod logs saved to recipes/pod-logs/" # Get kubernetes events and save to file kubectl get events -n $namespace > recipes/pod-logs/events.txt + - name: Upload Terraform recipe publishing logs uses: actions/upload-artifact@v4 if: always() @@ -622,82 +390,7 @@ jobs: name: ${{ matrix.name }}_recipes-pod-logs path: recipes/pod-logs if-no-files-found: error - - uses: marocchino/sticky-pull-request-comment@v2 - if: success() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :white_check_mark: ${{ matrix.name }} functional tests succeeded - - uses: marocchino/sticky-pull-request-comment@v2 - if: failure() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :x: ${{ matrix.name }} functional test failed. Please check [the logs](${{ env.ACTION_LINK }}) for more details - - uses: marocchino/sticky-pull-request-comment@v2 - if: cancelled() && env.PR_NUMBER != '' - continue-on-error: true - with: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - header: teststatus-${{ github.run_id }} - number: ${{ env.PR_NUMBER }} - append: true - message: | - :x: ${{ matrix.name }} functional test cancelled. Please check [the logs](${{ env.ACTION_LINK }}) for more details - report-test-results: - name: Report test results - needs: [build, tests] - runs-on: ubuntu-latest - if: always() - env: - CHECKOUT_REF: ${{ needs.build.outputs.CHECKOUT_REF }} - steps: - - name: Get GitHub app token - uses: tibdex/github-app-token@v2 - id: get_installation_token - with: - app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} - private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - - name: Get tests job status - id: get_test_status - run: | - # from: https://github.com/orgs/community/discussions/26526#discussioncomment-3252209 - ALL_JOBS_STATUS=$(curl -X GET -s -u "admin:${{ steps.get_installation_token.outputs.token }}" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs | jq ".jobs[] | {job_status: .conclusion}") - echo "All jobs status: $ALL_JOBS_STATUS" - TEST_STATUS="success" - for job_status in $(echo "$ALL_JOBS_STATUS" | jq -r '.[]'); do - echo "Job Status: $job_status" - if [[ "$job_status" == "failure" ]]; then - echo "Found failed test. Setting test status to failure" - TEST_STATUS="failure" - break - elif [[ "$job_status" == "cancelled" ]]; then - echo "Found cancelled test. Setting test status to cancelled" - TEST_STATUS="cancelled" - fi - done - echo "Test Status: $TEST_STATUS" - echo "test_status=$TEST_STATUS" >> $GITHUB_OUTPUT - - uses: LouisBrunner/checks-action@v2.0.0 - if: always() - with: - token: ${{ steps.get_installation_token.outputs.token }} - name: "Functional Test Run" - repo: ${{ github.repository }} - sha: ${{ env.CHECKOUT_REF }} - status: completed - conclusion: ${{ steps.get_test_status.outputs.test_status }} - output: | - {"summary":"Functional Test run completed. See links for more information.","title":"Functional Test Run"} - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + report-failure: name: Report test failure needs: [build, tests] @@ -712,7 +405,7 @@ jobs: response = await github.rest.actions.listWorkflowRuns({ owner: context.repo.owner, repo: context.repo.repo, - workflow_id: 'functional-test.yaml', + workflow_id: 'functional-test-noncloud.yaml', event: 'schedule', per_page: 10 }); diff --git a/.github/workflows/long-running-azure.yaml b/.github/workflows/long-running-azure.yaml index 93cbd797a78..77743093840 100644 --- a/.github/workflows/long-running-azure.yaml +++ b/.github/workflows/long-running-azure.yaml @@ -34,13 +34,13 @@ # the previous build is still valid. If valid, the workflow skips the build steps # and uses the cached 'rad cli' for testing. # -# Grafana dashboard URL: https://radlrtest00-dashboard-e4ffc0cwggchdhba.wus3.grafana.azure.com +# Grafana dashboard URL: https://radlrtest00-dashboard-e4ffc0cwggchdhba.wus3.grafana.azure.com name: Long-running test on Azure permissions: id-token: write # Required for requesting the JWT - contents: read # Required for actions/checkout + contents: read # Required for actions/checkout packages: write # Required for uploading the package on: @@ -56,7 +56,7 @@ env: GOPROXY: https://proxy.golang.org # gotestsum version - see: https://github.com/gotestyourself/gotestsum - GOTESTSUM_VER: 1.10.0 + GOTESTSUM_VER: 1.12.0 # Container registry for storing container images CONTAINER_REGISTRY: ghcr.io/radius-project/dev @@ -313,7 +313,7 @@ jobs: - name: Get GitHub app token uses: tibdex/github-app-token@v2 id: get_installation_token - with: + with: app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }} private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }} - name: Checkout @@ -534,7 +534,7 @@ jobs: event: 'schedule', per_page: 10 }); - + failureCount = 1; for (const run of response.data.workflow_runs) { if (run.conclusion === 'failure') { diff --git a/build/recipes.mk b/build/recipes.mk index 60173f8a4f2..2584cc8b1b8 100644 --- a/build/recipes.mk +++ b/build/recipes.mk @@ -15,7 +15,6 @@ # ------------------------------------------------------------ BICEP_RECIPE_TAG_VERSION?=latest -RAD_BICEP_PATH?=$${HOME}/.rad/bin TERRAFORM_MODULE_SERVER_NAMESPACE=radius-test-tf-module-server TERRAFORM_MODULE_SERVER_DEPLOYMENT_NAME=tf-module-server diff --git a/build/test.mk b/build/test.mk index 06eca889e16..7db7d8e82c6 100644 --- a/build/test.mk +++ b/build/test.mk @@ -101,7 +101,7 @@ test-functional-cli-noncloud: ## Runs cli functional tests that do not require c test-functional-daprrp: test-functional-daprrp-noncloud ## Runs all Dapr RP functional tests (both cloud and non-cloud) test-functional-daprrp-noncloud: ## Runs Dapr RP functional tests that do not require cloud resources -CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional-portable/daprrp/noncloud/... -timeout ${TEST_TIMEOUT} -v -parallel 3 $(GOTEST_OPTS) + CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional-portable/daprrp/noncloud/... -timeout ${TEST_TIMEOUT} -v -parallel 3 $(GOTEST_OPTS) test-functional-datastoresrp: test-functional-datastoresrp-noncloud test-functional-datastoresrp-cloud ## Runs all Datastores RP functional tests (non-cloud and cloud) diff --git a/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go b/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go index 1b836fc42a4..57ad918316f 100644 --- a/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go +++ b/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go @@ -44,6 +44,7 @@ func Test_MicrosoftSQL_Manual(t *testing.T) { } else { t.Error("AZURE_MSSQL_USERNAME and AZURE_MSSQL_PASSWORD environment variable must be set to run this test.") } + mssqlresourceid := "mssqlresourceid=" + os.Getenv("AZURE_MSSQL_RESOURCE_ID") sqlDatabse := "database=" + os.Getenv("AZURE_MSSQL_DATABASE") sqlServer := "server=" + os.Getenv("AZURE_MSSQL_SERVER") diff --git a/test/functional-portable/datastoresrp/cloud/resources/mongodb_test.go b/test/functional-portable/datastoresrp/cloud/resources/mongodb_test.go new file mode 100644 index 00000000000..b176975655b --- /dev/null +++ b/test/functional-portable/datastoresrp/cloud/resources/mongodb_test.go @@ -0,0 +1,72 @@ +/* +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. +*/ + +package resource_test + +import ( + "testing" + + "github.com/radius-project/radius/test/rp" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/validation" +) + +// Test_MongoDB_Recipe validates: +// the creation of a mongoDB from a recipe that uses an Azure resource +func Test_MongoDB_Recipe(t *testing.T) { + template := "testdata/datastoresrp-resources-mongodb-recipe.bicep" + name := "dsrp-resources-mongodb-recipe" + appNamespace := "dsrp-resources-mongodb-recipe-app" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "dsrp-resources-mongodb-recipe-env", + Type: validation.EnvironmentsResource, + }, + { + Name: "dsrp-resources-mongodb-recipe", + Type: validation.ApplicationsResource, + App: name, + }, + { + Name: "mongodb-app-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "mongodb-db", + Type: validation.MongoDatabasesResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "mongodb-app-ctnr").ValidateLabels(false), + }, + }, + }, + }, + }) + + test.Test(t) +} diff --git a/test/functional-portable/datastoresrp/cloud/resources/redis_test.go b/test/functional-portable/datastoresrp/cloud/resources/redis_test.go new file mode 100644 index 00000000000..ffeb6b8eb51 --- /dev/null +++ b/test/functional-portable/datastoresrp/cloud/resources/redis_test.go @@ -0,0 +1,101 @@ +/* +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. +*/ + +package resource_test + +import ( + "context" + "strings" + "testing" + + "github.com/radius-project/radius/test/rp" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/validation" + "github.com/stretchr/testify/require" +) + +func Test_Redis_Recipe(t *testing.T) { + template := "testdata/datastoresrp-resources-redis-recipe.bicep" + name := "dsrp-resources-redis-recipe" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "dsrp-resources-env-recipe-env", + Type: validation.EnvironmentsResource, + }, + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "rds-recipe", + Type: validation.RedisCachesResource, + App: name, + }, + }, + }, + SkipObjectValidation: true, + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { + redis, err := test.Options.ManagementClient.GetResource(ctx, "Applications.Datastores/redisCaches", "rds-recipe") + require.NoError(t, err) + require.NotNil(t, redis) + status := redis.Properties["status"].(map[string]any) + recipe := status["recipe"].(map[string]interface{}) + require.Equal(t, "bicep", recipe["templateKind"].(string)) + templatePath := strings.Split(recipe["templatePath"].(string), ":")[0] + require.Equal(t, "ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed", templatePath) + }, + }, + }) + + test.Test(t) +} + +func Test_Redis_DefaultRecipe(t *testing.T) { + template := "testdata/datastoresrp-resources-redis-default-recipe.bicep" + name := "dsrp-resources-redis-default-recipe" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "dsrp-resources-env-default-recipe-env", + Type: validation.EnvironmentsResource, + }, + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "rds-default-recipe", + Type: validation.RedisCachesResource, + App: name, + }, + }, + }, + SkipObjectValidation: true, + }, + }) + + test.Test(t) +} diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep b/test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep similarity index 83% rename from test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep rename to test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep index ccdc10dd632..8495e68ef45 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep +++ b/test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep @@ -4,11 +4,11 @@ param rg string = resourceGroup().name param sub string = subscription().subscriptionId -param registry string +param registry string param version string -param magpieimage string +param magpieimage string resource env 'Applications.Core/environments@2023-10-01-preview' = { name: 'dsrp-resources-mongodb-recipe-env' @@ -25,10 +25,10 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { } } recipes: { - 'Applications.Datastores/mongoDatabases':{ + 'Applications.Datastores/mongoDatabases': { mongoazure: { templateKind: 'bicep' - templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' } } } @@ -42,8 +42,8 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = { environment: env.id extensions: [ { - kind: 'kubernetesNamespace' - namespace: 'dsrp-resources-mongodb-recipe-app' + kind: 'kubernetesNamespace' + namespace: 'dsrp-resources-mongodb-recipe-app' } ] } @@ -64,9 +64,9 @@ resource webapp 'Applications.Core/containers@2023-10-01-preview' = { env: { DBCONNECTION: recipedb.connectionString() } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 + readinessProbe: { + kind: 'httpGet' + containerPort: 3000 path: '/healthz' } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep b/test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep similarity index 100% rename from test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep rename to test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep b/test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep similarity index 79% rename from test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep rename to test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep index 99304a666aa..a97261e63f7 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep +++ b/test/functional-portable/datastoresrp/cloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep @@ -2,7 +2,7 @@ import radius as radius param scope string = resourceGroup().id -param registry string +param registry string param version string @@ -13,7 +13,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { compute: { kind: 'kubernetes' resourceId: 'self' - namespace: 'dsrp-resources-env-recipe-env' + namespace: 'dsrp-resources-env-recipe-env' } providers: { azure: { @@ -21,10 +21,10 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { } } recipes: { - 'Applications.Datastores/redisCaches':{ + 'Applications.Datastores/redisCaches': { rediscache: { templateKind: 'bicep' - templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' } } } @@ -38,8 +38,8 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = { environment: env.id extensions: [ { - kind: 'kubernetesNamespace' - namespace: 'dsrp-resources-redis-recipe-app' + kind: 'kubernetesNamespace' + namespace: 'dsrp-resources-redis-recipe-app' } ] } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go b/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go index ee4a8de6702..cd9c8d67c42 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go @@ -70,49 +70,3 @@ func Test_MongoDB_Manual(t *testing.T) { test.Test(t) } - -// Test_MongoDB_Recipe validates: -// the creation of a mongoDB from a recipe that uses an Azure resource -func Test_MongoDB_Recipe(t *testing.T) { - template := "testdata/datastoresrp-resources-mongodb-recipe.bicep" - name := "dsrp-resources-mongodb-recipe" - appNamespace := "dsrp-resources-mongodb-recipe-app" - - test := rp.NewRPTest(t, name, []rp.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dsrp-resources-mongodb-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: "dsrp-resources-mongodb-recipe", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "mongodb-app-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mongodb-db", - Type: validation.MongoDatabasesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mongodb-app-ctnr").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go b/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go index 45acdfc99fb..4f672d25308 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go @@ -17,15 +17,12 @@ limitations under the License. package resource_test import ( - "context" - "strings" "testing" "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" - "github.com/stretchr/testify/require" ) func Test_Redis_Manual(t *testing.T) { @@ -72,75 +69,3 @@ func Test_Redis_Manual(t *testing.T) { test.Test(t) } - -func Test_Redis_Recipe(t *testing.T) { - template := "testdata/datastoresrp-resources-redis-recipe.bicep" - name := "dsrp-resources-redis-recipe" - - test := rp.NewRPTest(t, name, []rp.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dsrp-resources-env-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rds-recipe", - Type: validation.RedisCachesResource, - App: name, - }, - }, - }, - SkipObjectValidation: true, - PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { - redis, err := test.Options.ManagementClient.GetResource(ctx, "Applications.Datastores/redisCaches", "rds-recipe") - require.NoError(t, err) - require.NotNil(t, redis) - status := redis.Properties["status"].(map[string]any) - recipe := status["recipe"].(map[string]interface{}) - require.Equal(t, "bicep", recipe["templateKind"].(string)) - templatePath := strings.Split(recipe["templatePath"].(string), ":")[0] - require.Equal(t, "ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed", templatePath) - }, - }, - }) - - test.Test(t) -} - -func Test_Redis_DefaultRecipe(t *testing.T) { - template := "testdata/datastoresrp-resources-redis-default-recipe.bicep" - name := "dsrp-resources-redis-default-recipe" - - test := rp.NewRPTest(t, name, []rp.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dsrp-resources-env-default-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rds-default-recipe", - Type: validation.RedisCachesResource, - App: name, - }, - }, - }, - SkipObjectValidation: true, - }, - }) - - test.Test(t) -} diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep deleted file mode 100644 index 5c7a0ef04d5..00000000000 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep +++ /dev/null @@ -1,83 +0,0 @@ -import radius as radius - -param rg string = resourceGroup().name - -param sub string = subscription().subscriptionId - -param registry string - -param version string - -param magpieimage string - -resource env 'Applications.Core/environments@2023-10-01-preview' = { - name: 'dsrp-resources-env-recipes-context-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'dsrp-resources-env-recipes-context-env' - } - providers: { - azure: { - scope: '/subscriptions/${sub}/resourceGroups/${rg}' - } - } - recipes: { - 'Applications.Datastores/mongoDatabases':{ - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-context:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2023-10-01-preview' = { - name: 'dsrp-resources-mongodb-recipe-context' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'dsrp-resources-mongodb-recipe-context-app' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2023-10-01-preview' = { - name: 'mdb-ctx-ctnr' - location: 'global' - properties: { - application: app.id - connections: { - mongodb: { - source: recipedb.id - } - } - container: { - image: magpieimage - env: { - DBCONNECTION: recipedb.connectionString() - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - } -} - -resource recipedb 'Applications.Datastores/mongoDatabases@2023-10-01-preview' = { - name: 'mdb-ctx' - location: 'global' - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-manual.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-manual.bicep index 6153c746ae8..dc759689284 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-manual.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-manual.bicep @@ -3,10 +3,10 @@ import radius as radius param magpieimage string param environment string -resource app 'Applications.Core/applications@2023-10-01-preview' = { +resource app 'Applications.Core/applications@2023-10-01-preview' = { name: 'dsrp-resources-redis-manual' location: 'global' - properties:{ + properties: { environment: environment } } @@ -21,7 +21,7 @@ resource webapp 'Applications.Core/containers@2023-10-01-preview' = { env: { DBCONNECTION: redis.connectionString() } - readinessProbe:{ + readinessProbe: { kind: 'httpGet' containerPort: 3000 path: '/healthz' diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep index b590629c858..8b8e867ed51 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep @@ -1,10 +1,10 @@ import radius as radius -param registry string +param registry string param version string -param magpieimage string +param magpieimage string resource env 'Applications.Core/environments@2023-10-01-preview' = { name: 'dsrp-resources-simenv-recipe-env' @@ -16,10 +16,10 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { namespace: 'dsrp-resources-simenv-recipe-env' } recipes: { - 'Applications.Datastores/mongoDatabases':{ + 'Applications.Datastores/mongoDatabases': { 'mongodb-recipe-kubernetes': { templateKind: 'bicep' - templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' } } } @@ -34,8 +34,8 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = { environment: env.id extensions: [ { - kind: 'kubernetesNamespace' - namespace: 'dsrp-resources-simenv-recipe-app' + kind: 'kubernetesNamespace' + namespace: 'dsrp-resources-simenv-recipe-app' } ] } @@ -56,9 +56,9 @@ resource webapp 'Applications.Core/containers@2023-10-01-preview' = { env: { DBCONNECTION: recipedb.connectionString() } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 + readinessProbe: { + kind: 'httpGet' + containerPort: 3000 path: '/healthz' } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-manual.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-manual.bicep index e02020b0d8b..fdcb0bcefb9 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-manual.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-manual.bicep @@ -68,7 +68,7 @@ resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = { resourceProvisioning: 'manual' port: sqlPort username: username - secrets:{ + secrets: { password: password } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-rs-mongodb-manual.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-rs-mongodb-manual.bicep index 857af3ae122..3f472f87e91 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-rs-mongodb-manual.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-rs-mongodb-manual.bicep @@ -35,8 +35,6 @@ resource webapp 'Applications.Core/containers@2023-10-01-preview' = { } } - -// https://hub.docker.com/_/mongo/ resource mongoContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'mdb-us-ctnr' location: 'global'