[py-dev] xdist sending info between master and slave - support for client code

meme dough memedough at gmail.com
Fri Apr 16 11:09:12 CEST 2010


Hi,

I'm using pytest and the xdist plugin.

I'd like to get some information from the master to the slave, specifically
on the slave side I need to know the master's host, master's topdir and
master's rsync roots.

Currently I modified xdist to send the required info over the channel in
install_slave:

master_host = socket.gethostname()
master_topdir = config.topdir
channel.send((config, basetemp, gateway.id, master_host, master_topdir,
roots))

The rsync roots were passed into the TXNode during creation by the
NodeManager:

node = TXNode(gateway, self.config, putevent, self.roots)


That gets the info there but I'm not sure of the best way.

The master host / topdir could be added to config.options since that get
pickled over the channel, but it's not a command line option so it doesn't
seem the best place to put that info.  But it would work from a client point
of view without modifying xdist.

The master rsync roots can't be worked out by client unless it reimplements
the NodeManager._getrsyncdirs logic. This happens because DSession does
setup which creates NodeManager and setup_nodes which does install_slave
without any client hook in between so at no point can client get rsync roots
from session.nodemanager.roots and put them in something like config.options
to get to slave side.


That is the first half.  Next I need to send some info back from slave to
master when slave has finished.

Currently I modified xdist to send back a report object when the slave has
finished.  The SlaveNode has a report object which any client hook can
change or add to if they want to send info back to master:

self.report = None

I use pytest_sessionfinish hook on slave to set report to dict with info.
When slave finish it sendevent with the report:

self.sendevent("slavefinished", report=self.report)

The TXNode on master gets report and stores the slave report on itself:

self.report = kwargs['report']

Then on master use pytest_testnodedown hook to get slave report off TXNode.

That gets the info back from slave to master but I'm not sure if that's best
way.


Is it possible to modify xdist so that client code on master can send info
to the slave.  Will need access to rsync roots before it goes ahead and
installs the slave though.

Is it possible to modify xdist so that client code on the slave can send
info back to the master.  This looks like must modify xdist somehow since it
doesn't seem to send any report back at finish.


Now that I wrote all that, what is the obvious answer that I didn't see?

:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20100416/0579940b/attachment.html>


More information about the Pytest-dev mailing list