Skip to content

Commit

Permalink
fixup! Add support for --nest=... --hosts=cache://...
Browse files Browse the repository at this point in the history
  • Loading branch information
ydirson committed Sep 19, 2024
1 parent 4062dd9 commit 116a119
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,27 @@ def hosts(pytestconfig):
hosts_args = pytestconfig.getoption("hosts")
hosts_split = [hostlist.split(',') for hostlist in hosts_args]
hostname_list = list(itertools.chain(*hosts_split))
try:
host_list = []
for hostname_or_ip in hostname_list:
host_list.append(setup_host(hostname_or_ip, config=pytestconfig))

if not host_list:
pytest.fail("This test requires at least one --hosts parameter")
yield host_list

finally:
host_list = []
def _cleanup_hosts():
for host in host_list:
if host.nested:
logging.info("Destroying nested host's VM %s", host.nested.uuid)
host.nested.destroy(verify=True)

try:
for hostname_or_ip in hostname_list:
host_list.append(setup_host(hostname_or_ip, config=pytestconfig))
except Exception:
_cleanup_hosts()
raise

if not host_list:
pytest.fail("This test requires at least one --hosts parameter")
yield host_list

_cleanup_hosts

@pytest.fixture(scope='session')
def registered_xo_cli():
# The fixture is not responsible for establishing the connection.
Expand Down

0 comments on commit 116a119

Please sign in to comment.