Commit 92b8b8d0 authored by Charles Ferguson's avatar Charles Ferguson
Browse files

Fix for thread control tests on linux.

The 'netstat -i -c' command, when run as an unprivileged user, appears
to output nothing. This makes our tests fail because we rely on it
outputing something every second.

Change to using ping.
parent 2d52ba98
......@@ -155,9 +155,10 @@ class StreamedInput(object):
stopped = 'running'
return "StreamedInput(command=%r, shell=%r, buffer_size=%s; " \
return "%s(command=%r, shell=%r, buffer_size=%s; " \
"started=%s, stopped=%s, data_function=%s%s)" % \
(self.command,, self.buffer_size,
self.command,, self.buffer_size,
self.proc is not None, stopped, datafunc, extra)
def _set_nonblocking(self):
......@@ -514,9 +514,9 @@ class TestThreaded90ThreadControl(BaseThreadedInput):
def __init__(self, *args, **kwargs):
super(TestThreaded90ThreadControl, self).__init__(*args, **kwargs)
if sys.platform == 'darwin':
self.netstat = ['netstat', '-i', '-w1']
self.cmd = ['netstat', '-i', '-w1']
elif sys.platform.startswith('linux'):
self.netstat = ['netstat', '-i', '-c']
self.cmd = ['ping', '-c', '4', '']
raise NotImplementedError
......@@ -527,7 +527,7 @@ class TestThreaded90ThreadControl(BaseThreadedInput):
super(TestThreaded90ThreadControl, self).tearDown()
def test_001_start_and_stop_long_process(self): = streamedinput.StreamedInput(self.netstat) = streamedinput.StreamedInput(self.cmd)
initial_datalen = len(
......@@ -553,7 +553,7 @@ class TestThreaded90ThreadControl(BaseThreadedInput):
self.assertTrue(, "We should now be at the end of the list, and the process should be gone")
def test_002_context_handler_stops(self):
with streamedinput.ThreadedStreamedInput(self.netstat) as
with streamedinput.ThreadedStreamedInput(self.cmd) as
test_process = psutil.Process(
self.assertTrue(, "Process should be running")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment