Bug 1513486 - Remove /runnable_jobs/ API

Since it's only used by the frontend as a fallback for when it cannot
find a non-gzipped version of `runnable-jobs.json`, and enough time has
now passed for all jobs to have that file.
This commit is contained in:
Ed Morley 2019-02-08 12:16:31 +00:00
Родитель 394990452a
Коммит a9aa1d5a27
5 изменённых файлов: 2 добавлений и 71 удалений

Просмотреть файл

@ -78,8 +78,6 @@ In order to do so we need to:
- SETA uses mozilla-inbound as a reference for jobs for all trunk trees
- Make sure the job shows up in the [runnable jobs API]
- Update the job priority table from the shell:
Open the Python shell using `./manage.py shell`, then enter:
@ -101,5 +99,3 @@ In order to do so we need to:
JobPriority.objects.filter(platform="windows7-32-stylo", priority=1).update(priority=5);
JobPriority.objects.filter(platform="windows7-32-stylo", expiration_date__isnull=False).update(expiration_date=None)
```
[runnable jobs api]: https://treeherder.mozilla.org/api/project/mozilla-inbound/runnable_jobs/

Просмотреть файл

@ -1,25 +0,0 @@
from django.conf import settings
from django.urls import reverse
from mock import patch
# _taskcluster_runnable_jobs() is tested in test_taskcluster_runnable_jobs(),
# so mocking here is fine, given the API only counts/wraps the results.
@patch('treeherder.etl.runnable_jobs._taskcluster_runnable_jobs', return_value=[{'foo': 'bar'}])
def test_runnable_jobs_api(_taskcluster_runnable_jobs, client):
project_name = settings.TREEHERDER_TEST_REPOSITORY_NAME
url = reverse('runnable_jobs-list', kwargs={'project': project_name})
resp = client.get(url)
_taskcluster_runnable_jobs.assert_called_with(project_name, None)
assert resp.status_code == 200
assert resp.json() == {
'meta': {
'count': 1,
'offset': 0,
'repository': project_name,
},
'results': [{
'foo': 'bar',
}],
}

Просмотреть файл

@ -1,21 +0,0 @@
from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.status import HTTP_500_INTERNAL_SERVER_ERROR
from treeherder.etl.runnable_jobs import list_runnable_jobs
class RunnableJobsViewSet(viewsets.ViewSet):
"""
This viewset is responsible for the runnable_jobs endpoint.
"""
def list(self, request, project):
"""
GET method implementation for list of all runnable buildbot jobs
"""
try:
return Response(list_runnable_jobs(project, request.query_params.get('decision_task_id')))
except Exception as ex:
return Response("Exception: {0}".format(ex), status=HTTP_500_INTERNAL_SERVER_ERROR)

Просмотреть файл

@ -14,7 +14,6 @@ from treeherder.webapp.api import (auth,
performance_data,
push,
refdata,
runnable_jobs,
seta,
text_log_error)
@ -28,12 +27,6 @@ project_bound_router.register(
base_name='jobs',
)
project_bound_router.register(
r'runnable_jobs',
runnable_jobs.RunnableJobsViewSet,
base_name='runnable_jobs',
)
project_bound_router.register(
r'seta/job-priorities',
seta.SetaJobPriorityViewSet,

Просмотреть файл

@ -1,4 +1,3 @@
import { getProjectUrl } from '../helpers/location';
import { getRunnableJobsURL } from '../helpers/url';
import { escapeId } from '../helpers/aggregateId';
@ -10,19 +9,8 @@ export default class RunnableJobModel {
}
static async getList(repoName, params) {
let uri = getRunnableJobsURL(params.decision_task_id);
let rawJobs = await fetch(uri).then(response => response.json());
// TODO: Remove this fallback once the gz artifacts expire
if (rawJobs.code === 'ResourceNotFound') {
uri = getProjectUrl('/runnable_jobs/');
rawJobs = await JobModel.getList(repoName, params, { uri });
rawJobs.forEach(job => {
job.push_id = params.push_id;
job.id = escapeId(params.push_id + job.ref_data_name);
});
return rawJobs;
}
const uri = getRunnableJobsURL(params.decision_task_id);
const rawJobs = await fetch(uri).then(response => response.json());
return Object.entries(rawJobs).map(
([key, value]) =>