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

Update system tests for agent key polling #2119

Merged
merged 2 commits into from
Oct 29, 2021

Conversation

juanmanuelug
Copy link

Related issue
#2044

Description

Hi team,

In this PR, we aim to fix the system test for agent key polling that was being skipped and update it to support the agent key polling on cluster enviroment.

Configuration options

---
wazuh-master:
  description: Enable remoted agent_key_polling at master side
  sections:
  - section: remote
    elements:
      - connection:
          value: secure
      - port:
          value: 1514
      - protocol:
          value: tcp
      - queue_size:
          value: 131072
  - section: wodle
    attributes:
      - name: 'agent-key-polling'
    elements:
      - enabled:
          value: 'yes'
      - timeout:
          value: 60
      - exec_path:
          value: '/var/ossec/framework/python/bin/python3 /tmp/fetch_keys.py'
      - threads:
          value: 1
      - queue_size:
          value: 1024
      - force_insert:
          value: 'yes'

wazuh-worker1:
  description: Enable remoted agent_key_polling at worker side
  sections:
  - section: remote
    elements:
      - connection:
          value: secure
      - port:
          value: 1514
      - protocol:
          value: tcp
      - queue_size:
          value: 131072

Logs example

python3 -m pytest -vvsx test_agent_key_polling.py

================================================= test session starts ==================================================platform linux -- Python 3.6.9, pytest-4.5.0, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.6.9', 'Platform': 'Linux-4.15.0-159-generic-x86_64-with-Ubuntu-18.04-bionic', 'Packages': {'pytest': '4.5.0', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'testinfra': '5.0.0', 'metadata': '1.11.0', 'html': '2.0.1'}}
rootdir: /home/juanma/wazuh-qa/tests/system/test_cluster/test_agent_key_polling
plugins: testinfra-5.0.0, metadata-1.11.0, html-2.0.1
collected 1 item

