Skip to content

Conversation

@c-bordon
Copy link
Member

@c-bordon c-bordon commented Dec 23, 2025

close #954

Description

Two PR checks are added, one to validate EKS and another to validate the local deployment with MiniKube.

Tests

https://github.com/wazuh/wazuh-kubernetes/actions/runs/20525640321/job/58968384522?pr=1273

Note

The test failure is expected because it is related to the problem indicated here: #1268 (comment)

EKS test: https://github.com/wazuh/wazuh-kubernetes/actions/runs/20525640306/job/58968384486?pr=1273

Note

The EKS test will be executed on demand

@c-bordon c-bordon requested a review from a team December 23, 2025 17:56
@c-bordon c-bordon self-assigned this Dec 23, 2025
@c-bordon c-bordon linked an issue Dec 23, 2025 that may be closed by this pull request
2 tasks
@c-bordon c-bordon marked this pull request as ready for review December 24, 2025 16:40
teddytpc1
teddytpc1 previously approved these changes Dec 26, 2025
@c-bordon
Copy link
Member Author

Local test execution:

cbordon@cbordon-HP-255-15-6-inch-G10-Notebook-PC:~/Documents/wazuh/repositorios/wazuh-kubernetes$ pytest tests/k8s_pytest.py --deployment-type local -v
=========================================================================================================== test session starts ============================================================================================================
platform linux -- Python 3.12.3, pytest-7.4.4, pluggy-1.4.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/cbordon/Documents/wazuh/repositorios/wazuh-kubernetes
collected 6 items                                                                                                                                                                                                                          

tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_cluster_health FAILED                                                                                                                                                         [ 16%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_indices_health PASSED                                                                                                                                                         [ 33%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_nodes_count PASSED                                                                                                                                                            [ 50%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_wazuh_templates PASSED                                                                                                                                                                [ 66%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_manager_services_running FAILED                                                                                                                                                       [ 83%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_dashboard_service_url PASSED                                                                                                                                                          [100%]

================================================================================================================= FAILURES =================================================================================================================
_____________________________________________________________________________________________ TestWazuhKubernetes.test_indexer_cluster_health ______________________________________________________________________________________________

self = <k8s_pytest.TestWazuhKubernetes object at 0x708d52f81d00>, namespace = 'wazuh'

    def test_indexer_cluster_health(self, namespace):
        """Check if Wazuh indexer cluster health is green"""
        cmd = f'kubectl -n {namespace} exec -it wazuh-indexer-0 -- curl -XGET "https://localhost:9200/_cluster/health" -u {ADMIN_USER}:{ADMIN_PASSWORD} -k -s'
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
        print(f"Cluster health status: {result.stdout}")
>       assert "green" in result.stdout, "Cluster health is not green"
E       AssertionError: Cluster health is not green
E       assert 'green' in '{"cluster_name":"wazuh-cluster","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"discovered_master":true,"discovered_cluster_manager":true,"active_primary_shards":119,"active_shards":119,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":39,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":75.31645569620254}'
E        +  where '{"cluster_name":"wazuh-cluster","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"discovered_master":true,"discovered_cluster_manager":true,"active_primary_shards":119,"active_shards":119,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":39,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":75.31645569620254}' = CompletedProcess(args='kubectl -n wazuh exec -it wazuh-indexer-0 -- curl -XGET "https://localhost:9200/_cluster/health" -u admin:admin -k -s', returncode=0, stdout='{"cluster_name":"wazuh-cluster","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"discovered_master":true,"discovered_cluster_manager":true,"active_primary_shards":119,"active_shards":119,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":39,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":75.31645569620254}', stderr='Defaulted container "wazuh-indexer" out of: wazuh-indexer, volume-mount-hack (init), increase-the-vm-max-map-count (init)\nUnable to use a TTY - input is not a terminal or the right kind of file\n').stdout

tests/k8s_pytest.py:29: AssertionError
----------------------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------------------
Cluster health status: {"cluster_name":"wazuh-cluster","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"discovered_master":true,"discovered_cluster_manager":true,"active_primary_shards":119,"active_shards":119,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":39,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":75.31645569620254}
____________________________________________________________________________________________ TestWazuhKubernetes.test_manager_services_running _____________________________________________________________________________________________

self = <k8s_pytest.TestWazuhKubernetes object at 0x708d52fc26f0>, namespace = 'wazuh'

    def test_manager_services_running(self, namespace):
        """Check if Wazuh manager has at least 10 services running"""
        cmd = f'kubectl -n {namespace} exec -it wazuh-manager-master-0 -- /var/ossec/bin/wazuh-control status'
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
        print("Wazuh Manager services status:")
        print(result.stdout)
    
        running_services = len(re.findall(r'is running', result.stdout))
        print(f"Running services: {running_services}")
    
>       assert running_services >= 10, f"Expected at least 10 running services, found {running_services}"
E       AssertionError: Expected at least 10 running services, found 9
E       assert 9 >= 10

tests/k8s_pytest.py:83: AssertionError
----------------------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------------------
Wazuh Manager services status:
wazuh-clusterd is running...
wazuh-modulesd is running...
wazuh-monitord is running...
wazuh-logcollector is running...
wazuh-remoted is running...
wazuh-syscheckd is running...
wazuh-analysisd not running...
wazuh-execd is running...
wazuh-db is running...
wazuh-authd is running...
wazuh-apid not running...

Running services: 9
========================================================================================================= short test summary info ==========================================================================================================
FAILED tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_cluster_health - AssertionError: Cluster health is not green
FAILED tests/k8s_pytest.py::TestWazuhKubernetes::test_manager_services_running - AssertionError: Expected at least 10 running services, found 9
======================================================================================================= 2 failed, 4 passed in 0.97s ========================================================================================================

@c-bordon
Copy link
Member Author

Local test for EKS:

cbordon@cbordon-HP-255-15-6-inch-G10-Notebook-PC:~/Documents/wazuh/repositorios/wazuh-kubernetes$ pytest tests/k8s_pytest.py --deployment-type eks --dashboard-url "a0f7c065aa8f84b2bb9a31501127b190-52b2fcfec4f935d5.elb.us-west-1.amazonaws.com" -v
=========================================================================================================== test session starts ============================================================================================================
platform linux -- Python 3.12.3, pytest-7.4.4, pluggy-1.4.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/cbordon/Documents/wazuh/repositorios/wazuh-kubernetes
collected 6 items                                                                                                                                                                                                                          

tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_cluster_health PASSED                                                                                                                                                         [ 16%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_indices_health PASSED                                                                                                                                                         [ 33%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_indexer_nodes_count PASSED                                                                                                                                                            [ 50%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_wazuh_templates PASSED                                                                                                                                                                [ 66%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_manager_services_running PASSED                                                                                                                                                       [ 83%]
tests/k8s_pytest.py::TestWazuhKubernetes::test_dashboard_service_url PASSED                                                                                                                                                          [100%]

============================================================================================================ 6 passed in 24.62s ============================================================================================================

@teddytpc1 teddytpc1 merged commit eab7eaf into main Dec 26, 2025
1 check failed
@teddytpc1 teddytpc1 deleted the change/954-development-kubernetes-adapt-the-pr-tests branch December 26, 2025 17:59
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.

Development - Kubernetes - Adapt the PR tests

4 participants