Skip to content

Run Azure functional tests locally against OS-process Radius#11904

Open
sylvainsf wants to merge 2 commits into
mainfrom
local-functional
Open

Run Azure functional tests locally against OS-process Radius#11904
sylvainsf wants to merge 2 commits into
mainfrom
local-functional

Conversation

@sylvainsf
Copy link
Copy Markdown
Contributor

Description

Adds a workflow for running the corerp/cloud Azure functional tests against a local OS-process Radius stack (make debug-start) using the host's az login credentials, with no service-principal/workload-identity registration required.

Highlights

  • New build/scripts/azure-local-testenv.sh orchestrator with setup, run, teardown, all sub-commands. run and all accept passthrough go test flags (e.g. -run, -v).
  • Auto-recovery: run rebuilds state from the newest radlocal-${USER}-* resource group when the state file is missing (e.g. after make debug-stop), and re-applies the Azure scope on the default rad environment that debug-start wipes.
  • Orphan GC: teardown --all-orphans deletes every radlocal-${USER}-* RG and stops the tf-module-server port-forward.
  • tf-module-server bootstrap: deploys the in-cluster nginx test module server and port-forwards it to localhost:8999 automatically when not already reachable.
  • Terraform Azure provider falls back to use_cli = true when no Azure credential is registered with UCP (404), letting the host RP's az login session authenticate. CI workload-identity path is unchanged. See pkg/recipes/terraform/config/providers/azure.go.
  • build/scripts/start-radius.sh exports TERRAFORM_TEST_GLOBAL_DIR so the RP no longer tries to write to read-only /terraform.
  • AWS-required tests skip cleanly via t.Skip when AWS env vars are unset; private-git redis test skips when GH_TOKEN is unset.
  • recipe_terraform_test.go now derives the resource ID from the active workspace scope so it works against any RG (CI's kind-radius and local debug's default).

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).
  • This pull request adds or changes features of Radius and has an approved issue (issue link required).
  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Auto-generated summary

How tested

Full corerp/cloud/... suite green locally with the new orchestrator:

