def test_export_node_with_hostname(self): requests = [] event = threading.Event() def _helper(request_iterator, context): for request in request_iterator: requests.append(request) event.set() yield self._add_and_start_service(GenericRpcHandler(_helper)) ocagent.ExportRpcHandler( self._create_stub(), service_name=SERVICE_NAME, host_name='my host').send( metrics_service_pb2.ExportMetricsServiceRequest()) self.assertTrue(event.wait(timeout=1)) self.assertEqual(requests[0].node.identifier.host_name, 'my host')
def _create_rpc_handler(stub, service_name=SERVICE_NAME): return ocagent.ExportRpcHandler(stub, SERVICE_NAME)