def test_connections(): node = DummyNode() node.id = "node_id" actor = create_actor(node) inport = actor.inports['token'] outport = actor.outports['token'] in_peer_port = TestPort("x", "out") out_peer_port = TestPort("y", "in") out_peer_port.queue.add_reader(out_peer_port.id, {}) in_peer_port.queue.add_reader(inport.id, {}) inport.attach_endpoint(LocalInEndpoint(inport, in_peer_port)) outport.attach_endpoint(LocalOutEndpoint(outport, out_peer_port)) assert actor.connections(node) == { 'actor_id': actor.id, 'actor_name': actor.name, 'inports': { inport.id: [(node, in_peer_port.id)] }, 'outports': { outport.id: [(node, out_peer_port.id)] } }
def test_migrate(self): callback_mock = Mock() actor, actor_id = self._new_actor('std.Constant', {'data': 42}) actor.outports['token'].set_queue(queue.fanout_fifo.FanoutFIFO(5)) peer_node = DummyNode() actor.will_migrate = Mock() self.am.migrate(actor_id, peer_node.id, callback_mock) assert actor.will_migrate.called assert self.am.node.pm.disconnect.called args, kwargs = self.am.node.pm.disconnect.call_args self.assertEqual(kwargs['actor_id'], actor_id) cb = kwargs['callback'] self.assertEqual(cb.kwargs['actor'], actor) self.assertEqual(cb.kwargs['actor_type'], actor._type) self.assertEqual(cb.kwargs['callback'], callback_mock) self.assertEqual(cb.kwargs['node_id'], peer_node.id) self.assertEqual(cb.kwargs['ports'], actor.connections(self.am.node.id)) self.am.node.control.log_actor_migrate.assert_called_once_with( actor_id, peer_node.id)
def test_connections(): node = DummyNode() node.id = "node_id" actor = create_actor(node) inport = actor.inports['token'] outport = actor.outports['token'] in_peer_port = TestPort("x", "out") out_peer_port = TestPort("y", "in") out_peer_port.queue.add_reader(out_peer_port.id, {}) in_peer_port.queue.add_reader(inport.id, {}) inport.attach_endpoint(LocalInEndpoint(inport, in_peer_port)) outport.attach_endpoint(LocalOutEndpoint(outport, out_peer_port)) assert actor.connections(node) == { 'actor_id': actor.id, 'actor_name': actor.name, 'inports': {inport.id: [(node, in_peer_port.id)]}, 'outports': {outport.id: [(node, out_peer_port.id)]} }
def test_connections(): node = DummyNode() node.id = "node_id" actor = create_actor(node) inport = actor.inports['token'] outport = actor.outports['token'] port = Mock() port.id = "x" peer_port = Mock() peer_port.id = "y" inport.attach_endpoint(LocalInEndpoint(port, peer_port)) outport.attach_endpoint(LocalOutEndpoint(port, peer_port)) assert actor.connections(node) == { 'actor_id': actor.id, 'actor_name': actor.name, 'inports': {inport.id: (node, "y")}, 'outports': {outport.id: [(node, "y")]} }
def test_late_start(self): self.q = Queue.Queue() self.q2 = Queue.Queue() def cb(key, value): self.q2.put({"key": key, "value": value}) def started_cb(started): self.q.put(started) cb, d = create_callback() self.storage = storage.Storage(DummyNode()) self.storage.start('', cb) self.storage2 = storage.Storage(DummyNode()) self.storage.set("test", "1", 1, None) self.storage.set("test", "2", 2, None) self.storage.set("test", "3", 3, None) assert "test1" in self.storage.localstore assert "test2" in self.storage.localstore assert "test3" in self.storage.localstore cb2, d = create_callback() self.storage2.start('', cb2) value = yield d # print value[0][0] assert value[0][0] yield wait_for(self.storage.localstore.keys, condition=lambda x: not x()) assert not self.storage.localstore.keys() cb, d = create_callback() self.storage.get("test", "3", cb) a, kw = yield d assert a[0] == "3" and a[1] == 3 self.storage.stop() self.storage2.stop()
def setUp(self): self.rm = ReplicationManager(DummyNode()) self.rm.managed_replications = { "RM1": ReplicationData(), "RM2": ReplicationData() } for rid, r in self.rm.managed_replications.items(): r.id = rid r.peer_replication_ids = self.rm.managed_replications.keys() r.peer_replication_ids.remove(rid) # Make both rm ids local self.rm.leaders_cache = { "RM1": self.rm.node.id, "RM2": self.rm.node.id }
def actor(): return create_actor(DummyNode())
def setUp(self): n = DummyNode() self.am = ActorManager(node=n) n.am = self.am
def setUp(self): n = DummyNode() self.am = ActorManager(node=n) n.am = self.am n.pm.remove_ports_of_actor = Mock(return_value=[])
def setUp(self): n = DummyNode() self.am = ActorManager(node=n) n.am = self.am n.pm.remove_ports_of_actor = Mock(return_value = [])
def setup_class(self): self.storage = storage.Storage(DummyNode()) self.storage.start() yield threads.defer_to_thread(time.sleep, .01)
def actor(): get_calvinsys()._node = Mock() return create_actor(DummyNode())