pytest-testinfra icon indicating copy to clipboard operation
pytest-testinfra copied to clipboard

Force disconnect / reconnnect.

Open twirrim opened this issue 6 years ago • 0 comments

I have a somewhat strange test case scenario that I'm currently handling via pytest/fabric (as quirky as that interaction is).

For the purposes of testing a new image, I spin up ephemeral systems. We have a test case where we modify some properties of the image, disconnect, and then attempt to reconnect.

I don't seem to be able to make the disconnect / reconnect happen. I can force the disconnect by telling the backend client (paramiko) to close the session:

>>> host.backend.client.close()

but then testinfra doesn't attempt to reconnect the session afterwards:

>>> host.file('/etc/passwd').exists
*** AttributeError: 'NoneType' object has no attribute 'open_session'
>>>

Fabric will recognise the backend as having gone away and silently re-establish the connection.

In an ideal world, from my perspective, testinfra would catch that attribute error, recognise that means the connection has failed, and re-establish.

twirrim avatar Jun 20 '19 16:06 twirrim