# wazuh/qa-integration-framework architecture

> Architecture diagram of the GitHub repository wazuh/qa-integration-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wazuh/qa-integration-framework
- Repository: https://github.com/wazuh/qa-integration-framework

## Overview

This project is a quality assurance (QA) integration framework specifically designed for performing integration tests for the Wazuh platform. Its purpose is to simulate, monitor, and validate the various components of Wazuh (e.g., analysisd, agentd, API, etc.) by leveraging a structured collection of modules, constants, templates, and utilities.

##### Project Type and Purpose
- The project is an integration test framework focused on Wazuh. It provides a python library that simulation tests and validates various components (or “daemons”) of the Wazuh ecosystem.
- The README and file tree indicate that the framework is used by importing its modules and constants in test suites. Its primary goal is to facilitate integration testing by providing pre-configured templates, data feeds, simulators, monitors, and testing utilities.

##### File Structure
- Top-level files such as .gitignore, CHANGELOG.md, LICENSE, README.md, requirements.txt, and setup.py indicate a well-organized, distributable Python project.
- The extensive “src/wazuh_testing” directory contains all the internal logic, divided into several key subcomponents:
- Constants: Contains definitions for API endpoints, AWS configurations, daemon settings, file paths (e.g., for configurations, logs, rulesets, etc.), ports, and user settings.
- Data: Holds JSON and XML templates for alerts, configurations, events, feeds (feed data from various sources like Debian, RedHat, NVD, etc.), and statistics formats.
- Modules: This directory is organized into folders representing different daemons and functionalities (e.g., agentd, analysisd, api, authd, aws, execd, fim, logcollector, modulesd, monitord, remoted, wazuh_db). Each submodule typically contains configurations, pattern definitions, utilities, and sometimes test-specific resources (e.g., testrule inside analysisd).
- Tools: Contains utility scripts for administrative tasks such as certificate control, database administration, MITM simulation, file/socket controllers, simulators, and monitors. These tools support the integration tests by simulating or monitoring specific behaviors.
- Utils: General helper functions and utilities (e.g., handling agents, callbacks, cluster management, configuration, file handling, network utilities, etc.) that are shared across different parts of the integration tests.

##### README for Additional Insights
- The README provides simple instructions on how to install the framework and demonstrates basic usage via code examples.
- It shows real-life usage by demonstrating how to import constants (such as paths and patterns), initialize monitoring components (like FileMonitor), and utilize callback functions in tests. This confirms that the framework is intended to help simulate/log and verify Wazuh processes during integration testing.

a. Main Components:
- Test Harness & Entry Point: Represented by the main installation and module import in the test suites.
- Constants: A core component providing standardized configuration values (paths, API endpoints, etc.).
- Data Templates: Stores the alert templates, event templates, configuration templates, and feeds used by the testing modules.
- Modules (by sub-system): Each daemon or service (agentd, analysisd, api, authd, etc.) is represented as an individual component. These modules are responsible for simulating or validating their respective Wazuh functionalities.
- Tools: Represent external utilities like simulators, monitors, certificate controllers, and database administrators that assist in testing.
- Utilities: Helper functions that provide shared services (logging, network operations, encryption, etc.) across the framework.

b. Relationships and Interactions:
- The Test Harness (or entry point) imports modules, constants, and utilities to construct and run integration tests.
- The Modules interact with the Data Templates (for configuring tests and generating simulated alerts or events).
- Tools are used alongside modules to simulate external events (for example, running an agent or monitoring a log file) and trigger callbacks defined in Utils.
- Constants provide a common ground for configuration ensuring that all modules and tools refer to standardized paths, ports, and APIs.

c. Important Architectural Patterns:
- Modular Design: Each Wazuh daemon (agentd, analysisd, etc.) has its own subdirectory with configurations, patterns, and utilities, indicating a plug-and-play approach.
- Separation of Concerns: Division between constants, data, modules, tools, and utilities ensures that the system is easy to maintain, extend, and test in isolation.
- Template-Driven Testing: Data templates for alerts, configurations, and feeds suggest a design where tests are driven by predefined structured inputs.

d. Technologies, Frameworks, and Libraries:
- Python is the primary programming language, with dependencies managed via pip (as seen in requirements.txt and setup.py).
- Built-in and third-party libraries for logging, JSON/XML management, file monitoring, and network operations are implicitly used within the utilities and modules.
- The integration of various daemon-specific testing modules (agentd, analysisd, etc.) reflects an architecture tailored specifically for testing different aspects of the Wazuh platform.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TH("Test Harness & Entry Point"):::entrypoint
    CONST("Constants"):::config
    DATA("Data Templates"):::config
    TOOLS("Tools"):::tools
    UTIL("Utilities"):::utils

    TH -->|"imports"| CONST
    TH -->|"imports"| DATA
    TH -->|"imports"| UTIL
    TH -->|"triggers"| TOOLS
    TH -->|"imports"| AGENT
    TH -->|"imports"| ANALYSIS
    TH -->|"imports"| API

    DATA -->|"configures"| AGENT
    DATA -->|"configures"| ANALYSIS
    DATA -->|"configures"| API

    TOOLS -->|"simulates"| AGENT
    TOOLS -->|"monitors"| MONI
    TOOLS -->|"utilizes"| UTIL

    AGENT -->|"calls"| UTIL
    ANALYSIS -->|"calls"| UTIL
    API -->|"calls"| UTIL
    MODS -->|"utils_call"| UTIL
    LOG -->|"logs"| UTIL

    subgraph "Wazuh Modules"
        AGENT("Agentd"):::module
        ANALYSIS("Analysisd"):::module
        API("API"):::module
        AUTH("Authd"):::module
        AWS("AWS"):::module
        EXEC("Execd"):::module
        FIM("FIM"):::module
        LOG("Logcollector"):::module
        MODS("Modulesd"):::module
        MONI("Monitord"):::module
        REMOTE("Remoted"):::module
        WDB("Wazuh_DB"):::module
    end

    classDef entrypoint fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef config fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef module fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef tools fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef utils fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;

    click TH "https://github.com/wazuh/qa-integration-framework/blob/main/src/wazuh_testing/__init__.py"
    click CONST "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/constants"
    click DATA "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/data"
    click AGENT "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/agentd"
    click ANALYSIS "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/analysisd"
    click API "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/api"
    click AUTH "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/authd"
    click AWS "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/aws"
    click EXEC "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/execd"
    click FIM "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/fim"
    click LOG "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/logcollector"
    click MODS "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/modulesd"
    click MONI "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/monitord"
    click REMOTE "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/remoted"
    click WDB "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/modules/wazuh_db"
    click TOOLS "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/tools"
    click UTIL "https://github.com/wazuh/qa-integration-framework/tree/main/src/wazuh_testing/utils"
```
