def test_enforce_no_daemon(enforce_daemon_is_running): if not is_daemon_running(args=[]): assert spawn_daemon(args=[], wait_until_spawned=5.0) args = argparse.Namespace(no_daemon=True) with NodeStrategy(args=args) as node: assert node._daemon_node is None assert node._direct_node is not None
def daemon_node(): if is_daemon_running(args=[]): with DaemonNode(args=[]) as node: node.system.shutdown() assert spawn_daemon(args=[], wait_until_spawned=5.0) with DaemonNode(args=[]) as node: yield node
def __init__(self, args): use_daemon = not getattr(args, 'no_daemon', False) if use_daemon and is_daemon_running(args): self.node = DaemonNode(args) else: if use_daemon: spawn_daemon(args) self.node = DirectNode(args)
def __init__(self, args): use_daemon = not getattr(args, 'no_daemon', False) if use_daemon and is_daemon_running(args): self._daemon_node = DaemonNode(args) self._direct_node = None else: if use_daemon: spawn_daemon(args) self._direct_node = DirectNode(args) self._daemon_node = None self._args = args self._in_scope = False
def main(self, *, args): running = is_daemon_running(args) if running: print('The daemon is already running') return spawned = spawn_daemon(args, wait_until_spawned=10.0) if spawned: print('The daemon has been started') else: print('Failed to confirm that the daemon started successfully', file=sys.stderr) return 1
def main(self, *, args): running = is_daemon_running(args) if not running: print('The daemon is not running') return with DaemonNode(args) as daemon: try: shutdown = daemon.system.shutdown except AttributeError: return 'Failed to shutdown daemon, ' \ 'it might be using a different rmw implementation' shutdown() print('The daemon has been stopped')
def daemon_node(): if is_daemon_running(args=[]): assert shutdown_daemon(args=[], timeout=5.0) assert spawn_daemon(args=[], timeout=5.0) with DaemonNode(args=[]) as node: attempts = 3 delay_between_attempts = 2 # seconds for _ in range(attempts): node_names_and_namespaces = node.get_node_names_and_namespaces() if [TEST_NODE_NAME, TEST_NODE_NAMESPACE] in node_names_and_namespaces: break time.sleep(delay_between_attempts) else: pytest.fail( f'daemon failed to discover {TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}' ) yield node node.system.shutdown()
def enforce_daemon_is_running(): if not is_daemon_running(args=[]): assert spawn_daemon(args=[], wait_until_spawned=5.0) yield
def enforce_no_daemon_is_running(): if is_daemon_running(args=[]): with DaemonNode(args=[]) as node: node.system.shutdown() yield
def main(self, *, args): if is_daemon_running(args): print('The daemon is running') else: print('The daemon is not running')
def enforce_daemon_is_running(): if not is_daemon_running(args=[]): assert spawn_daemon(args=[], timeout=5.0) yield
def enforce_no_daemon_is_running(): if is_daemon_running(args=[]): assert shutdown_daemon(args=[], timeout=5.0) yield
def __init__(self, args): if is_daemon_running(args): self.node = DaemonNode(args) else: spawn_daemon(args) self.node = DirectNode(args)
def enforce_no_daemon_is_running(): if is_daemon_running(args=[]): assert shutdown_daemon(args=[], wait_duration=5.0) yield