Skip to content

Commit

Permalink
ansible-test - Remove deprecated features (ansible#80558)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclay authored Apr 19, 2023
1 parent 1fdeff9 commit 7b50571
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 236 deletions.
5 changes: 5 additions & 0 deletions changelogs/fragments/ansible-test-deprecated-cleanup.yml
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 0 additions & 3 deletions test/integration/targets/ansible-test-cloud-foreman/aliases

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions test/integration/targets/ansible-test-cloud-vcenter/aliases

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions test/lib/ansible_test/_internal/cli/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down
102 changes: 0 additions & 102 deletions test/lib/ansible_test/_internal/commands/integration/cloud/foreman.py

This file was deleted.

106 changes: 11 additions & 95 deletions test/lib/ansible_test/_internal/commands/integration/cloud/vcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

import configparser
import os

from ....util import (
ApplicationError,
Expand All @@ -13,15 +12,6 @@
IntegrationConfig,
)

from ....containers import (
CleanupMode,
run_support_container,
)

from .... data import (
data_context,
)

from . import (
CloudEnvironment,
CloudEnvironmentConfig,
Expand All @@ -32,74 +22,16 @@
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
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)


Expand All @@ -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',
)
# 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

ansible_vars = dict(
resource_prefix=self.resource_prefix,
)
ansible_vars.update(dict(parser.items('DEFAULT', raw=True)))

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': {
Expand Down
7 changes: 0 additions & 7 deletions test/lib/ansible_test/_internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import typing as t

from .util import (
display,
verify_sys_executable,
version_to_str,
type_guard,
Expand Down Expand Up @@ -136,12 +135,6 @@ def host_callback(payload_config: PayloadConfig) -> None:

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."""
Expand Down
1 change: 0 additions & 1 deletion test/lib/ansible_test/_internal/delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 7b50571

Please sign in to comment.