Added discovery_check to TestrunsController
Added discovery_check mixin to TestrunsController post method to avoid the need to call additional endpoints Change-Id: Ib900115eee190c1d7385d2ad6bfcda3df7f4b11d Closes-Bug: #1367359
This commit is contained in:
parent
1de6ed1c0b
commit
eedb48088a
|
@ -17,7 +17,7 @@ import logging
|
|||
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import joinedload
|
||||
from pecan import rest, expose, request
|
||||
from pecan import rest, expose, request, abort
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
|
@ -125,8 +125,24 @@ class TestrunsController(BaseRestController):
|
|||
if 'objects' in test_runs:
|
||||
test_runs = test_runs['objects']
|
||||
|
||||
res = []
|
||||
# Discover tests for all clusters in request
|
||||
clusters_ids = []
|
||||
nedded_testsets = set()
|
||||
for test_run in test_runs:
|
||||
cluster_id = test_run['metadata']['cluster_id']
|
||||
if cluster_id not in clusters_ids:
|
||||
clusters_ids.append(cluster_id)
|
||||
mixins.discovery_check(request.session,
|
||||
cluster_id,
|
||||
request.token)
|
||||
nedded_testsets.add(test_run['testset'])
|
||||
# Validate testsets from request
|
||||
test_sets = set([testset.id for testset in request.
|
||||
session.query(models.TestSet).all()])
|
||||
if nedded_testsets - test_sets:
|
||||
abort(400)
|
||||
|
||||
res = []
|
||||
for test_run in test_runs:
|
||||
test_set = test_run['testset']
|
||||
metadata = test_run['metadata']
|
||||
|
|
|
@ -84,8 +84,6 @@ class TestTestRunsController(base.BaseWSGITest):
|
|||
def setUp(self):
|
||||
super(TestTestRunsController, self).setUp()
|
||||
|
||||
controllers.TestsetsController().get(self.expected['cluster']['id'])
|
||||
|
||||
self.request_mock.body = json.dumps([
|
||||
{
|
||||
'testset': 'ha_deployment_test',
|
||||
|
|
Loading…
Reference in New Issue