- Introduction
- Journey Testing
- Upgrade Testing
- Linting and Static Analysis
- Best Practices
- Best Practice Examples
- Consistency Across Packages
- Contribution and Maintenance
- Related Resources
This document outlines the testing guidelines and best practices for UDS Packages. These guidelines aim to ensure consistency, reliability, and quality across all of our packages.
Journey testing is crucial for ensuring that UDS packages function correctly within their deployment environment and integrate properly with other UDS components.
A Journey in the context of UDS package testing is defined as:
The minimal and least fragile way to test all features of an application that could be broken from how we deploy it.
- Focus on testing the deployment, not the application itself (that's the upstream developer's job).
- Ensure that our deployment method doesn't break key functionalities.
- Test integration with UDS core components (e.g., Istio, Keycloak).
- Design tests that cover essential functionality without being overly complex.
- Focus on deployment-related issues (e.g., network policies, SSO access, cluster resource access).
- Handle limitations due to licensing or other constraints by documenting them and implementing what testing is possible.
- UI Testing: Playwright, Cypress
- Non-UI Testing: Jest
- Custom Scripts: Bash or other scripting languages as needed
Ensure that the current development package works when deployed over the previously released version.
- Test data migration and persistence.
- Verify that configurations are properly carried over or updated.
- Check for any breaking changes in APIs or integrations.
Use appropriate tooling to ensure code quality and consistency.
- YAML Linting:
yamllint
- Zarf Package Linting:
zarf dev lint
- Shellcheck for any bash scripts.
-
Consistency: Use similar testing approaches across different UDS packages where possible.
-
Documentation: Clearly document what each test is checking and why.
-
Maintenance: Keep tests updated as the application and deployment methods evolve.
-
CI/CD Integration: Incorporate all types of tests into your CI/CD pipeline.
-
Error Handling: Ensure tests fail gracefully and provide clear error messages.
-
Repeatability: Ensure tests produce consistent results regardless of how many times or in what order they are executed. Design them to handle dynamic and asynchronous workloads without compromising output integrity.
-
Performance Consideration: Balance thoroughness with rapid developer feedback:
- Single package tests: Aim for <15 minutes runtime
- Full CI jobs (e.g., deploy and test): Maximum 30 minutes
- Large integration tests (multiple packages): Longer durations acceptable
Note: Strive for individual package tests to complete in under 10 minutes when possible.
The following examples demonstrate best practices for implementing various types of tests in UDS packages:
-
The
uds-package-gitlab
repository provides a good example of journey test implementation. These files demonstrate how to set up and structure end-to-end tests using Playwright, including authentication handling and test suite organization.- Test Configuration: playwright.config.ts
- Test Suite: gitlab.test.ts
- Authentication Setup: auth.setup.ts
-
- The uds-common action is reused in packages.
- Example task in the uds-package-gitlab repository
-
Both
uds-package-gitlab
anduds-package-gitlab-runner
use atest.yaml
file to define their test execution process. These files are used by Maru Runner, which is built into the uds-cli tool. These YAML files demonstrate how to set up and run tests locally or in CI/CD pipelines.
These examples serve to codify the "Consistency" best practice. By following similar patterns across different UDS packages, we ensure a uniform approach to testing, making it easier for developers to understand and maintain tests across the ecosystem.
This document is a living guide. If you have suggestions for improvements or new best practices, please submit a PR or open an issue in the uds-common repository.
For package-specific testing information, refer to the individual package repositories and their documentation.