Stop freezing terminal when stopping ODL 02/63002/1
authorCédric Ollivier <cedric.ollivier@orange.com>
Mon, 11 Sep 2017 19:20:34 +0000 (21:20 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Mon, 11 Sep 2017 19:20:34 +0000 (21:20 +0200)
Change-Id: I9bfe3d5ee33efefb1e1710c84aeaa86ccfec8d3d
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
tests/transportpce_tests/test_portmapping.py

index c937ad73685bf3b140b6d5169377ce194ab7b2d4..c15a2d55e4472c8f98bf99d7540933f77bdb46fc 100644 (file)
@@ -4,6 +4,7 @@ import json
 import os
 import psutil
 import requests
+import signal
 import shutil
 import subprocess
 import time
@@ -40,7 +41,8 @@ class TransportPCEtesting(unittest.TestCase):
             zipobj.extractall()
             with open('odl.log', 'w') as outfile:
                 cls.odl_process = subprocess.Popen(
-                    ["bash", executable], stdout=outfile)
+                    ["bash", executable], stdout=outfile,
+                    stdin=open(os.devnull))
 
     @classmethod
     def setUpClass(cls):
@@ -50,10 +52,13 @@ class TransportPCEtesting(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        cls.testtools_process.kill()
+        cls.testtools_process.send_signal(signal.SIGINT)
+        cls.testtools_process.wait()
         for child in psutil.Process(cls.odl_process.pid).children():
-            child.kill()
-        cls.odl_process.kill()
+            child.send_signal(signal.SIGINT)
+            child.wait()
+        cls.odl_process.send_signal(signal.SIGINT)
+        cls.odl_process.wait()
 
     def setUp(self):
         time.sleep(1)