This document provides an overview of the testing architecture for the Unity Project. It encompasses continuous testing concepts such as testing across the software development lifecycle as well as automated execution of tests through automation.
The below list of test categories are included in our testing setup. Further details are provided below.
- Static Code Analysis: checks code for syntax, style, vulnerabilities, and bugs
- Unit Tests: tests functions or components to verify that they perform as intended
- Security Tests: identifies potential security vulnerabilities
- Build Tests: checks if the code builds into binaries or packages successfully
- Acceptance Tests: validates against end-user & stakeholder requirements
- Integration Tests: ensure software components interact correctly
- System Tests: intended to test the overall software application in an integrated form
- Location:
/.pre-commit-config.yaml
- Purpose: Perform static code analysis on Python files in the project.
- Running Tests:
- Manually:
- Install
Flake8
by runningpip install flake8
. - Navigate to the project directory and run
flake8 .
to analyze all Python files. - View the results in the terminal.
- Install
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Manually:
- Contributing:
- Framework Used:
Flake8
- Tips:
- Ensure your code follows PEP 8 style guidelines.
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Lint markdown files for syntax errors.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
markdownlint-cli
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Sort Python imports.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
isort
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Format Python code using the Black formatter.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
black
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Lint Ruby files for syntax errors.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
ruff
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Check Python code for security vulnerabilities.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
bandit
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Lint Dockerfiles for syntax errors.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
hadolint
- Tips: N/A
- Framework Used:
- Location:
/.pre-commit-config.yaml
- Purpose: Validate, format, and lint Terraform configuration files.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run nightly on all active branches.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used: `pre
- Location:
/unity-test/unit/conftest.py
- Purpose: Provides a
DagBag
object for testing DAGs. - Running Tests:
- Manually: N/A
- Automatically:
- Frequency: N/A
- Results Location: N/A
- Contributing:
- Framework Used: pytest
- Tips:
- This fixture can be used in other test functions to get access to the loaded DAGs.
- Location:
/unity-test/unit/step_defs/test_dags_validation.py
- Purpose: Tests the DAG validation features using pytest-bdd.
- Running Tests:
- Manually:
- Install the required Python packages:
pip install pytest pytest-bdd apache-airflow
- Run the tests:
pytest test_dags_validation.py
- View the test results in the console output.
- Install the required Python packages:
- Automatically:
- Frequency: On code changes
- Results Location: N/A
- Manually:
- Contributing:
- Framework Used: pytest-bdd
- Tips:
- The test functions use the
given
andthen
decorators from pytest-bdd to define the test scenarios. - Each scenario is defined in the
/unity-test/unit/features/dags_validation.feature
file. - The
the_dags_are_loaded
fixture is used to provide theDagBag
object to the test functions. - The test functions assert various properties of the loaded DAGs, such as the absence of import errors, the validity of task owners, the presence of tags, and the absence of DAG cycles.
- The test functions use the
- Location:
/.github/workflows
- Purpose: Identify potential security vulnerabilities.
- Running Tests:
- Manually: N/A
- Automatically:
- Frequency:
- Triggered by code commits to the
main
branch. - Run weekly, every Monday at 2:00 AM UTC.
- Triggered by code commits to the
- Results Location: N/A
- Frequency:
- Contributing:
- Framework Used:
OWASP ZAP
for web application vulnerabilities,Synk
for dependency checks - Tips:
- Use
Bandit
for Python code static analysis. - Follow the OWASP Top 10 Vulnerabilities.
- Use
- Framework Used:
- Location:
/unity-test/system/integration
- Purpose: To ensure that SBG E2E processing does not fail and data can be retrieved from it.
- Running Tests:
- Manually:
- Ensure the Airflow API is up and running.
- Trigger a dag run for the SBG E2E dag.
- Check the response status code is 200.
- Poll the dag run until a successful state is reached.
- Automatically:
- Trigger: Code changes.
- Timing: Nightly.
- Results Location:
[INSERT PATH OR LOCATION WHERE RESULTS WILL RESIDE]
- Manually:
- Contributing:
- Framework Used: pytest-bdd.
- Tips:
- Ensure that the Airflow API is up and running before running the tests.
- Check that the response status code is 200.
- Poll the dag run until a successful state is reached.
- Location:
/unity-test/system/smoke
- Purpose: Ensure that the Airflow API is up and running and each Airflow component is reported as healthy.
- Running Tests:
- Manually:
- Navigate to
/unity-test/system/smoke
folder. - Run
pytest
. - View test results in the terminal.
- Navigate to
- Automatically:
- Trigger: Code changes.
- Timing: On every push to the main branch.
- Results Location: Test results will be displayed in the CI/CD pipeline logs.
- Manually:
- Contributing:
- Framework Used:
pytest
andpytest-bdd
- Tips:
- Ensure that all Airflow components are included in the
airflow_components
list. - Ensure that the
airflow_api_url
fixture is properly set up.
- Ensure that all Airflow components are included in the
- Framework Used: