Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint_format_checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.14"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
29 changes: 10 additions & 19 deletions tests/agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()

Expand All @@ -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.
Expand All @@ -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()

Expand Down
Loading