test_agent_key_polling.py::test_agent_key_polling 2021-10-25 18:29:58,977 - wazuh_testing - DEBUG - Add new file composer process for wazuh-master and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:58,982 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-master and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:58,988 - wazuh_testing - DEBUG - Add new file composer process for wazuh-worker1 and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:58,998 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-worker1 and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:58,995 - wazuh_testing - DEBUG - Starting file composer for wazuh-master and path: /var/ossec/logs/ossec.log. Composite file in /home/juanma/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-master_ossec.log.tmp
2021-10-25 18:29:59,004 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-master and message: .*Agent key generated for agent 'wazuh-agent2'.*
2021-10-25 18:29:59,005 - wazuh_testing - DEBUG - Starting file composer for wazuh-worker1 and path: /var/ossec/logs/ossec.log. Composite file in /home/juanma/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-worker1_ossec.log.tmp
2021-10-25 18:29:59,016 - wazuh_testing - DEBUG - Add new file composer process for wazuh-agent2 and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:59,025 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-worker1 and message: .*Agent key generated for 'wazuh-agent2'.*
2021-10-25 18:29:59,030 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-agent2 and path: /var/ossec/logs/ossec.log
2021-10-25 18:29:59,033 - wazuh_testing - DEBUG - Starting file composer for wazuh-agent2 and path: /var/ossec/logs/ossec.log. Composite file in /home/juanma/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-agent2_ossec.log.tmp
2021-10-25 18:29:59,057 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Lost connection with manager. Setting lock.*
2021-10-25 18:30:00,062 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Lost connection with manager. Setting lock.*
2021-10-25 18:30:00,063 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Trying to connect to server \(wazuh-worker1.*
2021-10-25 18:30:00,065 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Trying to connect to server \(wazuh-worker1.*
2021-10-25 18:30:00,065 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Connected to the server \(wazuh-worker1.*
2021-10-25 18:30:39,743 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-worker1 and message: .*Agent key generated for 'wazuh-agent2'.*
2021-10-25 18:30:40,179 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-master and message: .*Agent key generated for agent 'wazuh-agent2'.*
2021-10-25 18:30:59,308 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Connected to the server \(wazuh-worker1.*
2021-10-25 18:31:00,325 - wazuh_testing - DEBUG - Cleaning temporal files...
2021-10-25 18:31:00,326 - wazuh_testing - DEBUG - Checking results...
2021-10-25 18:31:00,329 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/25 18:29:58 wazuh-agentd: ERROR: (1137): Lost connection with manager. Setting lock.
2021-10-25 18:31:00,330 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/25 18:29:58 wazuh-agentd: INFO: Trying to connect to server (wazuh-worker1/172.18.0.3:1514/tcp).
2021-10-25 18:31:00,331 - wazuh_testing - DEBUG - Received from wazuh-worker1 the expected message: 2021/10/25 18:30:39 wazuh-authd[8282] main-server.c:649 at run_dispatcher(): INFO: Agent key generated for 'wazuh-agent2' (requested by any)2021-10-25 18:31:00,332 - wazuh_testing - DEBUG - Received from wazuh-master the expected message: 2021/10/25 18:30:38 wazuh-authd[8290] local-server.c:395 at local_add(): INFO: Agent key generated for agent 'wazuh-agent2' (requested locally)
2021-10-25 18:31:00,334 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/25 18:30:59 wazuh-agentd: INFO: (4102): Connected to the server (wazuh-worker1/172.18.0.3:1514/tcp).
PASSED

============================================== 1 passed in 161.49 seconds ==============================================

Tests

  • Proven that tests pass when they have to pass.
  • Proven that tests fail when they have to fail.
  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.
  • Python codebase is documented following the Google Style for Python docstrings.

@juanmanuelug juanmanuelug marked this pull request as ready for review October 26, 2021 08:54
@snaow snaow linked an issue Oct 29, 2021 that may be closed by this pull request
@snaow
Copy link
Contributor

snaow commented Oct 29, 2021

Locally executed. All passed.

root@test:/home/vagrant/wazuh-qa/tests/system/test_cluster/test_agent_key_polling# python3 -m pytest -vvsx test_agent_key_polling.py
============================================================================================== test session starts ==============================================================================================platform linux -- Python 3.9.7, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.9.7', 'Platform': 'Linux-5.4.0-86-generic-x86_64-with-glibc2.31', 'Packages': {'pytest': '6.2.2', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'metadata': '1.11.0', 'html': '2.0.1', 'testinfra': '5.0.0'}}
rootdir: /home/vagrant/wazuh-qa/tests/system/test_cluster/test_agent_key_polling
plugins: metadata-1.11.0, html-2.0.1, testinfra-5.0.0
collected 1 item

test_agent_key_polling.py::test_agent_key_polling 2021-10-29 17:29:53,651 - wazuh_testing - DEBUG - Add new file composer process for wazuh-master and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,659 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-master and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,671 - wazuh_testing - DEBUG - Starting file composer for wazuh-master and path: /var/ossec/logs/ossec.log. Composite file in /home/vagrant/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-master_ossec.log.tmp
2021-10-29 17:29:53,668 - wazuh_testing - DEBUG - Add new file composer process for wazuh-worker1 and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,715 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-worker1 and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,722 - wazuh_testing - DEBUG - Add new file composer process for wazuh-agent2 and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,732 - wazuh_testing - DEBUG - Add new file monitor process for wazuh-agent2 and path: /var/ossec/logs/ossec.log
2021-10-29 17:29:53,740 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-master and message: .*Agent key generated for agent 'wazuh-agent2'.*
2021-10-29 17:29:53,736 - wazuh_testing - DEBUG - Starting file composer for wazuh-worker1 and path: /var/ossec/logs/ossec.log. Composite file in /home/vagrant/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-worker1_ossec.log.tmp
2021-10-29 17:29:53,754 - wazuh_testing - DEBUG - Starting file composer for wazuh-agent2 and path: /var/ossec/logs/ossec.log. Composite file in /home/vagrant/wazuh-qa/tests/system/test_cluster/test_agent_key_polling/tmp/wazuh-agent2_ossec.log.tmp
2021-10-29 17:29:53,757 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-worker1 and message: .*Agent key generated for 'wazuh-agent2'.*
2021-10-29 17:29:53,772 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Lost connection with manager. Setting lock.*
2021-10-29 17:29:56,950 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Lost connection with manager. Setting lock.*
2021-10-29 17:29:56,955 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Trying to connect to server \(wazuh-worker1.*
2021-10-29 17:29:56,968 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Trying to connect to server \(wazuh-worker1.*
2021-10-29 17:29:56,974 - wazuh_testing - DEBUG - Starting QueueMonitor for wazuh-agent2 and message: .*Connected to the server \(wazuh-worker1.*
2021-10-29 17:30:26,552 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-master and message: .*Agent key generated for agent 'wazuh-agent2'.*
2021-10-29 17:30:26,552 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-worker1 and message: .*Agent key generated for 'wazuh-agent2'.*
2021-10-29 17:30:45,960 - wazuh_testing - DEBUG - Finishing QueueMonitor for wazuh-agent2 and message: .*Connected to the server \(wazuh-worker1.*
2021-10-29 17:30:46,568 - wazuh_testing - DEBUG - Cleaning temporal files...
2021-10-29 17:30:46,669 - wazuh_testing - DEBUG - Checking results...
2021-10-29 17:30:46,769 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/29 19:29:44 wazuh-agentd: ERROR: (1137): Lost connection with manager. Setting lock.
2021-10-29 17:30:46,774 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/29 19:29:44 wazuh-agentd: INFO: Trying to connect to server (wazuh-worker1/172.18.0.3:1514/tcp).
2021-10-29 17:30:46,776 - wazuh_testing - DEBUG - Received from wazuh-master the expected message: 2021/10/29 19:30:24 wazuh-authd[9487] local-server.c:395 at local_add(): INFO: Agent key generated for agent 'wazuh-agent2' (requested locally)
2021-10-29 17:30:46,780 - wazuh_testing - DEBUG - Received from wazuh-worker1 the expected message: 2021/10/29 19:30:25 wazuh-authd[9202] main-server.c:649 at run_dispatcher(): INFO: Agent key generated for 'wazuh-agent2' (requested by any)
2021-10-29 17:30:46,784 - wazuh_testing - DEBUG - Received from wazuh-agent2 the expected message: 2021/10/29 19:30:45 wazuh-agentd: INFO: (4102): Connected to the server (wazuh-worker1/172.18.0.3:1514/tcp).
PASSED

========================================================================================= 1 passed in 257.07s (0:04:17) =========================================================================================

@snaow snaow merged commit 8857220 into master Oct 29, 2021
@snaow snaow deleted the 2044-update-system-test-for-key-polling-on-cluster branch October 29, 2021 17:37
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update system tests for agent key polling
4 participants