def setUp(self): self.platform = PlatformBackend() self.controller = (tracing_controller_backend.TracingControllerBackend( self.platform)) self.controller._supported_agents_classes = [FakeTracingAgentBase] self.config = tracing_config.TracingConfig() self.controller_log = self.controller._trace_log
def setUp(self): # Create a real TracingControllerBackend with a mock platform backend. mock_platform = mock.Mock(spec=platform_backend.PlatformBackend) self.controller = ( tracing_controller_backend.TracingControllerBackend(mock_platform)) self.config = tracing_config.TracingConfig() # Replace the list of real tracing agent classes, with a single simple # mock agent class. Tests can also override this list. self._TRACING_AGENT_CLASSES = [] mock.patch( 'telemetry.internal.platform.tracing_controller_backend' '._TRACING_AGENT_CLASSES', new=self._TRACING_AGENT_CLASSES).start() self._SetTracingAgentClasses(MockAgentClass()) # Replace the real TraceDataBuilder with our fake one, also wire it up # so we can keep track of trace_event.clock_sync calls. def clock_sync(sync_id, issue_ts): del issue_ts # Unused. self.controller._current_state.builder.clock_syncs.append(sync_id) mock.patch('tracing.trace_data.trace_data.TraceDataBuilder', new=FakeTraceDataBuilder).start() mock.patch('py_trace_event.trace_event.clock_sync', side_effect=clock_sync).start()
def setUp(self): # Create a real TracingControllerBackend with a mock platform backend. mock_platform = mock.Mock(spec=platform_backend.PlatformBackend) self.controller = ( tracing_controller_backend.TracingControllerBackend(mock_platform)) self.config = tracing_config.TracingConfig() # Replace the list of real tracing agent classes with one containing: # - a mock TelemetryTracingAgent to work as clock sync recorder, and # - a simple mock TracingAgent. # Tests can also override this list using _SetTracingAgentClasses. self._TRACING_AGENT_CLASSES = [ MockAgentClass(clock_sync_recorder=True), MockAgentClass() ] mock.patch( 'telemetry.internal.platform.tracing_controller_backend' '._TRACING_AGENT_CLASSES', new=self._TRACING_AGENT_CLASSES).start() # Replace the real TraceDataBuilder with a fake one to record clock_syncs. mock.patch('tracing.trace_data.trace_data.TraceDataBuilder', new=FakeTraceDataBuilder).start()
def setUp(self): # Create a real TracingControllerBackend with a mock platform backend. mock_platform = mock.Mock(spec=platform_backend.PlatformBackend) self.controller = ( tracing_controller_backend.TracingControllerBackend(mock_platform)) self.config = tracing_config.TracingConfig() # Replace the telemetry_tracing_agent module with a mock. self._clock_syncs = [] def record_issuer_clock_sync(sync_id, issue_ts): del issue_ts # Unused. self._clock_syncs.append(sync_id) self.telemetry_tracing_agent = mock.patch( 'telemetry.internal.platform.tracing_controller_backend' '.telemetry_tracing_agent').start() self.telemetry_tracing_agent.RecordIssuerClockSyncMarker.side_effect = ( record_issuer_clock_sync) # Replace the list of real tracing agent classes with one containing: # - a mock TelemetryTracingAgent to work as clock sync recorder, and # - a simple mock TracingAgent. # Tests can also override this list using _SetTracingAgentClasses. self._TRACING_AGENT_CLASSES = [ self.MockAgentClass(clock_sync_recorder=True), self.MockAgentClass() ] mock.patch( 'telemetry.internal.platform.tracing_controller_backend' '._TRACING_AGENT_CLASSES', new=self._TRACING_AGENT_CLASSES).start() # Replace the real TraceDataBuilder with a fake one to collect clock_syncs. mock.patch('tracing.trace_data.trace_data.TraceDataBuilder', new=FakeTraceDataBuilder).start()
def InitPlatformBackend(self): self._network_controller_backend = ( network_controller_backend.NetworkControllerBackend(self)) self._tracing_controller_backend = ( tracing_controller_backend.TracingControllerBackend(self))