Skip to content
Permalink
Browse files

tests/test_crossbar: check correct handling of unresponsive exporters

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information
jluebbe committed Nov 29, 2019
1 parent 1fc4067 commit 755fa8e0678275dcc6538d167d8b2dbb5fdf4aac
Showing with 38 additions and 0 deletions.
  1. +38 −0 tests/test_crossbar.py
@@ -1,5 +1,6 @@
import os
import re
import time

from importlib.util import find_spec

@@ -276,3 +277,40 @@ def test_reservation(place_acquire, tmpdir):
spawn.expect(pexpect.EOF)
spawn.close()
assert spawn.exitstatus == 0, spawn.before.strip()

def test_exporter_timeout(place, exporter):
with pexpect.spawn('python -m labgrid.remote.client resources') as spawn:
spawn.expect(pexpect.EOF)
spawn.close()
assert spawn.exitstatus == 0, spawn.before.strip()
assert b'/Testport/NetworkSerialPort' in spawn.before

# lock resources ensure cleanup is needed
with pexpect.spawn('python -m labgrid.remote.client -p test acquire') as spawn:
spawn.expect(pexpect.EOF)
spawn.close()
assert spawn.exitstatus == 0, spawn.before.strip()

suspend_tree(exporter.pid)
try:
time.sleep(30)

# the unresponsive exporter should be kicked by now
with pexpect.spawn('python -m labgrid.remote.client resources') as spawn:
spawn.expect(pexpect.EOF)
spawn.close()
assert spawn.exitstatus == 0, spawn.before.strip()
assert b'/Testport/NetworkSerialPort' not in spawn.before
finally:
resume_tree(exporter.pid)

# the exporter should quit by itself now
time.sleep(5)

assert not exporter.isalive()
assert exporter.exitstatus == 100

with pexpect.spawn('python -m labgrid.remote.client -p test release') as spawn:
spawn.expect(pexpect.EOF)
spawn.close()
assert spawn.exitstatus == 0, spawn.before.strip()

0 comments on commit 755fa8e

Please sign in to comment.
You can’t perform that action at this time.