def test_omaha_versions(self, mocked_get_logger): gpm['Version__limit_size'] = 1 version_size = 1000 * 1024 * 1023 versions = VersionFactory.create_batch(2, file_size=version_size) deleted_version = versions[0] self.assertEqual(Version.objects.count(), 2) extra_meta = dict(count=1, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Version', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Version_id=deleted_version.id, element_created=deleted_version.created.strftime( "%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID( '36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['omaha', 'Version'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 2) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_symbols(self, mocked_get_logger): gpm['Feedback__limit_size'] = 1 symbols_size = 100 * 1024 * 1023 symbols = SymbolsFactory.create_batch(20, file_size=symbols_size) deleted_symbols = symbols[7] self.assertEqual(Symbols.objects.count(), 20) extra_meta = dict(count=10, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Symbols', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(id=deleted_symbols.id, element_created=deleted_symbols.created.strftime( "%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID( '36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['crash', 'Symbols'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 11) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_feedbacks(self, mocked_get_logger): gpm['Feedback__limit_size'] = 1 feedback_size = 100 * 1024 * 1023 feedbacks = FeedbackFactory.create_batch(20, screenshot_size=feedback_size, system_logs_size=0, attached_file_size=0, blackbox_size=0) deleted_feedback = feedbacks[7] self.assertEqual(Feedback.objects.count(), 20) extra_meta = dict(count=10, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Feedback', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Feedback_id=deleted_feedback.id, element_created=deleted_feedback.created.strftime( "%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID( '36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['feedback', 'Feedback'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 11) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_sparkle_versions(self, mocked_get_logger): gpm['SparkleVersion__limit_size'] = 1 version_size = 1000*1024*1023 versions = SparkleVersionFactory.create_batch(2, file_size=version_size) deleted_version = versions[0] self.assertEqual(SparkleVersion.objects.count(), 2) extra_meta = dict(count=1, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='SparkleVersion', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(SparkleVersion_id=deleted_version.id, element_created=deleted_version.created.strftime("%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID('36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['sparkle', 'SparkleVersion'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 2) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_symbols(self, mocked_get_logger): gpm['Feedback__limit_size'] = 1 symbols_size = 100*1024*1023 symbols = SymbolsFactory.create_batch(20, file_size=symbols_size) deleted_symbols = symbols[7] self.assertEqual(Symbols.objects.count(), 20) extra_meta = dict(count=10, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Symbols', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Symbols_id=deleted_symbols.id, element_created=deleted_symbols.created.strftime("%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID('36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['crash', 'Symbols'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 11) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_crashes(self, mocked_get_logger): gpm['Crash__duplicate_number'] = 2 crashes = CrashFactory.create_batch(10, signature='test') deleted_crash = crashes[7] self.assertEqual(Crash.objects.count(), 10) extra_meta = dict(count=8, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Crash', limit_duplicated=2, limit_size=None, limit_days=None, size='0 bytes') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Crash_id=deleted_crash.id, element_created=deleted_crash.created.strftime( "%d. %B %Y %I:%M%p"), signature=deleted_crash.signature, userid=deleted_crash.userid, appid=deleted_crash.appid, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID( '36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['crash', 'Crash'], limit_duplicated=2) self.assertEqual(mocked_logger.info.call_count, 10) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_feedbacks(self, mocked_get_logger): gpm['Feedback__limit_size'] = 1 feedback_size = 100*1024*1023 feedbacks = FeedbackFactory.create_batch(20, screenshot_size=feedback_size, system_logs_size=0, attached_file_size=0, blackbox_size=0) deleted_feedback = feedbacks[7] self.assertEqual(Feedback.objects.count(), 20) extra_meta = dict(count=10, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Feedback', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Feedback_id=deleted_feedback.id, element_created=deleted_feedback.created.strftime("%d. %B %Y %I:%M%p"), log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID('36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['feedback', 'Feedback'], limit_size=1) self.assertEqual(mocked_logger.info.call_count, 11) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)
def test_crashes(self, mocked_get_logger): gpm['Crash__duplicate_number'] = 2 crashes = CrashFactory.create_batch(10, signature='test') deleted_crash = crashes[7] self.assertEqual(Crash.objects.count(), 10) extra_meta = dict(count=8, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00', model='Crash', limit_duplicated=2, limit_size=None, limit_days=None, size='0 bytes') log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta) extra = dict(Crash_id=deleted_crash.id, element_created=deleted_crash.created.strftime("%d. %B %Y %I:%M%p"), signature=deleted_crash.signature, userid=deleted_crash.userid, appid=deleted_crash.appid, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00') log_msg = add_extra_to_log_message('Manual cleanup element', extra=extra) mocked_logger = mocked_get_logger.return_value with patch('uuid.uuid4') as mocked_uuid4: mocked_uuid4.side_effect = (uuid.UUID('36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100)) deferred_manual_cleanup(['crash', 'Crash'], limit_duplicated=2) self.assertEqual(mocked_logger.info.call_count, 10) mocked_logger.info.assert_any_call(log_extra_msg) mocked_logger.info.assert_any_call(log_msg)