ansible-test: fix the vcenter+vcsim support

The vcenter provider allow one to use the `VMWARE_TEST_PLATFORM` to
manually select a test platform. The test platforms are:

- `govcsim`
- `static`
- and `worldstream`.

Before this commit, the `govcsim` value was ignored.

Example:

```shell
$ VMWARE_TEST_PLATFORM=govcsim ansible-test integration --python 3.7 needs/target/prepare_vmware_tests/
```
This commit is contained in:
Gonéri Le Bouder 2019-07-24 14:22:23 +02:00
parent 60a1545092
commit a3407682ed

View file

@ -71,7 +71,7 @@ class VcenterProvider(CloudProvider):
:type targets: tuple[TestTarget] :type targets: tuple[TestTarget]
:type exclude: list[str] :type exclude: list[str]
""" """
if self.vmware_test_platform is None or 'govcsim': if self.vmware_test_platform == 'govcsim':
docker = find_executable('docker', required=False) docker = find_executable('docker', required=False)
if docker: if docker:
@ -103,7 +103,9 @@ class VcenterProvider(CloudProvider):
super(VcenterProvider, self).setup() super(VcenterProvider, self).setup()
self._set_cloud_config('vmware_test_platform', self.vmware_test_platform) self._set_cloud_config('vmware_test_platform', self.vmware_test_platform)
if self._use_static_config(): if self.vmware_test_platform == 'govcsim':
self._setup_dynamic_simulator()
elif self._use_static_config():
self._set_cloud_config('vmware_test_platform', 'static') self._set_cloud_config('vmware_test_platform', 'static')
self._setup_static() self._setup_static()
elif self.vmware_test_platform == 'worldstream': elif self.vmware_test_platform == 'worldstream':
@ -216,7 +218,7 @@ class VcenterProvider(CloudProvider):
parser = ConfigParser({ parser = ConfigParser({
'vcenter_port': '443', 'vcenter_port': '443',
'vmware_proxy_host': '', 'vmware_proxy_host': '',
'vmware_proxy_port': ''}) 'vmware_proxy_port': '8080'})
parser.read(self.config_static_path) parser.read(self.config_static_path)
self.endpoint = parser.get('DEFAULT', 'vcenter_hostname') self.endpoint = parser.get('DEFAULT', 'vcenter_hostname')
@ -259,7 +261,10 @@ class VcenterEnvironment(CloudEnvironment):
""" """
:rtype: CloudEnvironmentConfig :rtype: CloudEnvironmentConfig
""" """
vmware_test_platform = self._get_cloud_config('vmware_test_platform') vmware_test_platform = os.environ.get('VMWARE_TEST_PLATFORM')
if not vmware_test_platform:
vmware_test_platform = self._get_cloud_config('vmware_test_platform')
if vmware_test_platform in ('worldstream', 'static'): if vmware_test_platform in ('worldstream', 'static'):
parser = ConfigParser() parser = ConfigParser()
parser.read(self.config_path) parser.read(self.config_path)