fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/41127?usp=email )


Change subject: tests/{ctrl,vty}_test_runner.py: dump stdout/stderr
......................................................................

tests/{ctrl,vty}_test_runner.py: dump stdout/stderr

>From time to time, we're seeing the following error in Jenkins:

----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../tests/vty_test_runner.py", line 70, in tearDown
    raise Exception("Process returned %d" % rc)
Exception: Process returned -9
----------------------------------------------------------------------

Let's dump stdout/stderr of the process to get more information.

Change-Id: Ie6a2f5b1bc56d35513643b52923403798e5a0a5a
Related: OS#5665
---
M tests/ctrl_test_runner.py
M tests/vty_test_runner.py
2 files changed, 36 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/27/41127/1

diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index 16d1e7c..1042df5 100755
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -26,6 +26,7 @@
 import socket
 import sys
 import struct
+import tempfile

 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
@@ -50,8 +51,12 @@
             cfi = config_index + 1
             osmo_ctrl_cmd[cfi] = os.path.join(confpath, osmo_ctrl_cmd[cfi])
 
+        self.stdout = tempfile.TemporaryFile()
+        self.stderr = tempfile.TemporaryFile()
         try:
-            self.proc = osmoutil.popen_devnull(osmo_ctrl_cmd)
+            # self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
+            print("Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for 
c in osmo_vty_cmd])))
+            self.proc = subprocess.Popen(osmo_vty_cmd, stdout=self.stdout, 
stderr=self.stderr)
         except OSError:
             print("Current directory: %s" % os.getcwd(), file=sys.stderr)
             print("Consider setting -b", file=sys.stderr)
@@ -62,11 +67,23 @@
         self.connect("127.0.0.1", appport)
         self.next_id = 1000

+    def dump_file(self, file, name):
+        file.seek(0)
+        data = file.read()
+        print('=' * 80)
+        print(name)
+        print('=' * 80)
+        print(data.decode())
+
     def tearDown(self):
         self.disconnect()
         rc = osmoutil.end_proc(self.proc)
         if rc is not None and rc != 0:
+            self.dump_file(self.stdout, 'stdout')
+            self.dump_file(self.stderr, 'stderr')
             raise Exception("Process returned %d" % rc)
+        self.stdout.close()
+        self.stderr.close()

     def disconnect(self):
         if not (self.sock is None):
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
index 2dfa155..571080e 100755
--- a/tests/vty_test_runner.py
+++ b/tests/vty_test_runner.py
@@ -20,6 +20,7 @@
 import unittest
 import socket
 import subprocess
+import tempfile

 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
@@ -51,8 +52,12 @@
             cfi = config_index + 1
             osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])

+        self.stdout = tempfile.TemporaryFile()
+        self.stderr = tempfile.TemporaryFile()
         try:
-            self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
+            # self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
+            print("Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for 
c in osmo_vty_cmd])))
+            self.proc = subprocess.Popen(osmo_vty_cmd, stdout=self.stdout, 
stderr=self.stderr)
         except OSError:
             print("Current directory: %s" % os.getcwd(), file=sys.stderr)
             print("Consider setting -b", file=sys.stderr)
@@ -61,13 +66,25 @@
         appport = self.vty_app()[0]
         self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport)

+    def dump_file(self, file, name):
+        file.seek(0)
+        data = file.read()
+        print('=' * 80)
+        print(name)
+        print('=' * 80)
+        print(data.decode())
+
     def tearDown(self):
         if self.vty:
             self.vty._close_socket()
         self.vty = None
         rc = osmoutil.end_proc(self.proc)
         if rc is not None and rc != 0:
+            self.dump_file(self.stdout, 'stdout')
+            self.dump_file(self.stderr, 'stderr')
             raise Exception("Process returned %d" % rc)
+        self.stdout.close()
+        self.stderr.close()

 class TestVTYMSC(TestVTYBase):


--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/41127?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: Ie6a2f5b1bc56d35513643b52923403798e5a0a5a
Gerrit-Change-Number: 41127
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>

Reply via email to