Skip to content

wip-sheriffed-frameworks #8661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion tests/webapp/api/test_performance_alertsummary_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

from tests.conftest import create_perf_alert
from treeherder.model.models import Push
from treeherder.perf.models import PerformanceAlert, PerformanceAlertSummary
from treeherder.perf.models import (
PerformanceAlert,
PerformanceAlertSummary,
PerformanceFramework,
)


@pytest.fixture
Expand Down Expand Up @@ -132,6 +136,38 @@ def test_alert_summaries_get(
}


def test_alert_summaries_sheriffed_frameworks(
client, test_perf_alert_summary, test_perf_alert_summary_2, test_perf_framework
):
# Add comments explaining what we are testing
browsertime = PerformanceFramework.objects.create(name="browsertime", enabled=True)
platform_mircobench = PerformanceFramework.objects.create(
name="platform_mircobench", enabled=True
)
test_perf_alert_summary.framework = browsertime
test_perf_alert_summary.save()
test_perf_alert_summary_2.framework = platform_mircobench
test_perf_alert_summary_2.save()
# verify that we get the performance summary + alert on GET
resp = client.get(
reverse("performance-alert-summaries-list"), {"show_sheriffed_frameworks": True}
)
assert resp.status_code == 200

assert len(resp.json()["results"]) == 1
assert resp.json()["results"][0]["framework"] == browsertime.id

test_perf_alert_summary.framework = test_perf_framework
test_perf_alert_summary.save()

resp = client.get(
reverse("performance-alert-summaries-list"), {"show_sheriffed_frameworks": True}
)
assert resp.status_code == 200

assert len(resp.json()["results"]) == 0


def test_alert_summaries_get_onhold(
client,
test_perf_alert_summary,
Expand Down
14 changes: 14 additions & 0 deletions treeherder/webapp/api/performance_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class PerformanceAlertSummaryFilter(django_filters.FilterSet):
hide_related_and_invalid = django_filters.BooleanFilter(method="_hide_related_and_invalid")
with_assignee = django_filters.CharFilter(method="_with_assignee")
timerange = django_filters.NumberFilter(method="_timerange")
show_sheriffed_frameworks = django_filters.BooleanFilter(method="_show_sheriffed_frameworks")

def _filter_text(self, queryset, name, value):
sep = Value(" ")
Expand Down Expand Up @@ -418,6 +419,19 @@ def _timerange(self, queryset, name, value):
push__time__gt=datetime.datetime.utcfromtimestamp(int(time.time() - int(value)))
)

def _show_sheriffed_frameworks(self, queryset, name, value):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should centralize them in a constant

return queryset.filter(
framework__name__in=[
"browsertime",
"awsy",
"talos",
"build_metrics",
"js-bench",
"mozperftest",
"devtools",
]
)

class Meta:
model = PerformanceAlertSummary
fields = [
Expand Down
12 changes: 12 additions & 0 deletions ui/perfherder/alerts/AlertsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ class AlertsView extends React.Component {
const frameworkOptions = cloneDeep(frameworks);
const ignoreFrameworks = { id: -1, name: 'all frameworks' };
frameworkOptions.unshift(ignoreFrameworks);
const ignoreNonSheriffedFrameworks = {
id: -2,
name: 'all sheriffed frameworks',
};
frameworkOptions.unshift(ignoreNonSheriffedFrameworks);
return frameworkOptions;
};

Expand Down Expand Up @@ -207,6 +212,9 @@ class AlertsView extends React.Component {
if (listMode && params.framework === doNotFilter) {
delete params.framework;
}
if (listMode && params.framework === -2) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to explain why we do this

delete params.framework;
}

return params;
};
Expand Down Expand Up @@ -271,6 +279,10 @@ class AlertsView extends React.Component {
if (hideAssignedToOthers) {
params.with_assignee = user.username;
}
console.log(framework);
if (framework.id === -2) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment that this is meant to be a ui artifice / workaround

params.show_sheriffed_frameworks = true;
}
}

const url = getApiUrl(
Expand Down
10 changes: 5 additions & 5 deletions ui/perfherder/alerts/AlertsViewControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ export default class AlertsViewControls extends React.Component {

let sortedFrameworks = sortData(frameworkOptions, 'name', false);
const allFrameworks = 'all frameworks';
const mozperftest = 'mozperftest';
const allSheriffedFrameworks = 'all sheriffed frameworks';
const platformMicrobench = 'platform_microbench';

sortedFrameworks = sortedFrameworks.filter(
(framework) =>
framework.name !== mozperftest &&
framework.name !== platformMicrobench &&
framework.name !== allFrameworks,
framework.name !== allFrameworks &&
framework.name !== allSheriffedFrameworks,
);

const frameworkNames =
Expand All @@ -165,8 +165,8 @@ export default class AlertsViewControls extends React.Component {
selectedItem: framework.name,
updateData: this.updateFramework,
namespace: 'framework',
pinned: [allFrameworks],
otherPinned: [mozperftest, platformMicrobench],
pinned: [allFrameworks, allSheriffedFrameworks],
otherPinned: [platformMicrobench],
},
];

Expand Down