Rename API endpoint for `get_runs_by_run_metadata_key`.

The route for `get_runs_by_run_metadata_key` conflicted with the
`get_test_runs_by_build_name` route when grouping by the
`build_name` metadata key. This moves the route into the
`/runs/key/` namespace to prevent it from colliding with other
endpoints.

Change-Id: I64280febe39eaecd7b694aea7f5d39df5c1bc45c
This commit is contained in:
Tim 2015-12-16 17:40:55 -07:00
parent 8559e8f0b9
commit 821601b16d
7 changed files with 17 additions and 12 deletions

View File

@ -69,7 +69,7 @@ function HealthService($http, config) {
service.getRunsForRunMetadataKey = function(runMetadataKey, value, options) { service.getRunsForRunMetadataKey = function(runMetadataKey, value, options) {
return config.get().then(function(config) { return config.get().then(function(config) {
return $http.jsonp(config.apiRoot + '/' + runMetadataKey + '/' + value + '/runs', { return $http.jsonp(config.apiRoot + '/runs/key/' + runMetadataKey + '/' + value, {
params: angular.extend(options, { callback: 'JSON_CALLBACK' }) params: angular.extend(options, { callback: 'JSON_CALLBACK' })
}); });
}); });

View File

@ -210,7 +210,7 @@ def _aggregate_runs(runs_by_time_delta):
return dict(timedelta=aggregated_runs) return dict(timedelta=aggregated_runs)
@app.route('/<path:run_metadata_key>/<path:value>/runs', methods=['GET']) @app.route('/runs/key/<path:run_metadata_key>/<path:value>', methods=['GET'])
def get_runs_by_run_metadata_key(run_metadata_key, value): def get_runs_by_run_metadata_key(run_metadata_key, value):
global Session global Session
session = Session() session = Session()

View File

@ -357,7 +357,8 @@ class TestRestAPI(base.TestCase):
def test_get_runs_by_project_resolution_sec(self, api_mock): def test_get_runs_by_project_resolution_sec(self, api_mock):
api.Session = mock.MagicMock() api.Session = mock.MagicMock()
query = 'datetime_resolution=sec' query = 'datetime_resolution=sec'
res = self.app.get('/project/openstack/trove/runs?{0}'.format(query)) res = self.app.get('/runs/key/project/openstack/trove?{0}'
.format(query))
self.assertEqual(200, res.status_code) self.assertEqual(200, res.status_code)
@ -411,7 +412,8 @@ class TestRestAPI(base.TestCase):
def test_get_runs_by_project_resolution_min(self, api_mock): def test_get_runs_by_project_resolution_min(self, api_mock):
api.Session = mock.MagicMock() api.Session = mock.MagicMock()
query = 'datetime_resolution=min' query = 'datetime_resolution=min'
res = self.app.get('/project/openstack/trove/runs?{0}'.format(query)) res = self.app.get('/runs/key/project/openstack/trove?{0}'
.format(query))
self.assertEqual(200, res.status_code) self.assertEqual(200, res.status_code)
@ -465,7 +467,8 @@ class TestRestAPI(base.TestCase):
def test_get_runs_by_project_resolution_hour(self, api_mock): def test_get_runs_by_project_resolution_hour(self, api_mock):
api.Session = mock.MagicMock() api.Session = mock.MagicMock()
query = 'datetime_resolution=hour' query = 'datetime_resolution=hour'
res = self.app.get('/project/openstack/trove/runs?{0}'.format(query)) res = self.app.get('/runs/key/project/openstack/trove?{0}'
.format(query))
self.assertEqual(200, res.status_code) self.assertEqual(200, res.status_code)
@ -525,7 +528,8 @@ class TestRestAPI(base.TestCase):
def test_get_runs_by_project_resolution_day(self, api_mock): def test_get_runs_by_project_resolution_day(self, api_mock):
api.Session = mock.MagicMock() api.Session = mock.MagicMock()
query = 'datetime_resolution=day' query = 'datetime_resolution=day'
res = self.app.get('/project/openstack/trove/runs?{0}'.format(query)) res = self.app.get('/runs/key/project/openstack/trove?{0}'
.format(query))
self.assertEqual(200, res.status_code) self.assertEqual(200, res.status_code)
@ -590,7 +594,8 @@ class TestRestAPI(base.TestCase):
stop_date = timestamp_d2.date().isoformat() stop_date = timestamp_d2.date().isoformat()
query = ('datetime_resolution=day&start_date={0}&stop_date={1}' query = ('datetime_resolution=day&start_date={0}&stop_date={1}'
.format(start_date, stop_date)) .format(start_date, stop_date))
res = self.app.get('/project/openstack/trove/runs?{0}'.format(query)) res = self.app.get('/runs/key/project/openstack/trove?{0}'
.format(query))
self.assertEqual(200, res.status_code) self.assertEqual(200, res.status_code)
@ -624,7 +629,7 @@ class TestRestAPI(base.TestCase):
def test_get_runs_by_project_invalid_resolution(self): def test_get_runs_by_project_invalid_resolution(self):
api.Session = mock.MagicMock() api.Session = mock.MagicMock()
res = self.app.get( res = self.app.get(
'/projects/openstack/trove/runs?datetime_resolution=century') '/runs/key/project/openstack/trove?datetime_resolution=century')
self.assertEqual(res.status_code, 400) self.assertEqual(res.status_code, 400)
self.assertEqual('Datetime resolution: century, is not a valid choice', self.assertEqual('Datetime resolution: century, is not a valid choice',
res.data) res.data)

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
request: { request: {
method: 'JSONP', method: 'JSONP',
path: '/project/openstack/taskflow/runs' path: '/runs/key/project/openstack/taskflow'
}, },
response: { response: {
data: { data: {

View File

@ -40,7 +40,7 @@ describe('E2E: Routes', function() {
// data should actually be requested (no request if error) // data should actually be requested (no request if error)
expect(mock.requestsMade()).toContain(jasmine.objectContaining({ expect(mock.requestsMade()).toContain(jasmine.objectContaining({
url: 'http://localhost:5000/project/openstack/taskflow/runs', url: 'http://localhost:5000/runs/key/project/openstack/taskflow',
method: 'JSONP' method: 'JSONP'
})); }));

View File

@ -62,7 +62,7 @@ describe('GroupedRunsController', function() {
}; };
var endpoint = API_ROOT + var endpoint = API_ROOT +
'/project/openstack/cinder/runs?callback=JSON_CALLBACK&' + '/runs/key/project/openstack/cinder?callback=JSON_CALLBACK&' +
'datetime_resolution=hour&' + 'datetime_resolution=hour&' +
'start_date=' + startDate.toISOString() + '&' + 'start_date=' + startDate.toISOString() + '&' +
'stop_date=' + stopDate.toISOString(); 'stop_date=' + stopDate.toISOString();

View File

@ -97,7 +97,7 @@ describe('HealthService', function() {
it('should get runs from project', function() { it('should get runs from project', function() {
var expectedResponse = [{ data: 'data' }, {}, {}]; var expectedResponse = [{ data: 'data' }, {}, {}];
var endpoint = API_ROOT + var endpoint = API_ROOT +
'/project/openstack/cinder/runs?' + '/runs/key/project/openstack/cinder?' +
'callback=JSON_CALLBACK&' + 'callback=JSON_CALLBACK&' +
'start_date=' + DEFAULT_START_TIME + '&' + 'start_date=' + DEFAULT_START_TIME + '&' +
'stop_date=' + DEFAULT_END_TIME; 'stop_date=' + DEFAULT_END_TIME;