def get_a_sample_pplan(): """Returns a legitimate looking physical plan This topology has 1 spout and 2 bolts. Currently no input/output streams. There is only one stream manager. [Instance 1: spout1] - instance_id = "instance1" - task_id = 100 - component_index = 0 - component_name = "spout1" [Instance 2: bolt1] - instance_id = "instance2" - task_id = 200 - component_index = 0 - component_name = "bolt1" [instance 3: bolt2] - instance_id = "instance3" - task_id = 300 - component_index = 0 - component_name = "bolt2" :returns: PhysicalPlan message and a list of dictionaries for each instance containing (instance_id, task_id, comp_index, comp_name) """ spout_1 = mock_protobuf.get_mock_spout( component=mock_protobuf.get_mock_component(name="spout1")) bolt_1 = mock_protobuf.get_mock_bolt( component=mock_protobuf.get_mock_component(name="bolt1")) bolt_2 = mock_protobuf.get_mock_bolt( component=mock_protobuf.get_mock_component(name="bolt2")) topology = mock_protobuf.get_mock_topology(spouts=[spout_1], bolts=[bolt_1, bolt_2]) instance_ids = ["instance1", "instance2", "instancer3"] task_ids = [100, 200, 300] comp_indexes = [0, 0, 0] comp_names = ["spout1", "bolt1", "bolt2"] instances = [] for i_id, t_id, c_i, c_name in zip(instance_ids, task_ids, comp_indexes, comp_names): info = mock_protobuf.get_mock_instance_info(task_id=t_id, component_index=c_i, component_name=c_name) instance = mock_protobuf.get_mock_instance(instance_id=i_id, info=info) instances.append(instance) pplan = mock_protobuf.get_mock_pplan(topology=topology, instances=instances) keys = ["instance_id", "task_id", "comp_index", "comp_name"] zipped = list(zip(instance_ids, task_ids, comp_indexes, comp_names)) return pplan, [dict(list(zip(keys, z))) for z in zipped]
def test_on_response(self): with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.INVALID_PACKET, None, None) with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.OK, None, mock_protobuf.get_mock_instance()) self.stmgr_client.on_response(StatusCode.OK, None, mock_protobuf.get_mock_register_response()) self.assertTrue(self.stmgr_client.handle_register_response_called)
def __init__(self): socket_options = SocketOptions(32768, 16, 32768, 16, 1024000, 1024000) with patch("heron.instance.src.python.utils.system_config.get_sys_config", side_effect=lambda: {constants.INSTANCE_RECONNECT_METRICSMGR_INTERVAL_SEC: 10, constants.INSTANCE_METRICS_SYSTEM_SAMPLE_INTERVAL_SEC: 10}): stream = HeronCommunicator(producer_cb=None, consumer_cb=None) MetricsManagerClient.__init__(self, EventLooper(), self.HOST, self.PORT, mock_protobuf.get_mock_instance(), HeronCommunicator(), stream, stream, {}, socket_options, Mock(), Mock()) self.register_req_called = False
def __init__(self): socket_options = SocketOptions(32768, 16, 32768, 16, 1024000, 1024000) with patch("heron.instance.src.python.utils.system_config.get_sys_config", side_effect=lambda: {constants.INSTANCE_RECONNECT_STREAMMGR_INTERVAL_SEC: 10}): SingleThreadStmgrClient.__init__(self, EventLooper(), None, self.HOST, self.PORT, "topology_name", "topology_id", mock_protobuf.get_mock_instance(), {}, None, socket_options) self.register_msg_called = False self.handle_register_response_called = False
def get_a_sample_pplan(): """Returns a legitimate looking physical plan This topology has 1 spout and 2 bolts. Currently no input/output streams. There is only one stream manager. [Instance 1: spout1] - instance_id = "instance1" - task_id = 100 - component_index = 0 - component_name = "spout1" [Instance 2: bolt1] - instance_id = "instance2" - task_id = 200 - component_index = 0 - component_name = "bolt1" [instance 3: bolt2] - instance_id = "instance3" - task_id = 300 - component_index = 0 - component_name = "bolt2" :returns: PhysicalPlan message and a list of dictionaries for each instance containing (instance_id, task_id, comp_index, comp_name) """ spout_1 = mock_protobuf.get_mock_spout(component=mock_protobuf.get_mock_component(name="spout1")) bolt_1 = mock_protobuf.get_mock_bolt(component=mock_protobuf.get_mock_component(name="bolt1")) bolt_2 = mock_protobuf.get_mock_bolt(component=mock_protobuf.get_mock_component(name="bolt2")) topology = mock_protobuf.get_mock_topology(spouts=[spout_1], bolts=[bolt_1, bolt_2]) instance_ids = ["instance1", "instance2", "instancer3"] task_ids = [100, 200, 300] comp_indexes = [0, 0, 0] comp_names = ["spout1", "bolt1", "bolt2"] instances = [] for i_id, t_id, c_i, c_name in zip(instance_ids, task_ids, comp_indexes, comp_names): info = mock_protobuf.get_mock_instance_info(task_id=t_id, component_index=c_i, component_name=c_name) instance = mock_protobuf.get_mock_instance(instance_id=i_id, info=info) instances.append(instance) pplan = mock_protobuf.get_mock_pplan(topology=topology, instances=instances) keys = ["instance_id", "task_id", "comp_index", "comp_name"] zipped = zip(instance_ids, task_ids, comp_indexes, comp_names) return pplan, [dict(zip(keys, z)) for z in zipped]
def __init__(self): socket_options = SocketOptions(32768, 16, 32768, 16, 1024000, 1024000) with patch( "heron.instance.src.python.utils.system_config.get_sys_config", side_effect=lambda: {constants.INSTANCE_RECONNECT_STREAMMGR_INTERVAL_SEC: 10}): SingleThreadStmgrClient.__init__(self, EventLooper(), None, self.HOST, self.PORT, "topology_name", "topology_id", mock_protobuf.get_mock_instance(), {}, None, socket_options) self.register_msg_called = False self.handle_register_response_called = False
def __init__(self): socket_options = SocketOptions(32768, 16, 32768, 16, 1024000, 1024000) with patch( "heron.instance.src.python.utils.system_config.get_sys_config", side_effect=lambda: { constants.INSTANCE_RECONNECT_METRICSMGR_INTERVAL_SEC: 10, constants.INSTANCE_METRICS_SYSTEM_SAMPLE_INTERVAL_SEC: 10 }): stream = HeronCommunicator(producer_cb=None, consumer_cb=None) MetricsManagerClient.__init__(self, EventLooper(), self.HOST, self.PORT, mock_protobuf.get_mock_instance(), HeronCommunicator(), stream, stream, {}, socket_options, Mock(), Mock()) self.register_req_called = False