Added new condition for open file condition in test_process
This commit is contained in:
parent
98630f3e38
commit
474d42b8b1
|
@ -48,6 +48,16 @@ class TestProcessConfig(TestProcessProto):
|
||||||
config.read(os.path.join(self.home, 'keys.dat'))
|
config.read(os.path.join(self.home, 'keys.dat'))
|
||||||
self.assertEqual(config.safeGetInt(
|
self.assertEqual(config.safeGetInt(
|
||||||
'bitmessagesettings', 'settingsversion'), 10)
|
'bitmessagesettings', 'settingsversion'), 10)
|
||||||
|
if config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'port') != 8444:
|
||||||
|
print('yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy')
|
||||||
|
import subprocess
|
||||||
|
current_port ='sudo netstat -nlp | grep :{}'.format(
|
||||||
|
config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'port'))
|
||||||
|
print(subprocess.call(
|
||||||
|
current_port,shell = True))
|
||||||
|
print('yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy')
|
||||||
self.assertEqual(config.safeGetInt(
|
self.assertEqual(config.safeGetInt(
|
||||||
'bitmessagesettings', 'port'), 8444)
|
'bitmessagesettings', 'port'), 8444)
|
||||||
# don't connect
|
# don't connect
|
||||||
|
|
|
@ -31,7 +31,8 @@ class TestProcessProto(unittest.TestCase):
|
||||||
_threads_count = 15
|
_threads_count = 15
|
||||||
_files = (
|
_files = (
|
||||||
'keys.dat', 'messages.dat', 'knownnodes.dat',
|
'keys.dat', 'messages.dat', 'knownnodes.dat',
|
||||||
'.api_started', 'unittest.lock','debug.log')
|
'.api_started', 'unittest.lock','singleton.lock'
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
@ -43,17 +44,19 @@ class TestProcessProto(unittest.TestCase):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cls.pid = int(cls._get_readline('singleton.lock'))
|
cls.pid = int(cls._get_readline('singleton.lock'))
|
||||||
cls.process = psutil.Process(cls.pid)
|
cls.process = psutil.Process(cls.pid)
|
||||||
|
print('')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_readline(cls, pfile):
|
def _get_readline(cls, pfile):
|
||||||
pfile = os.path.join(cls.home, pfile)
|
pfile = os.path.join(cls.home, pfile)
|
||||||
try:
|
try:
|
||||||
return open(pfile, 'rb').readline().strip()
|
with open(pfile, 'rb') as f:
|
||||||
|
return f.readline().strip()
|
||||||
except (OSError, IOError, FileNotFoundError):
|
except (OSError, IOError, FileNotFoundError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _stop_process(cls, timeout=60):
|
def _stop_process(cls, timeout=5):
|
||||||
cls.process.send_signal(signal.SIGTERM)
|
cls.process.send_signal(signal.SIGTERM)
|
||||||
try:
|
try:
|
||||||
cls.process.wait(timeout)
|
cls.process.wait(timeout)
|
||||||
|
@ -64,16 +67,22 @@ class TestProcessProto(unittest.TestCase):
|
||||||
print('55555555555555555')
|
print('55555555555555555')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
logger.error('_stop_process')
|
||||||
|
logger.error('this condition are getting killed are not')
|
||||||
|
print('psutil.pid_exists(cls.process.pid)-{}'.format(
|
||||||
|
psutil.pid_exists(cls.process.pid)))
|
||||||
|
print('psutil.pid-{}'.format(cls.process.pid))
|
||||||
logger.error('__stop__process')
|
logger.error('__stop__process')
|
||||||
except psutil.TimeoutExpired:
|
except psutil.TimeoutExpired:
|
||||||
logger.error('#####_stop_process method condition--##')
|
print('#####_stop_process method condition--##')
|
||||||
try:
|
try:
|
||||||
logger.error('cls.process PID -{}'.format(cls.process.pid))
|
print('cls.process PID -{}'.format(cls.process.pid))
|
||||||
except:
|
except:
|
||||||
logger.error('cls.process -{}'.format(cls.process))
|
print('cls.process -{}'.format(cls.process))
|
||||||
|
|
||||||
logger.error('#####_stop_process method condition--##')
|
print('#####_stop_process method condition--##')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Reference in New Issue
Block a user