-
Notifications
You must be signed in to change notification settings - Fork 32
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
Full Yellow Local - Fix WazuhDB tests self-configuration in 4.2 #1643
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8938220
Create wauzh_manager module and add to wazuhdb tests clean_registered…
Rebits acc9f5d
Create fixture to restart wazuh-manager in wazuhdb test
Rebits af61199
Fix error in wazuh_manager list agents function and test_wazuhdb
Rebits cda0f42
Improve wazuh_manager module and fix wazuhdb tests for previous agent…
Rebits 623284d
Fix wazuh manager module
Rebits 7a438a6
Rename remove_option with remove_type
Rebits d2419f5
Remove duplicated imports
Rebits File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import subprocess | ||
from wazuh_testing.tools import WAZUH_PATH | ||
from wazuh_testing.wazuh_db import query_wdb | ||
|
||
|
||
def list_agents_ids(): | ||
wazuhdb_result = query_wdb('global get-all-agents last_id -1') | ||
list_agents = [agent['id'] for agent in wazuhdb_result if not (0 == agent.get('id'))] | ||
|
||
return list_agents | ||
|
||
|
||
def remove_agents(agents_id, remove_type='wazuhdb'): | ||
if remove_type not in ['wazuhdb', 'manage_agents']: | ||
raise ValueError("Invalid type of agent removal: %s" % remove_type) | ||
|
||
if agents_id: | ||
for agent_id in agents_id: | ||
if remove_type == 'manage_agents': | ||
subprocess.call([f"{WAZUH_PATH}/bin/manage_agents", "-r", f"{agent_id}"], stdout=open(os.devnull, "w"), | ||
stderr=subprocess.STDOUT) | ||
elif remove_type == 'wazuhdb': | ||
result = query_wdb(f"global delete-agent {str(agent_id)}") | ||
|
||
|
||
def remove_all_agents(remove_type): | ||
remove_agents(list_agents_ids(), remove_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment follows the file standard, however, maybe they are not very useful. It should be necessary to standardize all tests structure and commentaries with the rest of the team in the future.