"""
if self.__state == STATE_DEAD:
raise ValueError("Can't resurrect already dead component")
- if self.running():
+ if self.is_running():
raise ValueError("Can't start already running component")
logger.info(BIND10_COMPONENT_START, self.name())
self.__state = STATE_RUNNING
"""
# This is not tested. It talks with the outher world, which is out
# of scope of unittests.
- if not self.running():
+ if not self.is_running():
raise ValueError("Can't stop a component which is not running")
logger.info(BIND10_COMPONENT_STOP, self.name())
self.__state = STATE_STOPPED
logger.error(BIND10_COMPONENT_FAILED, self.name(), self.pid(),
exit_str)
- if not self.running():
+ if not self.is_running():
raise ValueError("Can't fail component that isn't running")
self.__state = STATE_FAILED
self._failed_internal()
else:
return False
- def running(self):
+ def is_running(self):
"""
Informs if the component is currently running. It assumes the failed
is called whenever the component really fails and there might be some
def is_failed(self):
"""Informs if the component has failed and is waiting for a restart.
- Unlike the case of running(), if this returns True it always means
+ Unlike the case of is_running(), if this returns True it always means
the corresponding process has died and not yet restarted.
"""
for cname in old.keys():
if cname not in new:
component = self._components[cname][1]
- if component.running() or component.is_failed():
+ if component.is_running() or component.is_failed():
plan.append({
'command': STOP_CMD,
'component': component,
self._components[task['name']] = (task['config'],
component)
elif command == STOP_CMD:
- if component.running():
+ if component.is_running():
component.stop()
del self._components[task['name']]
else:
self.assertFalse(self.__start_called)
self.assertFalse(self.__stop_called)
self.assertFalse(self.__failed_called)
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertFalse(component.is_failed())
# We can't stop or fail the component yet
self.assertRaises(ValueError, component.stop)
self.assertTrue(self.__start_called)
self.assertFalse(self.__stop_called)
self.assertFalse(self.__failed_called)
- self.assertTrue(component.running())
+ self.assertTrue(component.is_running())
self.assertFalse(component.is_failed())
def __check_dead(self, component):
self.assertFalse(self.__stop_called)
self.assertTrue(self.__failed_called)
self.assertEqual(1, self._exitcode)
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertFalse(component.is_failed())
# Surely it can't be stopped when already dead
self.assertRaises(ValueError, component.stop)
self.assertTrue(self.__start_called)
self.assertFalse(self.__stop_called)
self.assertTrue(self.__failed_called)
- self.assertTrue(component.running())
+ self.assertTrue(component.is_running())
self.assertFalse(component.is_failed())
# Check it can't be started again
self.assertRaises(ValueError, component.start)
self.assertTrue(self.__start_called)
self.assertFalse(self.__stop_called)
self.assertTrue(self.__failed_called)
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertTrue(component.is_failed())
def __do_start_stop(self, kind):
self.assertTrue(self.__start_called)
self.assertTrue(self.__stop_called)
self.assertFalse(self.__failed_called)
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertFalse(component.is_failed())
# Check it can't be stopped twice
self.assertRaises(ValueError, component.stop)
self.assertIsNone(component.pid())
self.assertEqual(['hello'], component._params)
self.assertEqual('Address', component._address)
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertEqual({}, self.__registered_processes)
component.start()
- self.assertTrue(component.running())
+ self.assertTrue(component.is_running())
# Some versions of unittest miss assertIsInstance
self.assertTrue(isinstance(component._procinfo, TestProcInfo))
self.assertEqual(42, component.pid())
"""
component = Component('component', self, 'needed', 'Address')
component.start()
- self.assertTrue(component.running())
+ self.assertTrue(component.is_running())
self.assertEqual('component', self.__start_simple_params)
component.pid = lambda: 42
component.stop()
- self.assertFalse(component.running())
+ self.assertFalse(component.is_running())
self.assertEqual(('component', 'Address', 42),
self.__stop_process_params)
component = Component('component', self, 'needed', 'Address',
[], ProcInfo)
component.start()
- self.assertTrue(component.running())
+ self.assertTrue(component.is_running())
component.kill()
self.assertTrue(process.terminated)
self.assertFalse(process.killed)