mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 02:01:01 -03:30
* WIP First pass * started removing feature flags and adjusting logic * Add decorator * moved to dispatcher decorator * updated as many as I could find * Keep callback receiver working * remove any code that is not used by the call back receiver * add back auto_max_workers * added back get_auto_max_workers into common utils * Remove control and hazmat (squash this not done) * moved status out and deleted control as no longer needed * removed unused imports * adjusted test import to pull correct method * fixed imports and addressed clusternode heartbeat test * Update function comments * Add back hazmat for config and remove baseworker * added back hazmat per @alancoding feedback around config * removed baseworker completely and refactored it into the callback worker * Fix dispatcher run call and remove dispatch setting * remove dispatcher mock publish setting * Adjust heartbeat arg and more formatting * fixed the call to cluster_node_heartbeat missing binder * Fix attribute error in server logs
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import pytest
|
|
|
|
# AWX
|
|
from awx.main.ha import is_ha_environment
|
|
from awx.main.models.ha import Instance
|
|
from awx.main.utils.common import get_auto_max_workers
|
|
|
|
# Django
|
|
from django.test.utils import override_settings
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_multiple_instances():
|
|
for i in range(2):
|
|
Instance.objects.create(hostname=f'foo{i}', node_type='hybrid')
|
|
assert is_ha_environment()
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_db_localhost():
|
|
Instance.objects.create(hostname='foo', node_type='hybrid')
|
|
Instance.objects.create(hostname='bar', node_type='execution')
|
|
assert is_ha_environment() is False
|
|
|
|
|
|
@pytest.mark.django_db
|
|
@pytest.mark.parametrize(
|
|
'settings',
|
|
[
|
|
dict(SYSTEM_TASK_ABS_MEM='16Gi', SYSTEM_TASK_ABS_CPU='24', SYSTEM_TASK_FORKS_MEM=400, SYSTEM_TASK_FORKS_CPU=4),
|
|
dict(SYSTEM_TASK_ABS_MEM='124Gi', SYSTEM_TASK_ABS_CPU='2', SYSTEM_TASK_FORKS_MEM=None, SYSTEM_TASK_FORKS_CPU=None),
|
|
],
|
|
ids=['cpu_dominated', 'memory_dominated'],
|
|
)
|
|
def test_dispatcher_max_workers_reserve(settings, fake_redis):
|
|
"""This tests that the dispatcher max_workers matches instance capacity
|
|
|
|
Assumes capacity_adjustment is 1,
|
|
plus reserve worker count
|
|
"""
|
|
with override_settings(**settings):
|
|
i = Instance.objects.create(hostname='test-1', node_type='hybrid')
|
|
i.local_health_check()
|
|
|
|
assert get_auto_max_workers() == i.capacity + 7, (i.cpu, i.memory, i.cpu_capacity, i.mem_capacity)
|