ansible-test - Remove deprecated features (#80558)

pull/80572/head
Matt Clay 2 years ago committed by GitHub
parent 1fdeff949c
commit 7b50571588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
minor_changes:
- ansible-test - Removed the deprecated ``--docker-no-pull`` option.
- ansible-test - Removed the deprecated ``--no-pip-check`` option.
- ansible-test - Removed the deprecated ``foreman`` test plugin.
- ansible-test - Removed the deprecated ``govcsim`` support from the ``vcenter`` test plugin.

@ -1,3 +0,0 @@
cloud/foreman
shippable/generic/group1
context/controller

@ -1,6 +0,0 @@
- name: Verify endpoints respond
uri:
url: "{{ item }}"
validate_certs: no
with_items:
- http://{{ ansible_env.FOREMAN_HOST }}:{{ ansible_env.FOREMAN_PORT }}/ping

@ -1,3 +0,0 @@
cloud/vcenter
shippable/generic/group1
context/controller

@ -1,6 +0,0 @@
- name: Verify endpoints respond
uri:
url: "{{ item }}"
validate_certs: no
with_items:
- http://{{ vcenter_hostname }}:5000/ # control endpoint for the simulator

@ -146,12 +146,6 @@ def add_global_options(
help='install command requirements',
)
global_parser.add_argument(
'--no-pip-check',
action='store_true',
help=argparse.SUPPRESS, # deprecated, kept for now (with a warning) for backwards compatibility
)
add_global_remote(global_parser, controller_mode)
add_global_docker(global_parser, controller_mode)
@ -396,7 +390,6 @@ def add_global_docker(
"""Add global options for Docker."""
if controller_mode != ControllerMode.DELEGATED:
parser.set_defaults(
docker_no_pull=False,
docker_network=None,
docker_terminate=None,
prime_containers=False,
@ -406,12 +399,6 @@ def add_global_docker(
return
parser.add_argument(
'--docker-no-pull',
action='store_true',
help=argparse.SUPPRESS, # deprecated, kept for now (with a warning) for backwards compatibility
)
parser.add_argument(
'--docker-network',
metavar='NET',

@ -1,102 +0,0 @@
"""Foreman plugin for integration tests."""
from __future__ import annotations
import os
from ....config import (
IntegrationConfig,
)
from ....containers import (
CleanupMode,
run_support_container,
)
from ....util import (
display,
)
from . import (
CloudEnvironment,
CloudEnvironmentConfig,
CloudProvider,
)
class ForemanProvider(CloudProvider):
"""Foreman plugin. Sets up Foreman stub server for tests."""
DOCKER_SIMULATOR_NAME = 'foreman-stub'
# Default image to run Foreman stub from.
#
# The simulator must be pinned to a specific version
# to guarantee CI passes with the version used.
#
# It's source source itself resides at:
# https://github.com/ansible/foreman-test-container
DOCKER_IMAGE = 'quay.io/ansible/foreman-test-container:1.4.0'
def __init__(self, args: IntegrationConfig) -> None:
super().__init__(args)
self.__container_from_env = os.environ.get('ANSIBLE_FRMNSIM_CONTAINER')
"""
Overrides target container, might be used for development.
Use ANSIBLE_FRMNSIM_CONTAINER=whatever_you_want if you want
to use other image. Omit/empty otherwise.
"""
self.image = self.__container_from_env or self.DOCKER_IMAGE
self.uses_docker = True
def setup(self) -> None:
"""Setup cloud resource before delegation and reg cleanup callback."""
super().setup()
display.warning('The foreman test plugin is deprecated and will be removed in a future version of ansible-test.')
if self._use_static_config():
self._setup_static()
else:
self._setup_dynamic()
def _setup_dynamic(self) -> None:
"""Spawn a Foreman stub within docker container."""
foreman_port = 8080
ports = [
foreman_port,
]
run_support_container(
self.args,
self.platform,
self.image,
self.DOCKER_SIMULATOR_NAME,
ports,
allow_existing=True,
cleanup=CleanupMode.YES,
)
self._set_cloud_config('FOREMAN_HOST', self.DOCKER_SIMULATOR_NAME)
self._set_cloud_config('FOREMAN_PORT', str(foreman_port))
def _setup_static(self) -> None:
raise NotImplementedError()
class ForemanEnvironment(CloudEnvironment):
"""Foreman environment plugin. Updates integration test environment after delegation."""
def get_environment_config(self) -> CloudEnvironmentConfig:
"""Return environment configuration for use in the test environment after delegation."""
env_vars = dict(
FOREMAN_HOST=str(self._get_cloud_config('FOREMAN_HOST')),
FOREMAN_PORT=str(self._get_cloud_config('FOREMAN_PORT')),
)
return CloudEnvironmentConfig(
env_vars=env_vars,
)

@ -2,7 +2,6 @@
from __future__ import annotations
import configparser
import os
from ....util import (
ApplicationError,
@ -13,15 +12,6 @@ from ....config import (
IntegrationConfig,
)
from ....containers import (
CleanupMode,
run_support_container,
)
from .... data import (
data_context,
)
from . import (
CloudEnvironment,
CloudEnvironmentConfig,
@ -32,74 +22,16 @@ from . import (
class VcenterProvider(CloudProvider):
"""VMware vcenter/esx plugin. Sets up cloud resources for tests."""
DOCKER_SIMULATOR_NAME = 'vcenter-simulator'
def __init__(self, args: IntegrationConfig) -> None:
super().__init__(args)
# The simulator must be pinned to a specific version to guarantee CI passes with the version used.
if os.environ.get('ANSIBLE_VCSIM_CONTAINER'):
self.image = os.environ.get('ANSIBLE_VCSIM_CONTAINER')
else:
self.image = 'quay.io/ansible/vcenter-test-container:1.7.0'
# VMware tests can be run on govcsim or BYO with a static config file.
# When testing ansible-core, the simulator is the default if no config is provided. This facilitates easier testing of the plugin's container support.
# When testing a collection, static config is the default if no config is provided.
default_mode = 'govcsim' if data_context().content.is_ansible else 'static'
self.vmware_test_platform = os.environ.get('VMWARE_TEST_PLATFORM', default_mode)
if self.vmware_test_platform == 'govcsim':
display.warning(
'The govcsim simulator is deprecated and will be removed in a future version of ansible-test. Use a static configuration instead.',
unique=True,
)
self.uses_docker = True
self.uses_config = False
elif self.vmware_test_platform == 'static':
self.uses_docker = False
self.uses_config = True
def setup(self) -> None:
"""Setup the cloud resource before delegation and register a cleanup callback."""
super().setup()
self._set_cloud_config('vmware_test_platform', self.vmware_test_platform)
if self.vmware_test_platform == 'govcsim':
self._setup_dynamic_simulator()
self.managed = True
elif self.vmware_test_platform == 'static':
self._use_static_config()
self._setup_static()
else:
raise ApplicationError('Unknown vmware_test_platform: %s' % self.vmware_test_platform)
def _setup_dynamic_simulator(self) -> None:
"""Create a vcenter simulator using docker."""
ports = [
443,
8080,
8989,
5000, # control port for flask app in simulator
]
run_support_container(
self.args,
self.platform,
self.image,
self.DOCKER_SIMULATOR_NAME,
ports,
allow_existing=True,
cleanup=CleanupMode.YES,
)
self._set_cloud_config('vcenter_hostname', self.DOCKER_SIMULATOR_NAME)
def _setup_static(self) -> None:
if not os.path.exists(self.config_static_path):
if not self._use_static_config():
raise ApplicationError('Configuration file does not exist: %s' % self.config_static_path)
@ -108,37 +40,21 @@ class VcenterEnvironment(CloudEnvironment):
def get_environment_config(self) -> CloudEnvironmentConfig:
"""Return environment configuration for use in the test environment after delegation."""
try:
# We may be in a container, so we cannot just reach VMWARE_TEST_PLATFORM,
# We do a try/except instead
parser = configparser.ConfigParser()
parser.read(self.config_path) # static
env_vars = {}
ansible_vars = dict(
resource_prefix=self.resource_prefix,
)
ansible_vars.update(dict(parser.items('DEFAULT', raw=True)))
except KeyError: # govcsim
env_vars = dict(
VCENTER_HOSTNAME=str(self._get_cloud_config('vcenter_hostname')),
VCENTER_USERNAME='user',
VCENTER_PASSWORD='pass',
)
ansible_vars = dict(
vcsim=str(self._get_cloud_config('vcenter_hostname')),
vcenter_hostname=str(self._get_cloud_config('vcenter_hostname')),
vcenter_username='user',
vcenter_password='pass',
)
for key, value in ansible_vars.items():
if key.endswith('_password'):
display.sensitive.add(value)
return CloudEnvironmentConfig(
env_vars=env_vars,
ansible_vars=ansible_vars,
module_defaults={
'group/vmware': {

@ -8,7 +8,6 @@ import sys
import typing as t
from .util import (
display,
verify_sys_executable,
version_to_str,
type_guard,
@ -136,12 +135,6 @@ class EnvironmentConfig(CommonConfig):
data_context().register_payload_callback(host_callback)
if args.docker_no_pull:
display.warning('The --docker-no-pull option is deprecated and has no effect. It will be removed in a future version of ansible-test.')
if args.no_pip_check:
display.warning('The --no-pip-check option is deprecated and has no effect. It will be removed in a future version of ansible-test.')
@property
def controller(self) -> ControllerHostConfig:
"""Host configuration for the controller."""

@ -325,7 +325,6 @@ def filter_options(
) -> c.Iterable[str]:
"""Return an iterable that filters out unwanted CLI options and injects new ones as requested."""
replace: list[tuple[str, int, t.Optional[t.Union[bool, str, list[str]]]]] = [
('--docker-no-pull', 0, False),
('--truncate', 1, str(args.truncate)),
('--color', 1, 'yes' if args.color else 'no'),
('--redact', 0, False),

Loading…
Cancel
Save