From f882ac420d473f6b4950ce7e62118250375dd63e Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Wed, 9 Jun 2021 12:41:34 -0400 Subject: [PATCH] Fix tests --- .../tests/functional/api/test_instance_group.py | 4 +++- awx/main/tests/functional/conftest.py | 9 +++++++-- .../task_management/test_container_groups.py | 3 ++- .../functional/test_execution_environments.py | 14 -------------- .../functional/test_inventory_source_injectors.py | 3 ++- awx/main/tests/unit/test_tasks.py | 3 ++- awx_collection/test/awx/conftest.py | 2 +- 7 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 awx/main/tests/functional/test_execution_environments.py diff --git a/awx/main/tests/functional/api/test_instance_group.py b/awx/main/tests/functional/api/test_instance_group.py index 22309df142..8e4cc03844 100644 --- a/awx/main/tests/functional/api/test_instance_group.py +++ b/awx/main/tests/functional/api/test_instance_group.py @@ -105,7 +105,9 @@ def test_delete_instance_group_jobs_running(delete, instance_group_jobs_running, @pytest.mark.django_db -def test_delete_rename_tower_instance_group_prevented(delete, options, tower_instance_group, instance_group, user, patch, execution_environment): +def test_delete_rename_tower_instance_group_prevented( + delete, options, tower_instance_group, instance_group, user, patch, control_plane_execution_environment, default_job_execution_environment +): url = reverse("api:instance_group_detail", kwargs={'pk': tower_instance_group.pk}) super_user = user('bob', True) diff --git a/awx/main/tests/functional/conftest.py b/awx/main/tests/functional/conftest.py index 1150c025aa..a37f34f919 100644 --- a/awx/main/tests/functional/conftest.py +++ b/awx/main/tests/functional/conftest.py @@ -824,5 +824,10 @@ def slice_job_factory(slice_jt_factory): @pytest.fixture -def execution_environment(): - return ExecutionEnvironment.objects.create(name="test-ee", description="test-ee", managed_by_tower=True) +def control_plane_execution_environment(): + return ExecutionEnvironment.objects.create(name="Control Plane EE", managed_by_tower=True) + + +@pytest.fixture +def default_job_execution_environment(): + return ExecutionEnvironment.objects.create(name="Default Job EE", managed_by_tower=False) diff --git a/awx/main/tests/functional/task_management/test_container_groups.py b/awx/main/tests/functional/task_management/test_container_groups.py index 7bbdac218d..33a0f72392 100644 --- a/awx/main/tests/functional/task_management/test_container_groups.py +++ b/awx/main/tests/functional/task_management/test_container_groups.py @@ -35,7 +35,8 @@ def test_containerized_job(containerized_job): @pytest.mark.django_db -def test_kubectl_ssl_verification(containerized_job, execution_environment): +def test_kubectl_ssl_verification(containerized_job, default_job_execution_environment): + containerized_job.execution_environment = default_job_execution_environment cred = containerized_job.instance_group.credential cred.inputs['verify_ssl'] = True key_material = subprocess.run('openssl genrsa 2> /dev/null', shell=True, check=True, stdout=subprocess.PIPE) diff --git a/awx/main/tests/functional/test_execution_environments.py b/awx/main/tests/functional/test_execution_environments.py deleted file mode 100644 index c47f0d9859..0000000000 --- a/awx/main/tests/functional/test_execution_environments.py +++ /dev/null @@ -1,14 +0,0 @@ -import pytest - -from awx.main.models import ExecutionEnvironment - - -@pytest.mark.django_db -def test_execution_environment_creation(execution_environment, organization): - execution_env = ExecutionEnvironment.objects.create( - name='Hello Environment', image='', organization=organization, managed_by_tower=False, credential=None, pull='missing' - ) - assert type(execution_env) is type(execution_environment) - assert execution_env.organization == organization - assert execution_env.name == 'Hello Environment' - assert execution_env.pull == 'missing' diff --git a/awx/main/tests/functional/test_inventory_source_injectors.py b/awx/main/tests/functional/test_inventory_source_injectors.py index aff0356b59..f011e51104 100644 --- a/awx/main/tests/functional/test_inventory_source_injectors.py +++ b/awx/main/tests/functional/test_inventory_source_injectors.py @@ -182,7 +182,8 @@ def create_reference_data(source_dir, env, content): @pytest.mark.django_db @pytest.mark.parametrize('this_kind', CLOUD_PROVIDERS) def test_inventory_update_injected_content(this_kind, inventory, fake_credential_factory): - ExecutionEnvironment.objects.create(name='test EE', managed_by_tower=True) + ExecutionEnvironment.objects.create(name='Control Plane EE', managed_by_tower=True) + ExecutionEnvironment.objects.create(name='Default Job EE', managed_by_tower=False) injector = InventorySource.injectors[this_kind] if injector.plugin_name is None: diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 4bb1e33c10..ec6c9d1bee 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -588,7 +588,8 @@ class TestGenericRun: @pytest.mark.django_db class TestAdhocRun(TestJobExecution): def test_options_jinja_usage(self, adhoc_job, adhoc_update_model_wrapper): - ExecutionEnvironment.objects.create(name='test EE', managed_by_tower=True) + ExecutionEnvironment.objects.create(name='Control Plane EE', managed_by_tower=True) + ExecutionEnvironment.objects.create(name='Default Job EE', managed_by_tower=False) adhoc_job.module_args = '{{ ansible_ssh_pass }}' adhoc_job.websocket_emit_status = mock.Mock() diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index dcd75fee11..728df5e15c 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -265,7 +265,7 @@ def silence_warning(): @pytest.fixture def execution_environment(): - return ExecutionEnvironment.objects.create(name="test-ee", description="test-ee", managed_by_tower=True) + return ExecutionEnvironment.objects.create(name="test-ee", description="test-ee", managed_by_tower=False) @pytest.fixture(scope='session', autouse=True)