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

fix test_sync_agent_groups_get and add function to calculate hash #3895

Merged
merged 4 commits into from
Feb 7, 2023

Conversation

QU3B1M
Copy link
Member

@QU3B1M QU3B1M commented Feb 3, 2023

Related issue
#3890

Description

A fix on the calculation of the global groups hash made test_sync_agent_groups_get fail, with this modification now wazuh excludes the groups of the agent 000 from the calculation of the global_hash. It was found that our test uses an hardcoded hash that was wrongly calculated (using the agent 000 group to make the hash).

A function to calculate the correct hash was added in the wazuh_db module

Updated

  • tests/integration/test_wazuh_db/test_sync_agent_groups_get.py
  • tests/integration/test_wazuh_db/data/global/sync_agent_groups_get.yaml
  • deps/wazuh_testing/wazuh_testing/wazuh_db.py

Testing performed

Tester Test path Jenkins Local OS Commit Notes
@QU3B1M (Developer) integration/test_wazuh_db/ 🟢 🟢 🟢 🟢 🟢 🟢 Ubuntu 22.04 cf6d5ad Nothing to highlight
@jmv74211 (Reviewer) ⚫⚫⚫ 🚫 🚫 🚫 Nothing to highlight

@QU3B1M QU3B1M changed the base branch from master to 4.4 February 3, 2023 20:22
@QU3B1M QU3B1M marked this pull request as ready for review February 3, 2023 20:26
@QU3B1M QU3B1M force-pushed the 3890-fix-wazuhdb-sync-agent-groups branch from f4e3999 to f362438 Compare February 3, 2023 21:18
@QU3B1M QU3B1M force-pushed the 3890-fix-wazuhdb-sync-agent-groups branch from f362438 to cf6d5ad Compare February 3, 2023 21:36
@QU3B1M QU3B1M requested a review from jmv74211 February 3, 2023 21:51
@QU3B1M QU3B1M linked an issue Feb 3, 2023 that may be closed by this pull request
Copy link
Contributor

@jmv74211 jmv74211 left a comment

Choose a reason for hiding this comment

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

I have run the test for the 4.4 branch and the 4.4 fixed version (PR package) and in both cases the following test has failed:

test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test get_global_hash in true] FAILED [ 54%]

       assert str(response) == output, "Did not get expected response: {output}, recieved: {response}"
E       AssertionError: Did not get expected response: {output}, recieved: {response}
E       assert "[{'data': [{...cad2cb0bfd'}]" == "[{'data': [{...2505a946d7'}]"
E         - [{'data': [{'id': 1, 'groups': ['Test_group1']}, {'id': 2, 'groups': ['Test_group2']}], 'hash': '0ce72e59092cdb4856971082827aeb2505a946d7'}]
E         ?                                                                                                  ^^^^^^^  ------ --- ---------------
E         + [{'data': [{'id': 1, 'groups': ['Test_group1']}, {'id': 2, 'groups': ['Test_group2']}], 'hash': '49087946dd7a587ae30ae89cbc8084cad2cb0bfd'}]
E         ?                                                                                                  ^        + +++++++++++++++++++++++++++++

test_wazuh_db/test_sync_agent_groups_get.py:136: AssertionError
============================================================= short test summary info =============================================================
FAILED test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test get_global_hash in true]
========================================================== 1 failed, 21 passed in 46.43s ==========================================================

Please @QU3B1M check it.

@QU3B1M
Copy link
Member Author

QU3B1M commented Feb 6, 2023

@jmv74211 Its weird, I executed the tests on Jenkins (here) and it work as expected, maybe you took the package from the manual issue that was outdated (just now I updated it) please, try again with this package. Anyway it will fail with the 4.4 package as the tests sets an group hash to the agent 000 and wazuh does not have the fix to avoid it when calculating the hash

Copy link
Contributor

@jmv74211 jmv74211 left a comment

Choose a reason for hiding this comment

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

After testing with the new package, the tests have passed successfully

test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test sync_status with response] PASSED                                                   [  4%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test sync_status without response] PASSED                                                [  9%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'all' condition when agent groups are in 'sync_req'] PASSED                         [ 13%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'all' condition when agent groups are in 'synced'] PASSED                           [ 18%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'sync_status' condition when one agent groups are in 'synced'] PASSED               [ 22%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'all' condition when one agent groups are in 'synced'] PASSED                       [ 27%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test with and invalid filter in condition] PASSED                                        [ 31%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test without condition] PASSED                                                           [ 36%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test set_synced in True] PASSED                                                          [ 40%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test set_synced with invalid value - false] PASSED                                       [ 45%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test set_synced with invalid value - String] PASSED                                      [ 50%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test get_global_hash in true] PASSED                                                     [ 54%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test get_global_hash in false] PASSED                                                    [ 59%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test get_global_hash with invalid value] PASSED                                          [ 63%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'agent_registration_delta' in 0 and sync_status] PASSED                             [ 68%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'agent_registration_delta' in 0 and all condition] PASSED                           [ 72%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'agent_registration_delta' with delta in 10000 and sync_status] PASSED              [ 77%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test 'agent_registration_delta' with delta in 10000 and all] PASSED                      [ 81%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test last_id - by default] PASSED                                                        [ 86%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test last_id - obtain from second group] PASSED                                          [ 90%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test last_id - with not exist id] PASSED                                                 [ 95%]
test_wazuh_db/test_sync_agent_groups_get.py::test_sync_agent_groups[/home/vagrant/wazuh-qa/tests/integration/test: Test last_id - with negative value] PASSED                                               [100%]

=============================================================================================== 22 passed in 48.36s ===============================================================================================

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.

Fix test_sync_agent_groups_get.py
2 participants