diff --git a/.github/workflows/lint_format_checker.yaml b/.github/workflows/lint_format_checker.yaml index 5071bfa..812aa7f 100644 --- a/.github/workflows/lint_format_checker.yaml +++ b/.github/workflows/lint_format_checker.yaml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.11" ] + python-version: [ "3.14" ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index ca4ef50..2379c2f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,6 +1,6 @@ # This workflow use pytest: # - Install Python dependencies. -# - Run pytest for each of the supported Python versions ["3.8", "3.9", "3.10"]. +# - Run pytest for each of the supported Python versions ["3.14"]. # Running pytest with -m "no docker" to disable test that require a docker installation. name: Pytest. @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.14"] steps: - uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile index 34a73f5..9017847 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-slim as base +FROM python:3.14-slim as base FROM base as builder RUN mkdir /install WORKDIR /install @@ -11,4 +11,4 @@ COPY agent /app/agent COPY ostorlab.yaml /app/agent/ostorlab.yaml WORKDIR /app ENV PYTHONPATH=/app -CMD ["python3.11", "/app/agent/tracker_agent.py"] +CMD ["python", "/app/agent/tracker_agent.py"] diff --git a/tests/agent_test.py b/tests/agent_test.py index 1f21503..f772c62 100644 --- a/tests/agent_test.py +++ b/tests/agent_test.py @@ -41,7 +41,7 @@ def testTrackerAgentCheckQueueNotEmpty_whenQueueIsEmpty_returnFalse(): "sqlite:////tmp/ostorlab_db1.sqlite", ) def testTrackerAgentLogic_whenQueuesAreNotEmpty_killProcessesAndSend4Messages( - mocker, agent_mock, tracker_agent, requests_mock + mocker, agent_mock, tracker_agent ): """Test for the life cycle of the agent tracker. Case : The data queues start full. @@ -52,16 +52,11 @@ def testTrackerAgentLogic_whenQueuesAreNotEmpty_killProcessesAndSend4Messages( So, it should timeout, emits a message : post_scan_done_timeout, and another message : post_scan_done. """ - path = "http://guest:guest@localhost:15672/api/queues/%2F" - requests_mock.get( - path, - json=[ - {"name": "queue1", "messages": 42, "messages_unacknowledged": 0}, - {"name": "queue2", "messages": 0, "messages_unacknowledged": 0}, - ], - ) mocker.patch("agent.tracker_agent.universe.kill_universe", return_value=None) - mocker.patch.object(data_queues, "SLEEP_SEC", 0.01) + + mock_process = mocker.MagicMock() + mock_process.is_alive.return_value = True + mocker.patch("multiprocessing.Process", return_value=mock_process) tracker_agent.start() @@ -78,7 +73,7 @@ def testTrackerAgentLogic_whenQueuesAreNotEmpty_killProcessesAndSend4Messages( def testTrackerLogic_whenQueuesAreEmpty_send2messages( - mocker, agent_mock, tracker_agent, requests_mock + mocker, agent_mock, tracker_agent ): """Test for the life cycle of the agent tracker. Case : The data queues start empty. @@ -87,14 +82,10 @@ def testTrackerLogic_whenQueuesAreEmpty_send2messages( So, it should automatically emit a message : post_scan_done. """ mocker.patch("agent.tracker_agent.universe.kill_universe", return_value=None) - path = "http://guest:guest@localhost:15672/api/queues/%2F" - requests_mock.get( - path, - json=[ - {"name": "queue1", "messages": 0, "messages_unacknowledged": 0}, - {"name": "queue2", "messages": 0, "messages_unacknowledged": 0}, - ], - ) + + mock_process = mocker.MagicMock() + mock_process.is_alive.return_value = False + mocker.patch("multiprocessing.Process", return_value=mock_process) tracker_agent.start()