def test_index_crash(self): """Mock test the entire crash submission mechanism""" es_storage = ESCrashStorage(config=self.config) # This is the function that would actually connect to ES; by mocking # it entirely we are ensuring that ES doesn't actually get touched. es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_processed_crash( raw_crash=deepcopy(a_raw_crash), processed_crash=deepcopy(a_processed_crash), ) # Ensure that the indexing function is only called once. assert es_storage._submit_crash_to_elasticsearch.call_count == 1
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" es_storage = ESCrashStorage(config=self.config) es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed(raw_crash=a_raw_crash, dumps=None, processed_crash=a_processed_crash, crash_id=a_processed_crash['uuid']) mock_calls = [str(call) for call in self.config.metrics.mock_calls] # NOTE(willkg): The sizes of these json documents depend on what's in them. If we changed # a_processed_crash and a_raw_crash, then these numbers will change. assert 'call.histogram(\'processor.es.raw_crash_size\', 27)' in mock_calls assert 'call.histogram(\'processor.es.processed_crash_size\', 1785)' in mock_calls
def test_index_crash(self): """Mock test the entire crash submission mechanism. """ es_storage = ESCrashStorage(config=self.config) # This is the function that would actually connect to ES; by mocking # it entirely we are ensuring that ES doesn't actually get touched. es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed(raw_crash=a_raw_crash, dumps=None, processed_crash=a_processed_crash, crash_id=a_processed_crash['uuid']) # Ensure that the indexing function is only called once. eq_(es_storage._submit_crash_to_elasticsearch.call_count, 1)
def test_index_crash(self): """Mock test the entire crash submission mechanism""" es_storage = ESCrashStorage(config=self.config) # This is the function that would actually connect to ES; by mocking # it entirely we are ensuring that ES doesn't actually get touched. es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed( raw_crash=deepcopy(a_raw_crash), dumps=None, processed_crash=deepcopy(a_processed_crash), crash_id=a_processed_crash['uuid'] ) # Ensure that the indexing function is only called once. assert es_storage._submit_crash_to_elasticsearch.call_count == 1
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" es_storage = ESCrashStorage(config=self.config) es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed( raw_crash=a_raw_crash, dumps=None, processed_crash=a_processed_crash, crash_id=a_processed_crash['uuid'] ) mock_calls = [str(call) for call in self.config.metrics.mock_calls] # NOTE(willkg): The sizes of these json documents depend on what's in them. If we changed # a_processed_crash and a_raw_crash, then these numbers will change. assert 'call.histogram(\'processor.es.raw_crash_size\', 27)' in mock_calls assert 'call.histogram(\'processor.es.processed_crash_size\', 1785)' in mock_calls
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" with MetricsMock() as mm: es_storage = ESCrashStorage(config=self.config, namespace='processor.es') es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed( raw_crash=deepcopy(a_raw_crash), dumps=None, processed_crash=deepcopy(a_processed_crash), crash_id=a_processed_crash['uuid'] ) # NOTE(willkg): The sizes of these json documents depend on what's # in them. If we changed a_processed_crash and a_raw_crash, then # these numbers will change. assert mm.has_record('histogram', stat='processor.es.raw_crash_size', value=27) assert mm.has_record('histogram', stat='processor.es.processed_crash_size', value=1738)
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" with MetricsMock() as mm: es_storage = ESCrashStorage(config=self.config, namespace='processor.es') es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_raw_and_processed( raw_crash=deepcopy(a_raw_crash), dumps=None, processed_crash=deepcopy(a_processed_crash), crash_id=a_processed_crash['uuid'] ) # NOTE(willkg): The sizes of these json documents depend on what's # in them. If we changed a_processed_crash and a_raw_crash, then # these numbers will change. assert mm.has_record('histogram', stat='processor.es.raw_crash_size', value=27) assert mm.has_record('histogram', stat='processor.es.processed_crash_size', value=1738)
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" with MetricsMock() as mm: es_storage = ESCrashStorage(config=self.config, namespace="processor.es") es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_processed_crash( raw_crash=deepcopy(a_raw_crash), processed_crash=deepcopy(a_processed_crash), ) # NOTE(willkg): The sizes of these json documents depend on what's # in them. If we changed a_processed_crash and a_raw_crash, then # these numbers will change. mm.print_records() mm.assert_histogram("processor.es.raw_crash_size", value=27) mm.assert_histogram("processor.es.processed_crash_size", value=1721)
def test_crash_size_capture(self): """Verify we capture raw/processed crash sizes in ES crashstorage""" raw_crash = {"ProductName": "Firefox", "ReleaseChannel": "nightly"} processed_crash = { "date_processed": "2012-04-08 10:56:41.558922", "uuid": "936ce666-ff3b-4c7a-9674-367fe2120408", } with MetricsMock() as mm: es_storage = ESCrashStorage(config=self.config, namespace="processor.es") es_storage._submit_crash_to_elasticsearch = mock.Mock() es_storage.save_processed_crash( raw_crash=raw_crash, processed_crash=processed_crash, ) mm.assert_histogram("processor.es.raw_crash_size", value=55) mm.assert_histogram("processor.es.processed_crash_size", value=96)