Skip to content

Commit

Permalink
Add logging to Satellite-xdist worker assignment process (#14539)
Browse files Browse the repository at this point in the history
(cherry picked from commit c37a15c)
  • Loading branch information
ogajduse authored and web-flow committed Apr 19, 2024
1 parent 187a4fc commit 3c78b9f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pytest_fixtures/core/xdist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures specific to or relating to pytest's xdist plugin"""

import random

from broker import Broker
Expand Down Expand Up @@ -31,9 +32,17 @@ def align_to_satellite(request, worker_id, satellite_factory):

# attempt to add potential satellites from the broker inventory file
if settings.server.inventory_filter:
logger.info(
f'{worker_id=}: Attempting to add Satellite hosts using inventory filter: '
f'{settings.server.inventory_filter}'
)
hosts = Satellite.get_hosts_from_inventory(filter=settings.server.inventory_filter)
settings.server.hostnames += [host.hostname for host in hosts]

logger.debug(
f'{worker_id=}: {settings.server.xdist_behavior=}, '
f'{settings.server.hostnames=}, {settings.server.auto_checkin=}'
)
# attempt to align a worker to a satellite
if settings.server.xdist_behavior == 'run-on-one' and settings.server.hostnames:
settings.set("server.hostname", settings.server.hostnames[0])
Expand All @@ -48,14 +57,19 @@ def align_to_satellite(request, worker_id, satellite_factory):
settings.set("server.hostname", on_demand_sat.hostname)
# if no satellite was received, fallback to balance
if not settings.server.hostname:
logger.info(
f'{worker_id=}: No Satellite hostnames were available, '
'falling back to balance behavior'
)
settings.set("server.hostname", random.choice(settings.server.hostnames))
if settings.server.hostname:
logger.info(
f'xdist worker {worker_id} was assigned hostname {settings.server.hostname}'
)
logger.info(f'{worker_id=}: Worker was assigned hostname {settings.server.hostname}')
configure_airgun()
configure_nailgun()
yield
if on_demand_sat and settings.server.auto_checkin:
logger.info(
f'{worker_id=}: Checking in on-demand Satellite ' f'{on_demand_sat.hostname}'
)
on_demand_sat.teardown()
Broker(hosts=[on_demand_sat]).checkin()

0 comments on commit 3c78b9f

Please sign in to comment.