Package Testing
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll set up a testing strategy for your UDS Package that validates deployment correctness, UDS Core integration, and upgrade compatibility. These practices ensure packages deploy reliably and integrate properly with core services like Istio and Keycloak.
Prerequisites
Section titled “Prerequisites”- UDS CLI installed
- A UDS Package ready for testing
- Node.js installed (for Playwright and Jest)
- yamllint installed (for linting YAML files)
- Shellcheck installed (for linting bash scripts)
Before you begin
Section titled “Before you begin”UDS Package testing focuses on validating packaging, deployment, and integration, not duplicating upstream application tests. Tests should confirm that your packaging and configuration choices don’t break key functionality, and that integration with UDS Core components works as expected.
Place all test files (Playwright specs, Jest tests, custom validation scripts, and related configuration) in a tests directory at the root of your package repository.
-
Add journey tests
Journey tests validate the critical workflows impacted by your packaging, configuration, or deployment. Focus on deployment-related concerns like network policies, SSO access, and cluster resource access rather than upstream application logic.
Use Playwright for UI testing and Jest for API or non-UI testing. Use bash or other scripting languages for custom validation scripts as needed.
-
Add upgrade tests
Upgrade tests validate that the current development package deploys successfully over the most recently released version. When writing upgrade tests, verify the following:
- Data migration and persistence work correctly
- Configurations carry over or update properly
- No breaking changes occur in APIs or external integrations
-
Add linting and static analysis
Run linting checks to catch issues before deployment.
Terminal window # Lint Zarf package definitionsuds zarf dev lint # https://docs.zarf.dev/commands/zarf_dev_lint/# Lint YAML filesyamllint .# Lint bash scriptsshellcheck scripts/*.sh -
Integrate tests into CI/CD
Configure your pipeline to run all tests automatically so every code change is verified before advancing through the workflow. Follow these principles for reliable test suites:
- Repeatability: Tests should produce consistent results regardless of execution order or frequency. Design them to handle dynamic and asynchronous workloads without compromising output integrity.
- Error handling: Fail with actionable messages and include enough context to debug.
- Performance: Balance coverage with rapid feedback to keep pipelines efficient.
Verification
Section titled “Verification”Define your test tasks in a tasks/test.yaml file to automate and simplify test execution. A well-structured test file groups health checks, ingress validation, and UI tests into individual tasks, with an all task that runs them in sequence:
tasks: - name: all actions: - task: health-check - task: ingress - task: ui
- name: health-check actions: - description: Verify deployment is available wait: cluster: kind: Deployment name: my-package namespace: my-package condition: Available
- name: ingress actions: - description: Verify ingress returns 200 maxRetries: 30 cmd: | STATUS=$(curl -L -o /dev/null -s -w "%{http_code}\n" https://my-package.uds.dev) echo "Status: ${STATUS}" if [ "$STATUS" != "200" ]; then sleep 10 exit 1 fi
- name: ui description: Run Playwright UI tests actions: - cmd: npx playwright test dir: testsWith this in place, you can run all tests with a single command:
uds run test:allSee the Reference Package test tasks for a complete example.
Success criteria
Section titled “Success criteria”Your test suite is working correctly when:
- All tasks in
uds run test:allexit with code 0 - No error output appears in health check, ingress, or UI task logs
- Journey tests pass consistently across multiple runs
- Upgrade tests confirm data persists and the package reaches a
Readystate after upgrade
Troubleshooting
Section titled “Troubleshooting”Problem: Journey tests fail intermittently
Section titled “Problem: Journey tests fail intermittently”Symptom: Tests pass locally but fail in CI due to timing or async workloads.
Solution: Add appropriate wait conditions or retries for dynamic resources. Ensure tests don’t depend on execution order.
Problem: Upgrade tests fail on data migration
Section titled “Problem: Upgrade tests fail on data migration”Symptom: Data from the previous version is missing or corrupted after upgrade.
Solution: Check that persistent volume claims and database migrations are handled correctly in your Zarf package lifecycle actions.