def test_handshake(self): conn = EPMDKeepAliveConnection('test', 9999) conn.start() res = port2_please(self.erl_node_name) erl_port = res[1] channel = Channel(None) channel.connect(erl_port) node_name = self.erl_node_name + '@' + socket.gethostname() channel.send_name(node_name) self.assertEqual(channel.recv_status(), ('s', 'ok')) res = channel.recv_challenge() self.assertEqual(len(res), 5) self.assertEqual(res[0], 'n') self.assertEqual(res[4], node_name) out_challenge = res[3] challenge = gen_challenge() channel.send_challenge_reply(self.erl_node_secret, challenge, out_challenge) res = channel.recv_challenge_ack() self.assertEqual(len(res), 2) self.assertEqual(res[0], 'a')
def test(self): conn = EPMDKeepAliveConnection('test', 9999) conn.start() res = port2_please(self.erl_node_name) conn.join(0.1) self.assertEqual(len(res), 10) self.assertEqual(res[7], 'erl1')
def setUp(self): super(OutgoingNodeConnectionTestCase, self).setUp() res = port2_please(self.erl_node_name) erl_port = res[1] connected_event = event.Event() res_queue = Queue() class _Mock(OutgoingNodeConnection): def _process_message(self, message): res_queue.put(message) self.res_queue = res_queue self.connection = _Mock.start('test', erl_port, self.erl_node_secret, connected_event) connected_event.wait() self.node_name = 'test@' + socket.gethostname()
def connect_node(self, out_node_name): res = epmd.port2_please(out_node_name) out_port = res[1] if out_node_name in self.node_connections: self.logger.warning('Already connected to "%s"', out_node_name) else: connected_event = event.Event() out_conn = OutgoingNodeConnection.start( self.node_name, out_port, self.cookie, connected_event ) if connected_event.wait(self.CONNECT_NODE_TIMEOUT): self.node_connections[out_node_name] = out_conn return True else: self.logger.warning('Does not connected to "%s:%s" ' 'after %s seconds', out_node_name, out_port, self.CONNECT_NODE_TIMEOUT) return False