Fix scenario path in config detector
When running pytest with custom scenario name, make config detection taking into account the scenario specific molucule config file. For example, some scenarios could use podman, while other ones - a delegated driver. Change-Id: Ied74290876d28f6fb2011aa3d9ccd77c0c90bea1 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
640c525e7e
commit
54e7e2c1fa
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
driver:
|
||||||
|
name: podman
|
||||||
|
|
||||||
log: true
|
log: true
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: centos
|
- name: centos
|
||||||
hostname: centos
|
hostname: centos
|
||||||
|
@ -18,10 +18,10 @@ import pytest
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
def set_proper_molecule_config(role_path):
|
def set_proper_molecule_config(role_path, scenario='default'):
|
||||||
mol_config_file = "config.yml"
|
mol_config_file = "config.yml"
|
||||||
if os.path.exists(os.path.join(role_path, 'molecule', 'default/molecule.yml')):
|
if os.path.exists(os.path.join(role_path, 'molecule', f'{scenario}/molecule.yml')):
|
||||||
molecule_path = os.path.join(role_path, 'molecule', 'default/molecule.yml')
|
molecule_path = os.path.join(role_path, 'molecule', f'{scenario}/molecule.yml')
|
||||||
with open(molecule_path) as content:
|
with open(molecule_path) as content:
|
||||||
data = yaml.safe_load(content)
|
data = yaml.safe_load(content)
|
||||||
if 'driver' in data.keys() and data['driver']['name'] == 'podman':
|
if 'driver' in data.keys() and data['driver']['name'] == 'podman':
|
||||||
@ -35,8 +35,11 @@ def set_proper_molecule_config(role_path):
|
|||||||
def test_molecule(pytestconfig):
|
def test_molecule(pytestconfig):
|
||||||
cmd = ['python', '-m', 'molecule']
|
cmd = ['python', '-m', 'molecule']
|
||||||
scenario = pytestconfig.getoption("scenario")
|
scenario = pytestconfig.getoption("scenario")
|
||||||
|
if not scenario:
|
||||||
|
scenario = 'default'
|
||||||
ansible_args = pytestconfig.getoption("ansible_args")
|
ansible_args = pytestconfig.getoption("ansible_args")
|
||||||
cmd.extend(['--base-config', set_proper_molecule_config(os.getcwd())])
|
cmd.extend(['--base-config', set_proper_molecule_config(os.getcwd(),
|
||||||
|
scenario)])
|
||||||
|
|
||||||
if ansible_args:
|
if ansible_args:
|
||||||
cmd.append('converge')
|
cmd.append('converge')
|
||||||
|
Loading…
Reference in New Issue
Block a user