mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 09:06:06 +00:00
- Introduced a new module to determine the process role based on command-line arguments, enhancing PostgreSQL connection labeling for better monitoring. - Updated the database connection parameters to include the application name derived from the process role. - Added unit tests to validate the process role detection logic for different scenarios, including Celery and uWSGI.
18 lines
602 B
Python
18 lines
602 B
Python
from unittest.mock import patch
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
from dispatcharr.db.process_label import get_process_role
|
|
|
|
|
|
class ProcessLabelTests(SimpleTestCase):
|
|
def test_celery_worker_not_labeled_as_uwsgi(self):
|
|
role = get_process_role(
|
|
["/dispatcharrpy/bin/celery", "-A", "dispatcharr", "worker"]
|
|
)
|
|
self.assertEqual(role, "celery-worker")
|
|
|
|
def test_uwsgi_labeled_when_gevent_support(self):
|
|
with patch.dict("os.environ", {"GEVENT_SUPPORT": "True"}):
|
|
role = get_process_role(["uwsgi"])
|
|
self.assertEqual(role, "uwsgi")
|