Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate test_wazuh_db documentation to qa-docs #2346

Merged
merged 3 commits into from
Jan 7, 2022

Conversation

fedepacher
Copy link
Contributor

Related issue
#1820

Description

As part of epic #1796, this PR adds the missing documentation and migrates the current documentation to the new format used by qa-docs.

The schema used is the one defined in issue #1694

Generated documentation

test_wazuh_db.json

{
    "copyright": "Copyright (C) 2015-2021, Wazuh Inc.\nCreated by Wazuh, Inc. <[email protected]>.\nThis program is free software; you can redistribute it and/or modify it under the terms of GPLv2",
    "type": "integration",
    "brief": "Wazuh-db is the daemon in charge of the databases with all the Wazuh persistent information, exposing a socket to receive requests and provide information. The Wazuh core uses list-based databases to store information related to agent keys, and FIM/Rootcheck event data. Wazuh-db confirms that is able to save, update and erase the necessary information into the corresponding databases, using the proper commands and response strings.",
    "tier": 0,
    "modules": [
        "wazuh_db"
    ],
    "components": [
        "manager"
    ],
    "daemons": [
        "wazuh-db"
    ],
    "os_platform": [
        "linux"
    ],
    "os_version": [
        "Arch Linux",
        "Amazon Linux 2",
        "Amazon Linux 1",
        "CentOS 8",
        "CentOS 7",
        "CentOS 6",
        "Ubuntu Focal",
        "Ubuntu Bionic",
        "Ubuntu Xenial",
        "Ubuntu Trusty",
        "Debian Buster",
        "Debian Stretch",
        "Debian Jessie",
        "Debian Wheezy",
        "Red Hat 8",
        "Red Hat 7",
        "Red Hat 6"
    ],
    "references": [
        "https:/wazuh/wazuh-qa/blob/master/docs/tests/integration/test_wazuh_db/index.md",
        "https:/wazuh/wazuh-qa/blob/master/docs/tests/integration/test_wazuh_db/test_wazuh_db.md",
        "https://documentation.wazuh.com/current/user-manual/reference/daemons/wazuh-db.html"
    ],
    "tags": [
        "wazuh_db"
    ],
    "name": "test_wazuh_db.py",
    "id": 1,
    "group_id": 0,
    "path": "tests/integration/test_wazuh_db/test_wazuh_db.py",
    "tests": [
        {
            "description": "Check that every input agent message in wazuh-db socket generates the adequate output to wazuh-db socket. To do this, query the socket with a command taken from the input list of stages (test_case, input field) and compare the result with the input list of stages (test_case, output field).",
            "wazuh_min_version": "4.2.0",
            "parameters": [
                {
                    "restart_wazuh": {
                        "type": "fixture",
                        "brief": "Reset the 'ossec.log' file and start a new monitor."
                    }
                },
                {
                    "clean_registered_agents": {
                        "type": "fixture",
                        "brief": "Remove all agents of wazuhdb."
                    }
                },
                {
                    "configure_sockets_environment": {
                        "type": "fixture",
                        "brief": "Configure environment for sockets and MITM."
                    }
                },
                {
                    "connect_to_sockets_module": {
                        "type": "fixture",
                        "brief": "Module scope version of 'connect_to_sockets' fixture."
                    }
                },
                {
                    "insert_agents_test": {
                        "type": "fixture",
                        "brief": "Insert agents. Only used for the agent queries."
                    }
                },
                {
                    "test_case": {
                        "type": "fixture",
                        "brief": "List of test_case stages (dicts with input, output and stage keys)."
                    }
                }
            ],
            "assertions": [
                "Verify that the socket response matches the expected output of the yaml input file."
            ],
            "input_description": [
                "Test cases are defined in the agent_messages.yaml file. This file contains the command to insert and clear information of registered agents in the database. Also, it contains a case to check messages from not registered agents."
            ],
            "expected_output": [
                "r'Failed test case stage .*'",
                "r'Error when executing .* in daemon'",
                "Unable to add agent",
                "Unable to upgrade agent"
            ],
            "tags": [
                "wazuh_db",
                "wdb_socket"
            ],
            "name": "test_wazuh_db_messages_agent"
        },
        {
            "description": "Check that every input global message in wazuh-db socket generates the adequate output to wazuh-db socket. To do this, query the socket with a command taken from the input list of stages (test_case, input field) and compare the result with the input list of stages (test_case, output field).",
            "wazuh_min_version": "4.2.0",
            "parameters": [
                {
                    "restart_wazuh": {
                        "type": "fixture",
                        "brief": "Reset the 'ossec.log' file and start a new monitor."
                    }
                },
                {
                    "connect_to_sockets_module": {
                        "type": "fixture",
                        "brief": "Module scope version of 'connect_to_sockets' fixture."
                    }
                },
                {
                    "test_case": {
                        "type": "fixture",
                        "brief": "List of test_case stages (dicts with input, output and stage keys)."
                    }
                }
            ],
            "assertions": [
                "Verify that the socket response matches the expected output of the yaml input file."
            ],
            "input_description": [
                "Test cases are defined in the global_messages.yaml file. This file contains cases to insert, upgrade, label, select, get-all-agents, sync-agent-info-get, sync-agent-info-set, belongs table, reset connection status, get-agents-by-connection-status, disconnect-agents, delete and keepalive commands in global database."
            ],
            "expected_output": [
                "r'Failed test case stage .*'",
                "r'Error when executing * in daemon'"
            ],
            "tags": [
                "wazuh_db",
                "wdb_socket"
            ],
            "name": "test_wazuh_db_messages_global"
        },
        {
            "description": "Check that commands by chunks work properly when the agents' amount exceeds the response maximum size. To do this, send a command to the wazuh-db socket and check the response from the socket.",
            "wazuh_min_version": "4.2.0",
            "parameters": [
                {
                    "restart_wazuh": {
                        "type": "fixture",
                        "brief": "Reset the 'ossec.log' file and start a new monitor."
                    }
                },
                {
                    "configure_sockets_environment": {
                        "type": "fixture",
                        "brief": "Configure environment for sockets and MITM."
                    }
                },
                {
                    "clean_registered_agents": {
                        "type": "fixture",
                        "brief": "Remove all agents of wazuhdb."
                    }
                },
                {
                    "connect_to_sockets_module": {
                        "type": "fixture",
                        "brief": "Module scope version of 'connect_to_sockets' fixture."
                    }
                },
                {
                    "pre_insert_agents": {
                        "type": "fixture",
                        "brief": "Insert agents. Only used for the global queries."
                    }
                }
            ],
            "assertions": [
                "Verify that the socket status response matches with 'due' to fail."
            ],
            "input_description": [
                "Test cases are defined in the global_messages.yaml file. Status response is expected from global get-all-agents last_id 0 command, global sync-agent-info-get last_id 0 command, global get-agents-by-connection-status 0 active command and global disconnect-agents 0 .* syncreq command."
            ],
            "expected_output": [
                "r'Failed chunks check on .*'"
            ],
            "tags": [
                "wazuh_db",
                "wdb_socket"
            ],
            "name": "test_wazuh_db_chunks"
        },
        {
            "description": "Calculates the checksum range during the synchronization of the DBs the first time and avoids the checksum range the next time. To do this, query the database with the command that contains agent checksum information and calculate the checksum range.",
            "wazuh_min_version": "4.2.0",
            "parameters": [
                {
                    "restart_wazuh": {
                        "type": "fixture",
                        "brief": "Reset the 'ossec.log' file and start a new monitor."
                    }
                },
                {
                    "configure_sockets_environment": {
                        "type": "fixture",
                        "brief": "Configure environment for sockets and MITM."
                    }
                },
                {
                    "connect_to_sockets_module": {
                        "type": "fixture",
                        "brief": "Module scope version of 'connect_to_sockets' fixture."
                    }
                },
                {
                    "prepare_range_checksum_data": {
                        "type": "fixture",
                        "brief": "Execute syscheck command with a specific payload to query the database."
                    }
                },
                {
                    "file_monitoring": {
                        "type": "fixture",
                        "brief": "Handle the monitoring of a specified file."
                    }
                },
                {
                    "request": {
                        "type": "fixture",
                        "brief": "Provide information of the requesting test function."
                    }
                }
            ],
            "assertions": [
                "Verify that the checksum range can be calculated the first time and the checksum range was avoid the second time."
            ],
            "input_description": [
                "The input of this test is the agent payload defined in the prepare_range_checksum_data fixture."
            ],
            "expected_output": [
                "r'range checksum Time: .*'",
                "Checksum Range wasn\u00b4t calculated the first time",
                "range checksum avoided",
                "Checksum Range wasn\u00b4t avoided the second time"
            ],
            "tags": [
                "wazuh_db",
                "wdb_socket"
            ],
            "name": "test_wazuh_db_range_checksum"
        }
    ]
}

Tests

  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.
  • The qa-docs tool does not raise any error.

@fedepacher fedepacher self-assigned this Dec 15, 2021
Copy link
Contributor

@roronoasins roronoasins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job 👍, just a few changes

@roronoasins roronoasins linked an issue Dec 16, 2021 that may be closed by this pull request
6 tasks
@jmv74211 jmv74211 requested review from snaow and removed request for snaow December 16, 2021 10:30
roronoasins
roronoasins previously approved these changes Dec 16, 2021
Copy link
Contributor

@roronoasins roronoasins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@snaow snaow merged commit 619fb60 into master Jan 7, 2022
@snaow snaow deleted the 1820-qadocs-migrate-wazuh-db branch January 7, 2022 08:10
@snaow snaow mentioned this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qa-docs: Migrate test_wazuh_db documentation to schema 2.0
4 participants