Files
awx/awx_collection/test/awx/test_instance.py
Seth Foster 69102cf265 Remove receptor_address module from collection
After removing CRUD from receptor addresses, we need
to remove the module.

- remove receptor_address module
- Add listener_port to instance module
- Add peers_from_control_nodes to instance module

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
2024-02-02 10:37:41 -05:00

47 lines
1.4 KiB
Python

from __future__ import absolute_import, division, print_function
__metaclass__ = type
import pytest
from awx.main.models import Instance
from django.test.utils import override_settings
@pytest.mark.django_db
def test_peers_adding_and_removing(run_module, admin_user):
with override_settings(IS_K8S=True):
result = run_module(
'instance',
{'hostname': 'hopnode', 'node_type': 'hop', 'node_state': 'installed', 'listener_port': 6789},
admin_user,
)
assert result['changed']
hop_node = Instance.objects.get(pk=result.get('id'))
assert hop_node.node_type == 'hop'
address = hop_node.receptor_addresses.get(pk=result.get('id'))
assert address.port == 6789
result = run_module(
'instance',
{'hostname': 'executionnode', 'node_type': 'execution', 'node_state': 'installed', 'peers': ['hopnode']},
admin_user,
)
assert result['changed']
execution_node = Instance.objects.get(pk=result.get('id'))
assert set(execution_node.peers.all()) == {address}
result = run_module(
'instance',
{'hostname': 'executionnode', 'node_type': 'execution', 'node_state': 'installed', 'peers': []},
admin_user,
)
assert result['changed']
assert set(execution_node.peers.all()) == set()