]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra.run: Notice when short-lived procs exit
authorZack Cerza <zack@redhat.com>
Fri, 10 Mar 2017 16:41:46 +0000 (09:41 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 10 Mar 2017 22:00:42 +0000 (15:00 -0700)
If a command exits immediately, there is a race between greenlet
completion (which flushes the ChannelFile buffers) and the call to
exit_status_ready(). Waiting for 0.1s on the greenlets removes the race
condition.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/run.py
teuthology/orchestra/test/test_run.py

index f765edede0242f2dcd9fc4690fc46370336e27ae..6f829ab35ab5a6962a5d3826b7659e5a56d7bf5f 100644 (file)
@@ -179,6 +179,7 @@ class RemoteProcess(object):
 
     @property
     def finished(self):
+        gevent.wait(self.greenlets, timeout=0.1)
         ready = self._stdout_buf.channel.exit_status_ready()
         if ready:
             self._get_exitstatus()
index a703b72fce39cbd560679d05ed5537ff71efe6a9..8b9b7c0c52c3b9a58c7cdcdde67e6f9d948b5fd8 100644 (file)
@@ -148,7 +148,7 @@ class TestRun(object):
             args=['foo'],
             check_status=False,
         )
-        assert proc.exitstatus is None
+        assert proc.exitstatus == -1
 
     def test_status_lost(self):
         m_transport = MagicMock()
@@ -185,7 +185,7 @@ class TestRun(object):
             args=['foo'],
             check_status=False,
         )
-        assert proc.exitstatus is None
+        assert proc.exitstatus == -1
 
     def test_status_bad_nowait(self):
         self.m_stdout_buf.channel.recv_exit_status.return_value = 42
@@ -207,7 +207,7 @@ class TestRun(object):
             stdin=run.PIPE,
             wait=False
         )
-        assert proc.poll() is None
+        assert proc.poll() == 0
         code = proc.wait()
         assert code == 0
         assert proc.exitstatus == 0
@@ -222,7 +222,7 @@ class TestRun(object):
             stdout=run.PIPE,
             wait=False
         )
-        assert proc.poll() is None
+        assert proc.poll() == 0
         assert proc.stdout.readline() == lines[0]
         assert proc.stdout.readline() == lines[1]
         assert proc.stdout.readline() == lines[2]
@@ -240,7 +240,7 @@ class TestRun(object):
             stderr=run.PIPE,
             wait=False
         )
-        assert proc.poll() is None
+        assert proc.poll() == 0
         assert proc.stderr.readline() == lines[0]
         assert proc.stderr.readline() == lines[1]
         assert proc.stderr.readline() == lines[2]