|
6 | 6 |
|
7 | 7 | from tests.conftest import create_perf_alert
|
8 | 8 | from treeherder.model.models import Push
|
9 |
| -from treeherder.perf.models import PerformanceAlert, PerformanceAlertSummary |
| 9 | +from treeherder.perf.models import ( |
| 10 | + PerformanceAlert, |
| 11 | + PerformanceAlertSummary, |
| 12 | + PerformanceFramework, |
| 13 | +) |
10 | 14 |
|
11 | 15 | pytestmark = pytest.mark.perf
|
12 | 16 |
|
@@ -153,6 +157,35 @@ def test_alert_summaries_get_multiple_alerts(
|
153 | 157 | assert len(set([result["id"] for result in data["results"]])) == 2
|
154 | 158 |
|
155 | 159 |
|
| 160 | +def test_alert_summaries_sheriffed_frameworks( |
| 161 | + client, test_perf_alert_summary, test_perf_alert_summary_2, test_perf_framework |
| 162 | +): |
| 163 | + # verify that we return only the sheriffed framework alerts if show_sheriffed_frameworks is True |
| 164 | + sheriffed_framework = PerformanceFramework.objects.create(name="browsertime", enabled=True) |
| 165 | + non_sheriffed_framework = PerformanceFramework.objects.create( |
| 166 | + name="platform_microbench", enabled=True |
| 167 | + ) |
| 168 | + test_perf_alert_summary.framework = sheriffed_framework |
| 169 | + test_perf_alert_summary.save() |
| 170 | + test_perf_alert_summary_2.framework = non_sheriffed_framework |
| 171 | + test_perf_alert_summary_2.save() |
| 172 | + resp = client.get( |
| 173 | + reverse("performance-alert-summaries-list"), {"show_sheriffed_frameworks": True} |
| 174 | + ) |
| 175 | + assert resp.status_code == 200 |
| 176 | + # Should only include the sheriffed alert (browsertime) |
| 177 | + assert len(resp.json()["results"]) == 1 |
| 178 | + assert resp.json()["results"][0]["framework"] == sheriffed_framework.id |
| 179 | + test_perf_alert_summary.framework = test_perf_framework |
| 180 | + test_perf_alert_summary.save() |
| 181 | + resp = client.get( |
| 182 | + reverse("performance-alert-summaries-list"), {"show_sheriffed_frameworks": True} |
| 183 | + ) |
| 184 | + assert resp.status_code == 200 |
| 185 | + # Should return no results, since test_talos is not a sheriffed framework |
| 186 | + assert len(resp.json()["results"]) == 0 |
| 187 | + |
| 188 | + |
156 | 189 | def test_alert_summaries_get_onhold(
|
157 | 190 | client,
|
158 | 191 | test_perf_alert_summary,
|
|
0 commit comments