зеркало из https://github.com/mozilla/treeherder.git
Bug 1227740 - Detect and handle case where we alert inside a retrigger
Previously we would make the previous result set id the same as the current one, which meant we couldn't resolve the treeherder changeset.
This commit is contained in:
Родитель
1821c545b7
Коммит
2497d6f702
|
@ -90,12 +90,39 @@ def test_detect_alerts_in_series(test_project, test_repository,
|
|||
repository=test_repository,
|
||||
result_set_id=t,
|
||||
job_id=0,
|
||||
signature=signature,
|
||||
signature=test_perf_signature,
|
||||
push_timestamp=datetime.datetime.fromtimestamp(t),
|
||||
value=v)
|
||||
|
||||
generate_new_alerts_in_series(signature)
|
||||
generate_new_alerts_in_series(test_perf_signature)
|
||||
|
||||
assert PerformanceAlert.objects.count() == 2
|
||||
assert PerformanceAlertSummary.objects.count() == 2
|
||||
verify_alert(2, INTERVAL, INTERVAL-1, signature, 1.0, 2.0, True)
|
||||
_verify_alert(2, INTERVAL, INTERVAL-1, test_perf_signature, 1.0, 2.0,
|
||||
True)
|
||||
|
||||
|
||||
def test_detect_alerts_in_series_with_retriggers(
|
||||
test_project, test_repository, test_perf_signature):
|
||||
|
||||
# sometimes we detect an alert in the middle of a series
|
||||
# where there are retriggers, make sure we handle this case
|
||||
# gracefully by generating a sequence where the regression
|
||||
# "appears" in the middle of a series with the same resultset
|
||||
# to make sure things are calculated correctly
|
||||
for (r, j, v) in zip(
|
||||
([1 for i in range(30)] +
|
||||
[2 for i in range(60)]),
|
||||
[i for i in range(90)],
|
||||
([0.5 for i in range(50)] +
|
||||
[1.0 for i in range(40)])
|
||||
):
|
||||
PerformanceDatum.objects.create(
|
||||
repository=test_repository,
|
||||
result_set_id=r,
|
||||
job_id=j,
|
||||
signature=test_perf_signature,
|
||||
push_timestamp=datetime.datetime.fromtimestamp(r),
|
||||
value=v)
|
||||
generate_new_alerts_in_series(test_perf_signature)
|
||||
_verify_alert(1, 2, 1, test_perf_signature, 0.5, 1.0, True)
|
||||
|
|
|
@ -29,9 +29,15 @@ def generate_new_alerts_in_series(signature):
|
|||
testrun_id=datum.result_set_id)
|
||||
prev = None
|
||||
analyzed_series = a.analyze_t()
|
||||
|
||||
prev_testrun_id = None
|
||||
with transaction.atomic():
|
||||
for (prev, cur) in zip(analyzed_series, analyzed_series[1:]):
|
||||
# we can have the same testrun id in a sequence if there are
|
||||
# retriggers, so only set the prev_testrun_id if that isn't
|
||||
# the case
|
||||
if prev.testrun_id != cur.testrun_id:
|
||||
prev_testrun_id = prev.testrun_id
|
||||
|
||||
if cur.state == 'regression':
|
||||
prev_value = cur.historical_stats['avg']
|
||||
new_value = cur.forward_stats['avg']
|
||||
|
@ -54,7 +60,7 @@ def generate_new_alerts_in_series(signature):
|
|||
summary, _ = PerformanceAlertSummary.objects.get_or_create(
|
||||
repository=signature.repository,
|
||||
result_set_id=cur.testrun_id,
|
||||
prev_result_set_id=prev.testrun_id,
|
||||
prev_result_set_id=prev_testrun_id,
|
||||
defaults={
|
||||
'last_updated': datetime.datetime.fromtimestamp(
|
||||
cur.push_timestamp)
|
||||
|
|
Загрузка…
Ссылка в новой задаче