cls = getattr(module, run_dict['class'])
test_case = cls()
result = test_case.run()
-
- if result != TestCasesBase.TestCasesBase.EX_SKIP and \
- GlobalVariables.REPORT_FLAG:
- test_case.push_to_db()
+ if (result == TestCasesBase.TestCasesBase.EX_OK and
+ GlobalVariables.REPORT_FLAG):
+ result = test_case.push_to_db()
except ImportError:
logger.exception("Cannot import module {}".format(
run_dict['module']))
dependencies:
installer: '(fuel)|(compass)'
scenario: 'multisite'
- -
- name: domino
- criteria: 'status == "PASS"'
- blocking: false
- description: >-
- Test suite for template distribution based on Domino
- dependencies:
- installer: 'joid'
- scenario: ''
- run:
- module: 'functest.opnfv_tests.features.domino'
- class: 'DominoTests'
-
name: odl-sfc
criteria: 'status == "PASS"'
EX_OK = os.EX_OK
EX_RUN_ERROR = os.EX_SOFTWARE
EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1
- EX_SKIP = os.EX_SOFTWARE - 2
logger = ft_logger.Logger(__name__).getLogger()
import time
from functest.core import TestCasesBase
+import functest.utils.functest_constants as ft_constants
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
-import functest.utils.functest_constants as ft_constants
-class DominoTests(TestCasesBase.TestCasesBase):
+class DominoCases(TestCasesBase.TestCasesBase):
+ DOMINO_REPO = \
+ ft_constants.DOMINO_REPO_DIR
+ RESULTS_DIR = \
+ ft_constants.FUNCTEST_RESULTS_DIR
logger = ft_logger.Logger("domino").getLogger()
def __init__(self):
- super(DominoTests, self).__init__()
+ super(DominoCases, self).__init__()
self.project_name = "domino"
self.case_name = "domino-multinode"
def main(self, **kwargs):
- cmd = ('cd %s && ./tests/run_multinode.sh' %
- ft_constants.DOMINO_REPO_DIR)
- log_file = os.path.join(
- ft_constants.FUNCTEST_RESULTS_DIR, "domino.log")
+ cmd = 'cd %s && ./tests/run_multinode.sh' % self.DOMINO_REPO
+ log_file = os.path.join(self.RESULTS_DIR, "domino.log")
start_time = time.time()
ret = ft_utils.execute_command(cmd,
output_file=log_file)
stop_time = time.time()
- duration = round(stop_time - start_time, 1)
- if ret == 0 and duration > 1:
+ if ret == 0:
self.logger.info("domino OK")
status = 'PASS'
- elif ret == 0 and duration <= 1:
- self.logger.info("domino TEST SKIPPED")
- status = 'SKIP'
else:
self.logger.info("domino FAILED")
status = "FAIL"
# report status only if tests run (FAIL OR PASS)
- if status is not "SKIP":
- self.criteria = status
- self.start_time = start_time
- self.stop_time = stop_time
- self.details = {}
+ self.criteria = status
+ self.start_time = start_time
+ self.stop_time = stop_time
+ self.details = {}
def run(self):
kwargs = {}
return self.main(**kwargs)
-
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
help="Create json result file",
action="store_true")
args = vars(parser.parse_args())
- domino = DominoTests()
+ domino = DominoCases()
try:
result = domino.main(**args)
if result != TestCasesBase.TestCasesBase.EX_OK:
output_file=log_file)
stop_time = time.time()
- duration = round(stop_time - start_time, 1)
- if ret == 0 and duration > 1:
+ if ret == 0:
self.logger.info("%s OK" % self.case_name)
status = 'PASS'
- elif ret == 0 and duration <= 1:
- self.logger.info("%s TEST SKIPPED" % self.case_name)
- status = 'SKIP'
else:
self.logger.info("%s FAILED" % self.case_name)
status = "FAIL"
# report status only if tests run (FAIL OR PASS)
- if status is not "SKIP":
- self.criteria = status
- self.start_time = start_time
- self.stop_time = stop_time
- self.details = {}
+ self.criteria = status
+ self.start_time = start_time
+ self.stop_time = stop_time
+ self.details = {}
def run(self):
kwargs = {}
from tackerclient.v1_0 import client as tackerclient
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
-import yaml
+import time
logger = ft_logger.Logger("tacker_utils").getLogger()
req_params = {'fields': 'id', 'name': resource_name}
endpoint = '/{0}s'.format(resource_type)
resp = tacker_client.get(endpoint, params=req_params)
+ endpoint = endpoint.replace('-', '_')
return resp[endpoint[1:]][0]['id']
except Exception, e:
logger.error("Error [get_id_from_name(tacker_client, "
def get_sfc_classifier_id(tacker_client, sfc_clf_name):
- return get_id_from_name(tacker_client, 'sfc_classifier', sfc_clf_name)
+ return get_id_from_name(tacker_client, 'sfc-classifier', sfc_clf_name)
def list_vnfds(tacker_client, verbose=False):
vnfd_body = {}
if tosca_file is not None:
with open(tosca_file) as tosca_fd:
- vnfd_body = yaml.safe_load(tosca_fd)
- return tacker_client.create_vnfd(body=vnfd_body)
+ vnfd_body = tosca_fd.read()
+ logger.error(vnfd_body)
+ return tacker_client.create_vnfd(
+ body={"vnfd": {"attributes": {"vnfd": vnfd_body}}})
except Exception, e:
- logger.error("Error [create_vnfd(tacker_client, '%s')]: %s"
- % (tosca_file, e))
+ logger.exception("Error [create_vnfd(tacker_client, '%s')]: %s"
+ % (tosca_file, e))
return None
return None
+def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None):
+ try:
+ _id = None
+ if vnf_id is not None:
+ _id = vnf_id
+ elif vnf_name is not None:
+ while _id is None:
+ try:
+ _id = get_vnf_id(tacker_client, vnf_name)
+ except:
+ logger.error("Bazinga")
+ else:
+ raise Exception('You must specify vnf_id or vnf_name')
+ while True:
+ vnf = [v for v in list_vnfs(tacker_client, verbose=True)['vnfs']
+ if v['id'] == _id]
+ vnf = vnf[0]
+ logger.info('Waiting for vnf {0}'.format(str(vnf)))
+ if vnf['status'] == 'ERROR':
+ raise Exception('Error when booting vnf %s' % _id)
+ elif vnf['status'] == 'PENDING_CREATE':
+ time.sleep(3)
+ continue
+ else:
+ break
+ return _id
+ except Exception, e:
+ logger.error("error [wait_for_vnf(tacker_client, '%s', '%s')]: %s"
+ % (vnf_id, vnf_name, e))
+ return None
+
+
def delete_vnf(tacker_client, vnf_id=None, vnf_name=None):
try:
vnf = vnf_id
else:
if sfc_name is None:
raise Exception('You need to provide an SFC id or name')
- sfc_clf_body['sfc']['chain'] = get_sfc_id(tacker_client, sfc_name)
+ sfc_clf_body['sfc_classifier']['chain'] = get_sfc_id(
+ tacker_client, sfc_name)
return tacker_client.create_sfc_classifier(body=sfc_clf_body)
except Exception, e:
- logger.error("error [create_sfc_classifier(tacker_client, '%s', '%s', "
- "'%s')]: %s" % (sfc_clf_name, sfc_id, sfc_name, match, e))
+ logger.error("error [create_sfc_classifier(tacker_client, '%s', '%s',"
+ " '%s', '%s')]: '%s'"
+ % (sfc_clf_name, sfc_id, sfc_name, str(match), e))
return None