This application is an automated end-to-end test tool to be run continuously in a Radix cluster to verify that the most important functionalities are behaving as expected. This document is for Radix developers, or anyone interested in poking around.
Radix CI/CD Canary is deployed to cluster through a Helm release using Flux Operator, whenever a new image is pushed to the container registry for the corresponding branch, or a change has been made to the Helm chart. Build and Push to container registry is done using Github actions.
The application is implemented in Go. It provides metrics to the Radix external monitoring solution via Prometheus. It relies on being able to impersonate users (test users and groups are defined in the Helm chart), and it interacts with the Radix API and the Radix GitHub Webhook in the cluster it runs.
Currently, there are following scenarios (or suites) implemented, named Happy path, NSP, NSP-Long and Deploy only.
The Happy path suite contains the following tests.
- Register application
- Register application with no deploy key
- Register application with main as config branch
- List applications
- Set build secrets
- Build application
- Set secret
- Check private image hub
- Check alias responding
- Check access to application user should not be able to access
- Promote deployment to other environment
- Promote deployment to same environment
- Checks that access can be locked down by updating AD group
- Checks that machine user can be created and get proper access
- Checks that radixconfig.yaml is read from correct config branch
- Delete applications
The NSP (Network Security Policy) suite contains the following tests.
- Reach ingress
- Reach service in different namespace
- Do DNS lookup toward public nameservers from networkpolicy-canary.
- Do DNS lookup toward internal K8s nameserver from networkpolicy-canary.
- Get list of Radix jobs in networkpolicy-canary's namespace from networkpolicy-canary.
- Test that http://login.microsoft.com/ can be reached from networkpolicy-canary.
The NSP-Long suite contains the following tests. The NSP-Long suite has longer test interval than the NSP suite.
- Test scheduling of job batch from networkpolicy-canary.
- Test whether radix-canary-golang can be reached from networkpolicy-canary.
- Test whether well known external websites can be reached from networkpolicy-canary.
The Deploy only suite contains the following tests.
- Register application
- Deploy application
- Check private image hub func
- Check alias responding
- Delete applications
The radix-cicd-canary project follows a trunk-based development approach.
-
External contributors should:
- Fork the repository
- Create a feature branch in their fork
-
Maintainers may create feature branches directly in the main repository.
All changes must be merged into the master branch using pull requests with squash commits.
The squash commit message must follow the Conventional Commits specification.
Merging a pull request into master triggers the Prepare release pull request workflow.
This workflow analyzes the commit messages to determine whether the version number should be bumped — and if so, whether it's a major, minor, or patch change.
It then creates two pull requests:
- one for the new stable version (e.g.
1.2.3), and - one for a pre-release version where
-rc.[number]is appended (e.g.1.2.3-rc.1).
Merging either of these pull requests triggers the Create releases and tags workflow.
This workflow reads the version stored in version.txt, creates a GitHub release, and tags it accordingly.
The new tag triggers the Build and deploy Docker and Helm workflow, which:
- builds and pushes a new container image and Helm chart to
ghcr.io, and - uploads the Helm chart as an artifact to the corresponding GitHub release.
The application can be run locally for debugging purposes, but it will still interact with radix-api and radix-github-webhook in a cluster. A config map named radix-cicd-canary should exist in in the cluster, under the radix-cicd-canary namespace (i.e. kubectl get configmap -n radix-cicd-canary -oyaml); its format can be found at charts/templates/config.yaml. Normally, though, you don't need to do anything with this configmap. When debugging in a cluster it is wise to turn of the canary in the cluster. Do that by setting replica to zero for the deployment (i.e. kubectl edit deploy -n radix-cicd-canary). Also make sure you start a test from scratch by deleting the registration for the apps used in the tests kubectl delete rr $(kubectl get rr -o custom-columns=':metadata.name' --no-headers | grep canarycicd-)
The tests can be debugged in their entirety by setting the BEARER_TOKEN value in the .env file, and then running debug from VSCode (F5). You will most likely need to comment in the os.Setenv("GODEBUG", "http2server=0,http2client=0") line in the main.go to allow for a large token in the API.
Unit tests can be debugged individually by setting the BEARER_TOKEN value in the env_utils.go file, and then running debug on each unit test. Note the unit tests, are not really unit tests, but an ability to test a single functionality. Make sure that all scenarios before the test has executed before you start debugging a single test.
By default Info and Error messages have being logged. This can be configured via environment variable LOG_LEVEL (pods need to be restarted after changes)
LOG_LEVEL=ERROR- log onlyErrormessagesLOG_LEVEL=INFOor not set - logInfoandErrormessagesLOG_LEVEL=WARNor not set - logInfo,WarningandErrormessagesLOG_LEVEL=DEBUG- logDebug,Warning,InfoandErrormessagesPRETTY_PRINT=yes- Print human readable text instead of json messages
By default, all suites are running. This can be configured with environment variables
SUITE_LIST- list of suite names, separated by:SUITE_LIST_IS_BLACKLISTfalse,noor not set -SUITE_LISTcontains suites to be only runningtrueoryes-SUITE_LISTcontains suites, which should be skipped
To debug locally with connecting to the local services - set following environment variables:
USE_LOCAL_GITHUB_WEBHOOK_APIfalse,noor not set - connecting to in-clusterradix-apitrueoryes- connecting toradix-api, running onhttp://localhost:3001
USE_LOCAL_RADIX_APIfalse,noor not set - connecting to in-clusterradix-apitrueoryes- connecting toradix-api, running onhttp://localhost:3002
Want to contribute? Read our contributing guidelines
This is how we handle security issues