Test Status
Test_AzureConnections PASS
Test_ACI PASS
Test_TerraformRecipe_AzureResourceGroup PASS
AWS-only tests (Test_AWS_*, Test_Extender_RecipeAWS_LogGroup, Test_AWSRedeploy*) SKIP (no AWS creds)
Test_TerraformPrivateGitModule_KubernetesRedis SKIP (no GH_TOKEN)
Test_Storage, Test_PersistentVolume SKIP (issue #7853, pre-existing)
./build/scripts/azure-local-testenv.sh run -v
# EXIT=0

Unit tests for the changed terraform provider package also pass:

go test ./pkg/recipes/terraform/config/providers/... -count=1

Documentation

Updated docs/contributing/contributing-code/contributing-code-debugging/radius-os-processes-debugging.md with new sections on:

  • Re-running individual tests via azure-local-testenv.sh run -run …
  • Cleaning up orphaned resource groups with teardown --all-orphans
  • tf-module-server bootstrap behavior
  • Terraform recipes falling back to Azure CLI credentials

Backwards compatibility

  • CI path unchanged: workload-identity / service-principal credentials registered with rad credential register azure … continue to work exactly as before.
  • The use_cli = true fallback only activates when UCP returns 404 for the credential lookup (i.e. no credential ever registered).

Adds a workflow for running the corerp/cloud Azure functional tests
against a local OS-process Radius stack (`make debug-start`) using the
host's `az login` credentials, with no service-principal/workload-identity
registration required.

Highlights

- New `build/scripts/azure-local-testenv.sh` orchestrator with
  `setup`, `run`, `teardown`, `all` sub-commands. `run` and `all` accept
  passthrough `go test` flags (e.g. `-run`, `-v`).
- Auto-recovery: `run` rebuilds state from the newest
  `radlocal-${USER}-*` resource group when the state file is missing
  (e.g. after `make debug-stop`), and re-applies the Azure scope on the
  default rad environment that `debug-start` wipes.
- Orphan GC: `teardown --all-orphans` deletes every
  `radlocal-${USER}-*` RG and stops the `tf-module-server` port-forward.
- `tf-module-server` bootstrap: deploys the in-cluster nginx test module
  server and port-forwards it to `localhost:8999` automatically when not
  already reachable.
- Terraform Azure provider falls back to `use_cli = true` when no Azure
  credential is registered with UCP (404), letting the host RP's
  `az login` session authenticate. CI workload-identity path is
  unchanged.
- `start-radius.sh` exports `TERRAFORM_TEST_GLOBAL_DIR` so the RP no
  longer tries to write to read-only `/terraform`.
- AWS-required tests skip cleanly via `t.Skip` when AWS env vars are
  unset; private-git redis test skips when `GH_TOKEN` is unset.
- `recipe_terraform_test.go` now derives the resource ID from the
  active workspace scope so it works against any RG (CI's `kind-radius`
  and local debug's `default`).

Tested

Full `corerp/cloud/...` suite green locally:
- PASS: `Test_AzureConnections`, `Test_ACI`, `Test_TerraformRecipe_AzureResourceGroup`
- SKIP: AWS-only tests, `Test_TerraformPrivateGitModule_KubernetesRedis`,
  `Test_Storage`/`Test_PersistentVolume` (issue #7853, pre-existing)

Documentation in
`docs/contributing/contributing-code/contributing-code-debugging/radius-os-processes-debugging.md`.

Signed-off-by: Sylvain Niles <sylvainniles@microsoft.com>
Copilot AI review requested due to automatic review settings May 14, 2026 20:09
@sylvainsf sylvainsf requested review from a team as code owners May 14, 2026 20:09
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a local-dev workflow to run the corerp/cloud Azure functional tests against an OS-process Radius debug stack using ambient az login credentials (no UCP-registered Azure credential required), plus supporting tweaks to tests, tooling, and docs.

Changes:

  • Introduces build/scripts/azure-local-testenv.sh + new make test-functional-azure-local* targets to provision/execute/cleanup an ephemeral Azure test environment.
  • Updates Terraform Azure provider config generation to fall back to Azure CLI auth (use_cli = true) when no Radius-managed credential exists (incl. 404 lookup).
  • Improves local/CI test ergonomics (scope-derived resource IDs, skip behavior when secrets/creds are absent) and documents the workflow.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/validation/shared.go Adds a local-dev escape hatch env var to bypass UCP credential presence checks in tests.
test/functional-portable/corerp/cloud/resources/recipe_terraform_test.go Uses active workspace scope for resource IDs; skips private-git test when GH_TOKEN is unset.
test/functional-portable/corerp/cloud/resources/extender_test.go Switches AWS env-var precheck from failing to skipping.
test/createAzureTestResources.bicep Parameterizes Cosmos account name to avoid global-name collisions in parallel/local runs.
pkg/recipes/terraform/config/providers/azure.go Treats 404/missing creds as “no creds” and explicitly enables Azure CLI auth fallback.
docs/contributing/contributing-code/contributing-code-debugging/radius-os-processes-debugging.md Documents running DE locally and the new local Azure functional test workflow.
build/test.mk Adds test-functional-azure-local* make targets that wrap the new orchestrator script.
build/scripts/start-radius.sh Sets a writable Terraform global cache dir for OS-process runs.
build/scripts/ensure-encryption-key.sh Ensures the encryption key Secret exists for the k3d debug stack (Helm-less path).
build/scripts/azure-local-testenv.sh New orchestrator for setup/run/teardown of local Azure functional test environment + tf-module-server bootstrap.
build/debug.mk Improves k3d cluster handling; supports reusing an external local Deployment Engine on port 5017; ensures encryption key secret exists.

Comment on lines +262 to +263
# Pick the newest RG (epoch suffix). RG names are radlocal-<user>-<epoch>.
rg="$(printf '%s\n' ${matches} | sort -t- -k3 -n | tail -1)"
Comment on lines +90 to +94
if ! kubectl get ns "${TF_MODULE_SERVER_NS}" >/dev/null 2>&1 \
|| ! kubectl -n "${TF_MODULE_SERVER_NS}" get deploy tf-module-server >/dev/null 2>&1; then
log "Deploying tf-module-server into the debug cluster (publish-test-terraform-recipes)..."
(cd "${REPO_ROOT}" && make publish-test-terraform-recipes >/dev/null) \
|| { err "make publish-test-terraform-recipes failed"; exit 1; }
Comment on lines +402 to +406
cmd_all() {
cmd_setup
local rc=0
if [[ "${AZURE_LOCAL_KEEP_ON_FAILURE:-0}" == "1" || "${AZURE_LOCAL_KEEP_ON_FAILURE:-}" =~ ^[Tt]rue$ ]]; then
log "AZURE_LOCAL_KEEP_ON_FAILURE is set; teardown will be SKIPPED if tests fail (post-mortem mode)."
Comment on lines +172 to +179
// When no Radius-managed credentials are registered (e.g. a developer
// running the RP locally without `rad credential register azure ...`),
// fall back to the Azure CLI credentials available on the host process.
// `use_cli = true` is the azurerm provider default but we set it
// explicitly to make the intent clear in the generated terraform config.
if credentials == nil {
configMap[azureUseCLIParam] = true
return configMap
Comment thread build/debug.mk
Comment on lines +298 to +301
if command -v lsof >/dev/null 2>&1; then \
listener_cmd=$$(lsof -nP -iTCP:5017 -sTCP:LISTEN 2>/dev/null | awk 'NR==2 {print $$1}'); \
fi; \
if [ -n "$$listener_cmd" ] && [ "$$listener_cmd" != "kubectl" ] && curl -s "http://localhost:5017/metrics" > /dev/null 2>&1; then \
Comment on lines +35 to 39
// Skip the test if the required environment variables are not set
// (in CI these are provided alongside AWS credentials; locally the
// AWS feature gate via RequiredFeatures will also skip the test when
// AWS credentials are not registered with UCP).
if awsAccountID == "" || awsRegion == "" {
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Unit Tests

    2 files  ±0    423 suites  ±0   7m 26s ⏱️ +3s
5 137 tests ±0  5 135 ✅ ±0  2 💤 ±0  0 ❌ ±0 
6 175 runs  ±0  6 173 ✅ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit cc77ff9. ± Comparison against base commit 9017ff2.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.69%. Comparing base (9017ff2) to head (cc77ff9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/recipes/terraform/config/providers/azure.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11904      +/-   ##
==========================================
- Coverage   51.69%   51.69%   -0.01%     
==========================================
  Files         724      724              
  Lines       45508    45511       +3     
==========================================
  Hits        23525    23525              
- Misses      19763    19765       +2     
- Partials     2220     2221       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests Bot commented May 19, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref cc77ff9
Unique ID func85e549ff30
Image tag pr-func85e549ff30
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func85e549ff30
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func85e549ff30
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func85e549ff30
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func85e549ff30
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func85e549ff30
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants