def test_performance_signatures_are_deleted(test_perf_signature, mock_taskcluster_notify): cycler = PerfherderCycler(chunk_size=100, sleep_time=0) expired_timestamp = cycler.max_timestamp perf_signature_to_delete = PerformanceSignature.objects.create( signature_hash='b' * 40, repository=test_perf_signature.repository, framework=test_perf_signature.framework, platform=test_perf_signature.platform, option_collection=test_perf_signature.option_collection, suite=test_perf_signature.suite, test='test_perf_signature_to_delete', last_updated=expired_timestamp, has_subtests=False, ) perf_signature_to_keep = PerformanceSignature.objects.create( signature_hash='h' * 40, repository=test_perf_signature.repository, framework=test_perf_signature.framework, platform=test_perf_signature.platform, option_collection=test_perf_signature.option_collection, suite=test_perf_signature.suite, test='test_perf_signature_to_keep', last_updated=datetime.now(), has_subtests=False, ) call_command('cycle_data', 'from:perfherder') assert perf_signature_to_keep.id in list( PerformanceSignature.objects.values_list('id', flat=True)) assert perf_signature_to_delete.id not in list( PerformanceSignature.objects.values_list('id', flat=True))
def test_performance_cycler_quit_indicator(mock_taskcluster_notify): ten_minutes_ago = datetime.now() - timedelta(minutes=10) one_second = timedelta(seconds=1) two_seconds_ago = datetime.now() - timedelta(seconds=2) five_minutes = timedelta(minutes=5) with pytest.raises(MaxRuntimeExceeded): PerfherderCycler(chunk_size=100, sleep_time=0) max_runtime = MaxRuntime(max_runtime=one_second) max_runtime.started_at = ten_minutes_ago max_runtime.quit_on_timeout() try: PerfherderCycler(chunk_size=100, sleep_time=0) max_runtime = MaxRuntime(max_runtime=five_minutes) max_runtime.started_at = two_seconds_ago max_runtime.quit_on_timeout() except MaxRuntimeExceeded: pytest.fail('Performance cycling shouldn\'t have timed out')
def test_signature_remover( test_perf_signature, test_perf_signature_2, test_perf_data, taskcluster_notify_mock, mock_tc_prod_credentials, ): cycler = PerfherderCycler(chunk_size=100, sleep_time=0) expired_timestamp = cycler.max_timestamp test_perf_signature_2.last_updated = expired_timestamp test_perf_signature_2.save() assert len(PerformanceSignature.objects.all()) == 2 call_command('cycle_data', 'from:perfherder') assert taskcluster_notify_mock.email.call_count == 1 assert len(PerformanceSignature.objects.all()) == 1 assert PerformanceSignature.objects.first() == test_perf_signature