summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jjb/joid/joid-ci-jobs.yml12
-rw-r--r--jjb/joid/joid-deploy.sh23
-rw-r--r--jjb/opnfv/installer-params.yml4
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py16
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/resources/result_handlers.py19
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/tests/unit/fake_pymongo.py16
-rw-r--r--utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py44
-rw-r--r--utils/test/result_collection_api/update/__init__.py8
-rw-r--r--utils/test/result_collection_api/update/backup.py44
-rw-r--r--utils/test/result_collection_api/update/restore.py39
-rw-r--r--utils/test/result_collection_api/update/utils.py44
11 files changed, 198 insertions, 71 deletions
diff --git a/jjb/joid/joid-ci-jobs.yml b/jjb/joid/joid-ci-jobs.yml
index ddc6c1694..c861b92fe 100644
--- a/jjb/joid/joid-ci-jobs.yml
+++ b/jjb/joid/joid-ci-jobs.yml
@@ -203,7 +203,7 @@
- trigger:
name: 'joid-os-nosdn-nofeature-ha-baremetal-master-trigger'
triggers:
- - timed: ''
+ - timed: '0 2 * * *'
- trigger:
name: 'joid-os-nosdn-nofeature-ha-virtual-master-trigger'
triggers:
@@ -221,7 +221,7 @@
- trigger:
name: 'joid-os-nosdn-nofeature-ha-baremetal-brahmaputra-trigger'
triggers:
- - timed: '0 2 * * *'
+ - timed: ''
- trigger:
name: 'joid-os-nosdn-nofeature-ha-virtual-brahmaputra-trigger'
triggers:
@@ -239,7 +239,7 @@
- trigger:
name: 'joid-os-odl_l2-nofeature-ha-baremetal-master-trigger'
triggers:
- - timed: ''
+ - timed: '0 10 * * *'
- trigger:
name: 'joid-os-odl_l2-nofeature-ha-virtual-master-trigger'
triggers:
@@ -257,7 +257,7 @@
- trigger:
name: 'joid-os-odl_l2-nofeature-ha-baremetal-brahmaputra-trigger'
triggers:
- - timed: '0 10 * * *'
+ - timed: ''
- trigger:
name: 'joid-os-odl_l2-nofeature-ha-virtual-brahmaputra-trigger'
triggers:
@@ -275,7 +275,7 @@
- trigger:
name: 'joid-os-onos-nofeature-ha-baremetal-master-trigger'
triggers:
- - timed: ''
+ - timed: '0 18 * * *'
- trigger:
name: 'joid-os-onos-nofeature-ha-virtual-master-trigger'
triggers:
@@ -293,7 +293,7 @@
- trigger:
name: 'joid-os-onos-nofeature-ha-baremetal-brahmaputra-trigger'
triggers:
- - timed: '0 18 * * *'
+ - timed: ''
- trigger:
name: 'joid-os-onos-nofeature-ha-virtual-brahmaputra-trigger'
triggers:
diff --git a/jjb/joid/joid-deploy.sh b/jjb/joid/joid-deploy.sh
index 51a1469c4..bd2597320 100644
--- a/jjb/joid/joid-deploy.sh
+++ b/jjb/joid/joid-deploy.sh
@@ -223,29 +223,6 @@ curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null;
exit_on_error $? "Deploy FAILED to auth to openstack"
-
-##
-## Create external network if needed
-##
-
-# If we have more information than only the name, try to create it
-if [ -z "$EXTNET_TYPE" ]; then
- echo "------ No data for external network creation, pass ------"
-elif [[ "$DEPLOY_SCENARIO" =~ "onos" ]]; then
- echo "------ ONOS have created the external network, pass ------"
-else
- echo "------ External network creation ------"
- neutron net-create $EXTNET_NAME --router:external True \
- --provider:physical_network external --provider:network_type $EXTNET_TYPE
- exit_on_error $? "External network creation failed"
- neutron subnet-create $EXTNET_NAME --name $EXTNET_NAME \
- --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
- --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
- exit_on_error $? "External subnet creation failed"
- neutron net-update $EXTNET_NAME --shared
- exit_on_error $? "External network sharing failed"
-fi
-
##
## Exit success
##
diff --git a/jjb/opnfv/installer-params.yml b/jjb/opnfv/installer-params.yml
index c0223e235..98a15de79 100644
--- a/jjb/opnfv/installer-params.yml
+++ b/jjb/opnfv/installer-params.yml
@@ -63,8 +63,8 @@
description: 'Installer used for deploying OPNFV on this POD'
- string:
name: OS_RELEASE
- default: 'liberty'
- description: 'OpenStack release (kilo|liberty)'
+ default: 'mitaka'
+ description: 'OpenStack release (liberty|mitaka)'
- string:
name: EXTERNAL_NETWORK
default: ext-net;flat;192.168.0.2;192.168.0.253;192.168.0.1;192.168.0.0/24
diff --git a/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py b/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
index f331e28cd..121875d02 100644
--- a/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
+++ b/utils/test/result_collection_api/opnfv_testapi/dashboard/dashboard_utils.py
@@ -51,22 +51,6 @@ def check_dashboard_ready_case(project, case):
return eval(cmd)
-def get_dashboard_cases():
- # Retrieve all the test cases that could provide
- # Dashboard ready graphs
- # look in the releng repo
- # search all the project2Dashboard.py files
- # we assume that dashboard processing of project <Project>
- # is performed in the <Project>2Dashboard.py file
- modules = []
- cp = re.compile('dashboard.*2Dashboard')
- for module in sys.modules:
- if re.match(cp, module):
- modules.append(module)
-
- return modules
-
-
def get_dashboard_projects():
# Retrieve all the projects that could provide
# Dashboard ready graphs
diff --git a/utils/test/result_collection_api/opnfv_testapi/resources/result_handlers.py b/utils/test/result_collection_api/opnfv_testapi/resources/result_handlers.py
index 0a4c0db7b..fe2d71e5e 100644
--- a/utils/test/result_collection_api/opnfv_testapi/resources/result_handlers.py
+++ b/utils/test/result_collection_api/opnfv_testapi/resources/result_handlers.py
@@ -25,6 +25,13 @@ class GenericResultHandler(GenericApiHandler):
self.table = self.db_results
self.table_cls = TestResult
+ def get_int(self, key, value):
+ try:
+ value = int(value)
+ except:
+ raise HTTPError(HTTP_BAD_REQUEST, '{} must be int'.format(key))
+ return value
+
def set_query(self):
query = dict()
for k in self.request.query_arguments.keys():
@@ -32,10 +39,7 @@ class GenericResultHandler(GenericApiHandler):
if k == 'project' or k == 'pod' or k == 'case':
query[k + '_name'] = v
elif k == 'period':
- try:
- v = int(v)
- except:
- raise HTTPError(HTTP_BAD_REQUEST, 'period must be int')
+ v = self.get_int(k, v)
if v > 0:
period = datetime.now() - timedelta(days=v)
obj = {"$gte": str(period)}
@@ -119,12 +123,9 @@ class ResultsCLHandler(GenericResultHandler):
"""
last = self.get_query_argument('last', 0)
if last is not None:
- try:
- last = int(last)
- except:
- raise HTTPError(HTTP_BAD_REQUEST, 'last must be int')
+ last = self.get_int('last', last)
- self._list(self.set_query(), sort=[{'start_date', -1}], last=last)
+ self._list(self.set_query(), sort=[('start_date', -1)], last=last)
@swagger.operation(nickname="create")
def post(self):
diff --git a/utils/test/result_collection_api/opnfv_testapi/tests/unit/fake_pymongo.py b/utils/test/result_collection_api/opnfv_testapi/tests/unit/fake_pymongo.py
index 9b4d1208c..ef9c719be 100644
--- a/utils/test/result_collection_api/opnfv_testapi/tests/unit/fake_pymongo.py
+++ b/utils/test/result_collection_api/opnfv_testapi/tests/unit/fake_pymongo.py
@@ -8,6 +8,7 @@
##############################################################################
from bson.objectid import ObjectId
from concurrent.futures import ThreadPoolExecutor
+from operator import itemgetter
def thread_execute(method, *args, **kwargs):
@@ -20,6 +21,7 @@ class MemCursor(object):
def __init__(self, collection):
self.collection = collection
self.count = len(self.collection)
+ self.sorted = []
def _is_next_exist(self):
return self.count != 0
@@ -32,10 +34,22 @@ class MemCursor(object):
self.count -= 1
return self.collection.pop()
- def sort(self, key_or_list, direction=None):
+ def sort(self, key_or_list):
+ key = key_or_list[0][0]
+ if key_or_list[0][1] == -1:
+ reverse = True
+ else:
+ reverse = False
+
+ if key_or_list is not None:
+ self.collection = sorted(self.collection,
+ key=itemgetter(key), reverse=reverse)
return self
def limit(self, limit):
+ if limit != 0 and limit < len(self.collection):
+ self.collection = self.collection[0:limit]
+ self.count = limit
return self
diff --git a/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
index 5a5dd3852..dbc4431ce 100644
--- a/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
+++ b/utils/test/result_collection_api/opnfv_testapi/tests/unit/test_result.py
@@ -196,16 +196,30 @@ class TestResultGet(TestResultBase):
def test_queryCriteria(self):
self._query_and_assert(self._set_query('criteria'))
+ def test_queryPeriodNotInt(self):
+ code, body = self.query(self._set_query('period=a'))
+ self.assertEqual(code, HTTP_BAD_REQUEST)
+ self.assertIn('period must be int', body)
+
def test_queryPeriodFail(self):
self._query_and_assert(self._set_query('period=1'),
- aheadof=True,
- found=False)
+ found=False, days=-10)
def test_queryPeriodSuccess(self):
self._query_and_assert(self._set_query('period=1'),
- aheadof=False,
found=True)
+ def test_queryLastNotInt(self):
+ code, body = self.query(self._set_query('last=a'))
+ self.assertEqual(code, HTTP_BAD_REQUEST)
+ self.assertIn('last must be int', body)
+
+ def test_queryLast(self):
+ self._create_changed_date()
+ req = self._create_changed_date(minutes=20)
+ self._create_changed_date(minutes=-20)
+ self._query_and_assert(self._set_query('last=1'), req=req)
+
def test_combination(self):
self._query_and_assert(self._set_query('pod',
'project',
@@ -231,17 +245,9 @@ class TestResultGet(TestResultBase):
'period=1'),
found=False)
- def _query_and_assert(self, query, aheadof=False, found=True):
- import copy
- from datetime import datetime, timedelta
- req = copy.deepcopy(self.req_d)
- if aheadof:
- req.start_date = datetime.now() - timedelta(days=10)
- else:
- req.start_date = datetime.now()
- req.stop_date = str(req.start_date + timedelta(minutes=10))
- req.start_date = str(req.start_date)
- _, res = self.create(req)
+ def _query_and_assert(self, query, found=True, req=None, **kwargs):
+ if req is None:
+ req = self._create_changed_date(**kwargs)
code, body = self.query(query)
if not found:
self.assertEqual(code, HTTP_OK)
@@ -251,6 +257,16 @@ class TestResultGet(TestResultBase):
for result in body.results:
self.assert_res(code, result, req)
+ def _create_changed_date(self, **kwargs):
+ import copy
+ from datetime import datetime, timedelta
+ req = copy.deepcopy(self.req_d)
+ req.start_date = datetime.now() + timedelta(**kwargs)
+ req.stop_date = str(req.start_date + timedelta(minutes=10))
+ req.start_date = str(req.start_date)
+ self.create(req)
+ return req
+
def _set_query(self, *args):
uri = ''
for arg in args:
diff --git a/utils/test/result_collection_api/update/__init__.py b/utils/test/result_collection_api/update/__init__.py
new file mode 100644
index 000000000..363bc388e
--- /dev/null
+++ b/utils/test/result_collection_api/update/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/utils/test/result_collection_api/update/backup.py b/utils/test/result_collection_api/update/backup.py
new file mode 100644
index 000000000..faa4fd410
--- /dev/null
+++ b/utils/test/result_collection_api/update/backup.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import os
+import argparse
+import datetime
+
+from utils import execute, main, get_abspath
+
+parser = argparse.ArgumentParser(description='Backup MongoDBs')
+
+parser.add_argument('-u', '--url',
+ type=str,
+ required=False,
+ default='mongodb://127.0.0.1:27017/',
+ help='Mongo DB URL for Backups')
+parser.add_argument('-o', '--output_dir',
+ type=str,
+ required=False,
+ default='./',
+ help='Output directory for the backup.')
+
+parser.add_argument('-d', '--db',
+ type=str,
+ required=False,
+ default='test_results_collection',
+ help='database for the backup.')
+
+
+def backup(args):
+ db = args.db
+ out = get_abspath(args.output_dir)
+ now = datetime.datetime.now()
+ out = os.path.join(out, '%s__%s' % (db, now.strftime('%Y_%m_%d_%H%M%S')))
+ cmd = ['mongodump', '-o', '%s' % out]
+ execute(cmd, args)
+
+if __name__ == '__main__':
+ main(backup, parser)
diff --git a/utils/test/result_collection_api/update/restore.py b/utils/test/result_collection_api/update/restore.py
new file mode 100644
index 000000000..a2b65f321
--- /dev/null
+++ b/utils/test/result_collection_api/update/restore.py
@@ -0,0 +1,39 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import argparse
+
+from utils import execute, main, get_abspath
+
+parser = argparse.ArgumentParser(description='Restore MongoDBs')
+
+parser.add_argument('-u', '--url',
+ type=str,
+ required=False,
+ default='mongodb://127.0.0.1:27017/',
+ help='Mongo DB URL for Backup')
+parser.add_argument('-i', '--input_dir',
+ type=str,
+ required=False,
+ default='./',
+ help='Input directory for the Restore.')
+parser.add_argument('-d', '--db',
+ type=str,
+ required=False,
+ default=None,
+ help='database for the restore.')
+
+
+def restore(args):
+ input_dir = get_abspath(args.input_dir)
+ cmd = ['mongorestore', '%s' % input_dir]
+ execute(cmd, args)
+
+
+if __name__ == '__main__':
+ main(restore, parser)
diff --git a/utils/test/result_collection_api/update/utils.py b/utils/test/result_collection_api/update/utils.py
new file mode 100644
index 000000000..ef93f33cf
--- /dev/null
+++ b/utils/test/result_collection_api/update/utils.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import os
+import urlparse
+import subprocess
+
+
+def get_abspath(path):
+ assert os.path.isdir(path), 'Path %s can\'t be found.' % path
+ return os.path.abspath(path)
+
+
+def url_parse(url):
+ url = urlparse.urlparse(url)
+ assert url.scheme == 'mongodb', 'URL must be a MongoDB URL'
+
+ return url.username, url.password, url.hostname, url.port
+
+
+def execute(cmd, args):
+ (username, password, hostname, port) = url_parse(args.url)
+ cmd.extend(['--host', '%s' % hostname, '--port', '%s' % port])
+ db = args.db
+ if db is not None:
+ cmd.extend(['--db', '%s' % db])
+ if username is not None:
+ cmd.extend(['-u', '%s' % username, '-p', '%s' % password])
+ print('execute: %s' % cmd)
+ execute_output = subprocess.check_output(cmd)
+ print(execute_output)
+
+
+def main(method, parser):
+ args = parser.parse_args()
+ try:
+ method(args)
+ except AssertionError, msg:
+ print(msg)