зеркало из https://github.com/mozilla/treeherder.git
Revert "Bug 1919588 - Add a new testing alert table, along with new fields. (#8200)" for uniqueness failure
This reverts commit fb59b00868
.
This commit is contained in:
Родитель
34fb5344e4
Коммит
2f33cc4d79
|
@ -101,9 +101,9 @@ def test_reassigning_regression(
|
|||
|
||||
assert s.status == PerformanceAlertSummary.UNTRIAGED
|
||||
|
||||
# reassigning a regression that was in the first summary
|
||||
# to the second summary should leave the status as UNTRIAGED
|
||||
reassigned_alert = create_perf_alert(
|
||||
# reassigning a regression to the initial summary
|
||||
# which contains only an improvement
|
||||
create_perf_alert(
|
||||
summary=s,
|
||||
series_signature=signature1,
|
||||
related_summary=test_perf_alert_summary_2,
|
||||
|
@ -117,12 +117,9 @@ def test_reassigning_regression(
|
|||
# the regression alert will keep it's status of REASSIGNED
|
||||
untriaged_improvement_alert.status = PerformanceAlert.ACKNOWLEDGED
|
||||
untriaged_improvement_alert.save()
|
||||
assert reassigned_alert.status == PerformanceAlert.REASSIGNED
|
||||
|
||||
# Status of the summary with only improvements should automatically
|
||||
# have a status of IMPROVEMENT
|
||||
s = PerformanceAlertSummary.objects.get(id=1)
|
||||
assert s.status == PerformanceAlertSummary.IMPROVEMENT
|
||||
assert s.status == PerformanceAlertSummary.INVESTIGATING
|
||||
|
||||
|
||||
def test_improvement_summary_status_after_reassigning_regression(
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
# Generated by Django 5.1.2 on 2024-10-16 18:38
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("perf", "0054_performancealert_confidence_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="performancealerttesting",
|
||||
name="related_summary",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="performancealerttesting",
|
||||
name="summary",
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name="performancealerttesting",
|
||||
unique_together=None,
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="performancealerttesting",
|
||||
name="classifier",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="performancealerttesting",
|
||||
name="series_signature",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="performancealert",
|
||||
name="confidence",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="performancealert",
|
||||
name="detection_method",
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name="PerformanceAlertSummaryTesting",
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name="PerformanceAlertTesting",
|
||||
),
|
||||
]
|
|
@ -256,7 +256,7 @@ class IssueTracker(models.Model):
|
|||
return f"{self.name} (tasks via {self.task_base_url})"
|
||||
|
||||
|
||||
class PerformanceAlertSummaryBase(models.Model):
|
||||
class PerformanceAlertSummary(models.Model):
|
||||
"""
|
||||
A summarization of performance alerts
|
||||
|
||||
|
@ -351,64 +351,61 @@ class PerformanceAlertSummaryBase(models.Model):
|
|||
self.status = self.autodetermine_status()
|
||||
self.save(using=using)
|
||||
|
||||
def autodetermine_status(self, alert_model=None):
|
||||
summary_class = self.__class__
|
||||
if not alert_model:
|
||||
alert_model = PerformanceAlert
|
||||
|
||||
alerts = alert_model.objects.filter(summary=self) | alert_model.objects.filter(
|
||||
def autodetermine_status(self):
|
||||
alerts = PerformanceAlert.objects.filter(summary=self) | PerformanceAlert.objects.filter(
|
||||
related_summary=self
|
||||
)
|
||||
|
||||
# if no alerts yet, we'll say untriaged
|
||||
if not alerts:
|
||||
return summary_class.UNTRIAGED
|
||||
return PerformanceAlertSummary.UNTRIAGED
|
||||
|
||||
# if any untriaged, then set to untriaged
|
||||
if any(alert.status == alert_model.UNTRIAGED for alert in alerts):
|
||||
return summary_class.UNTRIAGED
|
||||
if any(alert.status == PerformanceAlert.UNTRIAGED for alert in alerts):
|
||||
return PerformanceAlertSummary.UNTRIAGED
|
||||
|
||||
# if the summary's status is IMPROVEMENT, but a regression is
|
||||
# reassigned to that summary then set the summary's status to untriaged
|
||||
# and change all acknowledged statuses to untriaged
|
||||
if self.status == summary_class.IMPROVEMENT:
|
||||
if self.status == PerformanceAlertSummary.IMPROVEMENT:
|
||||
if any(
|
||||
alert.status == alert_model.REASSIGNED and alert.is_regression for alert in alerts
|
||||
alert.status == PerformanceAlert.REASSIGNED and alert.is_regression
|
||||
for alert in alerts
|
||||
):
|
||||
acknowledged_alerts = [
|
||||
alert for alert in alerts if alert.status == alert_model.ACKNOWLEDGED
|
||||
alert for alert in alerts if alert.status == PerformanceAlert.ACKNOWLEDGED
|
||||
]
|
||||
for alert in acknowledged_alerts:
|
||||
alert.status = alert_model.UNTRIAGED
|
||||
alert.status = PerformanceAlert.UNTRIAGED
|
||||
alert.save()
|
||||
return summary_class.UNTRIAGED
|
||||
return PerformanceAlertSummary.UNTRIAGED
|
||||
|
||||
# if all invalid, then set to invalid
|
||||
if all(alert.status == alert_model.INVALID for alert in alerts):
|
||||
return summary_class.INVALID
|
||||
if all(alert.status == PerformanceAlert.INVALID for alert in alerts):
|
||||
return PerformanceAlertSummary.INVALID
|
||||
|
||||
# otherwise filter out invalid alerts
|
||||
alerts = [a for a in alerts if a.status != alert_model.INVALID]
|
||||
alerts = [a for a in alerts if a.status != PerformanceAlert.INVALID]
|
||||
|
||||
# if there are any "acknowledged" alerts, then set to investigating
|
||||
# if not one of the resolved statuses and there are regressions,
|
||||
# otherwise we'll say it's an improvement
|
||||
if any(alert.status == alert_model.ACKNOWLEDGED for alert in alerts):
|
||||
if any(alert.status == PerformanceAlert.ACKNOWLEDGED for alert in alerts):
|
||||
if all(
|
||||
not alert.is_regression
|
||||
for alert in alerts
|
||||
if alert.status == alert_model.ACKNOWLEDGED
|
||||
or (alert.status == alert_model.REASSIGNED and alert.related_summary.id == self.id)
|
||||
if alert.status == PerformanceAlert.ACKNOWLEDGED
|
||||
or alert.status == PerformanceAlert.REASSIGNED
|
||||
):
|
||||
return summary_class.IMPROVEMENT
|
||||
return PerformanceAlertSummary.IMPROVEMENT
|
||||
elif self.status not in (
|
||||
summary_class.IMPROVEMENT,
|
||||
summary_class.INVESTIGATING,
|
||||
summary_class.WONTFIX,
|
||||
summary_class.FIXED,
|
||||
summary_class.BACKED_OUT,
|
||||
PerformanceAlertSummary.IMPROVEMENT,
|
||||
PerformanceAlertSummary.INVESTIGATING,
|
||||
PerformanceAlertSummary.WONTFIX,
|
||||
PerformanceAlertSummary.FIXED,
|
||||
PerformanceAlertSummary.BACKED_OUT,
|
||||
):
|
||||
return summary_class.INVESTIGATING
|
||||
return PerformanceAlertSummary.INVESTIGATING
|
||||
# keep status if one of the investigating ones
|
||||
return self.status
|
||||
|
||||
|
@ -416,10 +413,10 @@ class PerformanceAlertSummaryBase(models.Model):
|
|||
# alerts of its own: all alerts should be either reassigned,
|
||||
# downstream, or invalid (but not all invalid, that case is covered
|
||||
# above)
|
||||
if any(alert.status == alert_model.REASSIGNED for alert in alerts):
|
||||
return summary_class.REASSIGNED
|
||||
if any(alert.status == PerformanceAlert.REASSIGNED for alert in alerts):
|
||||
return PerformanceAlertSummary.REASSIGNED
|
||||
|
||||
return summary_class.DOWNSTREAM
|
||||
return PerformanceAlertSummary.DOWNSTREAM
|
||||
|
||||
def timestamp_first_triage(self):
|
||||
# called for summary specific updates (e.g. notes, bug linking)
|
||||
|
@ -428,32 +425,14 @@ class PerformanceAlertSummaryBase(models.Model):
|
|||
return self
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
db_table = "performance_alert_summary"
|
||||
unique_together = ("repository", "framework", "prev_push", "push")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.framework} {self.repository} {self.prev_push.revision}-{self.push.revision}"
|
||||
|
||||
|
||||
class PerformanceAlertSummary(PerformanceAlertSummaryBase):
|
||||
class Meta:
|
||||
db_table = "performance_alert_summary"
|
||||
unique_together = ("repository", "framework", "prev_push", "push")
|
||||
|
||||
|
||||
class PerformanceAlertSummaryTesting(PerformanceAlertSummaryBase):
|
||||
assignee = models.ForeignKey(
|
||||
User, on_delete=models.SET_NULL, null=True, related_name="assigned_alerts_testing"
|
||||
)
|
||||
|
||||
def autodetermine_status(self, alert_model=None):
|
||||
super().autodetermine_status(alert_model=PerformanceAlertTesting)
|
||||
|
||||
class Meta:
|
||||
db_table = "performance_alert_summary_testing"
|
||||
unique_together = ("repository", "framework", "prev_push", "push")
|
||||
|
||||
|
||||
class PerformanceAlertBase(models.Model):
|
||||
class PerformanceAlert(models.Model):
|
||||
"""
|
||||
A single performance alert
|
||||
|
||||
|
@ -517,15 +496,6 @@ class PerformanceAlertBase(models.Model):
|
|||
null=True,
|
||||
)
|
||||
|
||||
confidence = models.FloatField(
|
||||
help_text=(
|
||||
"A value that indicates the confidence of the alert (specific to "
|
||||
"the detection method used)"
|
||||
),
|
||||
null=True,
|
||||
)
|
||||
detection_method = models.CharField(max_length=100, null=True)
|
||||
|
||||
SKEWED = "SKEWED"
|
||||
OUTLIERS = "OUTLIERS"
|
||||
MODAL = "MODAL"
|
||||
|
@ -616,33 +586,12 @@ class PerformanceAlertBase(models.Model):
|
|||
self.summary.timestamp_first_triage().save()
|
||||
return self
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.summary} {self.series_signature} {self.amount_pct}%"
|
||||
|
||||
|
||||
class PerformanceAlert(PerformanceAlertBase):
|
||||
class Meta:
|
||||
db_table = "performance_alert"
|
||||
unique_together = ("summary", "series_signature")
|
||||
|
||||
|
||||
class PerformanceAlertTesting(PerformanceAlertBase):
|
||||
summary = models.ForeignKey(
|
||||
PerformanceAlertSummaryTesting, on_delete=models.CASCADE, related_name="alerts"
|
||||
)
|
||||
related_summary = models.ForeignKey(
|
||||
PerformanceAlertSummaryTesting,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="related_alerts",
|
||||
null=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
db_table = "performance_alert_testing"
|
||||
unique_together = ("summary", "series_signature")
|
||||
def __str__(self):
|
||||
return f"{self.summary} {self.series_signature} {self.amount_pct}%"
|
||||
|
||||
|
||||
class PerformanceTag(models.Model):
|
||||
|
|
Загрузка…
Ссылка в новой задаче