summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jjb/releng/opnfv-docker.sh18
-rw-r--r--prototypes/xci/playbooks/configure-opnfvhost.yml5
-rw-r--r--utils/test/testapi/opnfv_testapi/common/raises.py31
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/handlers.py43
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/result_handlers.py5
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py6
6 files changed, 64 insertions, 44 deletions
diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh
index 9bd711bc6..5d73a9d70 100644
--- a/jjb/releng/opnfv-docker.sh
+++ b/jjb/releng/opnfv-docker.sh
@@ -17,14 +17,16 @@ echo "Starting opnfv-docker for $DOCKER_REPO_NAME ..."
echo "--------------------------------------------------------"
echo
-
-if [[ -n $(ps -ef|grep 'docker build'|grep -v grep) ]]; then
- echo "There is already another build process in progress:"
- echo $(ps -ef|grep 'docker build'|grep -v grep)
- # Abort this job since it will collide and might mess up the current one.
- echo "Aborting..."
- exit 1
-fi
+count=30 # docker build jobs might take up to ~30 min
+while [[ -n `ps -ef|grep 'docker build'|grep -v grep` ]]; do
+ echo "Build in progress. Waiting..."
+ sleep 60
+ count=$(( $count - 1 ))
+ if [ $count -eq 0 ]; then
+ echo "Timeout. Aborting..."
+ exit 1
+ fi
+done
# Remove previous running containers if exist
if [[ -n "$(docker ps -a | grep $DOCKER_REPO_NAME)" ]]; then
diff --git a/prototypes/xci/playbooks/configure-opnfvhost.yml b/prototypes/xci/playbooks/configure-opnfvhost.yml
index abebd1d7f..6689c8dc7 100644
--- a/prototypes/xci/playbooks/configure-opnfvhost.yml
+++ b/prototypes/xci/playbooks/configure-opnfvhost.yml
@@ -17,6 +17,8 @@
- role: remove-folders
- { role: clone-repository, project: "opnfv/releng", repo: "{{ OPNFV_RELENG_GIT_URL }}", dest: "{{ OPNFV_RELENG_PATH }}", version: "{{ OPNFV_RELENG_VERSION }}" }
- { role: clone-repository, project: "openstack/openstack-ansible", repo: "{{ OPENSTACK_OSA_GIT_URL }}", dest: "{{ OPENSTACK_OSA_PATH }}", version: "{{ OPENSTACK_OSA_VERSION }}" }
+ # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
+ - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
tasks:
- name: generate SSH keys
shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
@@ -48,9 +50,6 @@
shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/setup-openstack.yml {{OPENSTACK_OSA_PATH}}/playbooks"
- name: copy OPNFV role requirements
shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/ansible-role-requirements.yml {{OPENSTACK_OSA_PATH}}"
- roles:
- # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
- - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
- hosts: localhost
remote_user: root
tasks:
diff --git a/utils/test/testapi/opnfv_testapi/common/raises.py b/utils/test/testapi/opnfv_testapi/common/raises.py
new file mode 100644
index 000000000..ed3a84ee0
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/common/raises.py
@@ -0,0 +1,31 @@
+import httplib
+
+from tornado import web
+
+
+class Raiser(object):
+ code = httplib.OK
+
+ def __init__(self, reason):
+ raise web.HTTPError(self.code, reason)
+
+
+class BadRequest(Raiser):
+ code = httplib.BAD_REQUEST
+
+
+class Forbidden(Raiser):
+ code = httplib.FORBIDDEN
+
+
+class NotFound(Raiser):
+ code = httplib.NOT_FOUND
+
+
+class Unauthorized(Raiser):
+ code = httplib.UNAUTHORIZED
+
+
+class CodeTBD(object):
+ def __init__(self, code, reason):
+ raise web.HTTPError(code, reason)
diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py
index bf8a92b54..c2b1a6476 100644
--- a/utils/test/testapi/opnfv_testapi/resources/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py
@@ -22,13 +22,13 @@
from datetime import datetime
import functools
-import httplib
import json
from tornado import gen
from tornado import web
import models
+from opnfv_testapi.common import raises
from opnfv_testapi.tornado_swagger import swagger
DEFAULT_REPRESENTATION = "application/json"
@@ -56,9 +56,7 @@ class GenericApiHandler(web.RequestHandler):
try:
self.json_args = json.loads(self.request.body)
except (ValueError, KeyError, TypeError) as error:
- raise web.HTTPError(httplib.BAD_REQUEST,
- "Bad Json format [{}]".
- format(error))
+ raises.BadRequest("Bad Json format [{}]".format(error))
def finish_request(self, json_object=None):
if json_object:
@@ -83,13 +81,11 @@ class GenericApiHandler(web.RequestHandler):
try:
token = self.request.headers['X-Auth-Token']
except KeyError:
- raise web.HTTPError(httplib.UNAUTHORIZED,
- "No Authentication Header.")
+ raises.Unauthorized("No Authentication Header.")
query = {'access_token': token}
check = yield self._eval_db_find_one(query, 'tokens')
if not check:
- raise web.HTTPError(httplib.FORBIDDEN,
- "Invalid Token.")
+ raises.Forbidden("Invalid Token.")
ret = yield gen.coroutine(method)(self, *args, **kwargs)
raise gen.Return(ret)
return wrapper
@@ -101,14 +97,13 @@ class GenericApiHandler(web.RequestHandler):
:param db_checks: [(table, exist, query, error)]
"""
if self.json_args is None:
- raise web.HTTPError(httplib.BAD_REQUEST, "no body")
+ raises.BadRequest('no body')
data = self.table_cls.from_dict(self.json_args)
for miss in miss_checks:
miss_data = data.__getattribute__(miss)
if miss_data is None or miss_data == '':
- raise web.HTTPError(httplib.BAD_REQUEST,
- '{} missing'.format(miss))
+ raises.BadRequest('{} missing'.format(miss))
for k, v in kwargs.iteritems():
data.__setattr__(k, v)
@@ -117,7 +112,7 @@ class GenericApiHandler(web.RequestHandler):
check = yield self._eval_db_find_one(query(data), table)
if (exist and not check) or (not exist and check):
code, message = error(data)
- raise web.HTTPError(code, message)
+ raises.CodeTBD(code, message)
if self.table != 'results':
data.creation_date = datetime.now()
@@ -153,18 +148,16 @@ class GenericApiHandler(web.RequestHandler):
def _get_one(self, query):
data = yield self._eval_db_find_one(query)
if data is None:
- raise web.HTTPError(httplib.NOT_FOUND,
- "[{}] not exist in table [{}]"
- .format(query, self.table))
+ raises.NotFound("[{}] not exist in table [{}]"
+ .format(query, self.table))
self.finish_request(self.format_data(data))
@authenticate
def _delete(self, query):
data = yield self._eval_db_find_one(query)
if data is None:
- raise web.HTTPError(httplib.NOT_FOUND,
- "[{}] not exit in table [{}]"
- .format(query, self.table))
+ raises.NotFound("[{}] not exit in table [{}]"
+ .format(query, self.table))
yield self._eval_db(self.table, 'remove', query)
self.finish_request()
@@ -172,14 +165,13 @@ class GenericApiHandler(web.RequestHandler):
@authenticate
def _update(self, query, db_keys):
if self.json_args is None:
- raise web.HTTPError(httplib.BAD_REQUEST, "No payload")
+ raises.BadRequest("No payload")
# check old data exist
from_data = yield self._eval_db_find_one(query)
if from_data is None:
- raise web.HTTPError(httplib.NOT_FOUND,
- "{} could not be found in table [{}]"
- .format(query, self.table))
+ raises.NotFound("{} could not be found in table [{}]"
+ .format(query, self.table))
data = self.table_cls.from_dict(from_data)
# check new data exist
@@ -187,9 +179,8 @@ class GenericApiHandler(web.RequestHandler):
if not equal:
to_data = yield self._eval_db_find_one(new_query)
if to_data is not None:
- raise web.HTTPError(httplib.FORBIDDEN,
- "{} already exists in table [{}]"
- .format(new_query, self.table))
+ raises.Forbidden("{} already exists in table [{}]"
+ .format(new_query, self.table))
# we merge the whole document """
edit_request = self._update_requests(data)
@@ -206,7 +197,7 @@ class GenericApiHandler(web.RequestHandler):
request = self._update_request(request, k, v,
data.__getattribute__(k))
if not request:
- raise web.HTTPError(httplib.FORBIDDEN, "Nothing to update")
+ raises.Forbidden("Nothing to update")
edit_request = data.format()
edit_request.update(request)
diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
index 44b9f8c07..3e78057ce 100644
--- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py
@@ -11,8 +11,8 @@ from datetime import timedelta
import httplib
from bson import objectid
-from tornado import web
+from opnfv_testapi.common import raises
from opnfv_testapi.resources import handlers
from opnfv_testapi.resources import result_models
from opnfv_testapi.tornado_swagger import swagger
@@ -30,8 +30,7 @@ class GenericResultHandler(handlers.GenericApiHandler):
try:
value = int(value)
except:
- raise web.HTTPError(httplib.BAD_REQUEST,
- '{} must be int'.format(key))
+ raises.BadRequest('{} must be int'.format(key))
return value
def set_query(self):
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index a2856dbd7..9d0233c77 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -1,8 +1,7 @@
import functools
import httplib
-from tornado import web
-
+from opnfv_testapi.common import raises
from opnfv_testapi.resources import handlers
import opnfv_testapi.resources.scenario_models as models
from opnfv_testapi.tornado_swagger import swagger
@@ -185,8 +184,7 @@ class ScenarioGURHandler(GenericScenarioHandler):
def _update_requests_rename(self, data):
data.name = self._term.get('name')
if not data.name:
- raise web.HTTPError(httplib.BAD_REQUEST,
- "new scenario name is not provided")
+ raises.BadRequest("new scenario name is not provided")
def _update_requests_add_installer(self, data):
data.installers.append(models.ScenarioInstaller.from_dict(self._term))