summaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-03-18 13:10:23 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-03-18 13:10:23 +0000
commit26fa022ae631922f22978f79b2912fd56f133ab2 (patch)
treefa428f2560ed5f9ccb266f8411a2dbb4295fb0e0 /testcases
parentfd95510eb2caa63ec1613b271fb620f9c66e2278 (diff)
parent7c9aef8db83e025034e3427c1330a00420fae50a (diff)
Merge "Add criteria and version when pushing the results into test DB"
Diffstat (limited to 'testcases')
-rw-r--r--testcases/Controllers/ODL/CI/odlreport2db.py19
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py80
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally-cert.py37
-rw-r--r--testcases/features/doctor.py17
-rw-r--r--testcases/features/promise.py63
-rw-r--r--testcases/functest_utils.py52
-rw-r--r--testcases/vIMS/CI/vIMS.py54
-rw-r--r--testcases/vPing/CI/libraries/vPing_ssh.py59
-rw-r--r--testcases/vPing/CI/libraries/vPing_userdata.py42
9 files changed, 258 insertions, 165 deletions
diff --git a/testcases/Controllers/ODL/CI/odlreport2db.py b/testcases/Controllers/ODL/CI/odlreport2db.py
index 50731ffe1..3a696eb2d 100644
--- a/testcases/Controllers/ODL/CI/odlreport2db.py
+++ b/testcases/Controllers/ODL/CI/odlreport2db.py
@@ -130,12 +130,31 @@ def main(argv):
# -i fuel
# -p opnfv-jump-2
# -s os-odl_l2-ha
+ version = scenario
+
+ # success criteria for ODL = 100% of tests OK
+ status = "failed"
+ try:
+ tests_passed = 0
+ tests_failed = 0
+ for v in data['details']:
+ if v['test_status']['@status'] == "PASS":
+ tests_passed += 1
+ else:
+ tests_failed += 1
+
+ if (tests_failed < 1):
+ status = "passed"
+ except:
+ print("Unable to set criteria" % sys.exc_info()[0])
functest_utils.push_results_to_db(database,
"functest",
data['case_name'],
None,
data['pod_name'],
+ version,
scenario,
+ status,
build_tag,
data)
except:
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index 563fa5082..a47198b96 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -55,11 +55,12 @@ if not os.path.exists(REPO_PATH):
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
-ONOSCI_PATH= REPO_PATH+'testcases/Controllers/ONOS/Teston/CI/'
+ONOSCI_PATH = REPO_PATH + 'testcases/Controllers/ONOS/Teston/CI/'
starttime = datetime.datetime.now()
HOME = os.environ['HOME'] + "/"
+
def RunScript(testname):
"""
Run ONOS Test Script
@@ -67,9 +68,10 @@ def RunScript(testname):
testname: ONOS Testcase Name
"""
runtest = ONOSCI_PATH + "OnosSystemTest/TestON/bin/cli.py run " + testname
- logger.debug( "Run script " + testname )
+ logger.debug("Run script " + testname)
os.system(runtest)
+
def DownloadCodes(url="https://github.com/sunyulin/OnosSystemTest.git"):
"""
Download Onos Teston codes
@@ -77,9 +79,10 @@ def DownloadCodes(url="https://github.com/sunyulin/OnosSystemTest.git"):
url: github url
"""
downloadcode = "git clone " + url + " " + ONOSCI_PATH + "OnosSystemTest"
- logger.debug( "Download Onos Teston codes " + url)
+ logger.debug("Download Onos Teston codes " + url)
os.system(downloadcode)
+
def GetResult():
LOGPATH = ONOSCI_PATH + "OnosSystemTest/TestON/logs"
cmd = "grep -rnh " + "Fail" + " " + LOGPATH
@@ -93,7 +96,7 @@ def GetResult():
else:
logger.debug("Testcases Success")
Result = "Success"
- #payload={'timestart': str(starttime),
+ # payload={'timestart': str(starttime),
# 'duration': str(duration),
# 'status': Result}
cmd = "grep -rnh 'Execution Time' " + LOGPATH
@@ -103,72 +106,78 @@ def GetResult():
cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNB_*"
Resultbuffer = os.popen(cmd).read()
if Resultbuffer.find('100%') >= 0:
- result1='Success'
+ result1 = 'Success'
else:
- result1='Failed'
+ result1 = 'Failed'
cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNBL3*"
Resultbuffer = os.popen(cmd).read()
if Resultbuffer.find('100%') >= 0:
- result2='Success'
+ result2 = 'Success'
else:
- result2='Failed'
+ result2 = 'Failed'
status1 = []
status2 = []
cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNB_*"
Resultbuffer = os.popen(cmd).read()
pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- #res = pattern.search(Resultbuffer).groups()
+ # res = pattern.search(Resultbuffer).groups()
res = pattern.findall(Resultbuffer)
i = 0
for index in range(len(res)):
- status1.append({'Case name:':res[i][0] + res[i][1],'Case result':res[i][2]})
- i=i+1
+ status1.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNBL3*"
Resultbuffer = os.popen(cmd).read()
pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- #res = pattern.search(Resultbuffer).groups()
+ # res = pattern.search(Resultbuffer).groups()
res = pattern.findall(Resultbuffer)
i = 0
for index in range(len(res)):
- status2.append({'Case name:':res[i][0] + res[i][1],'Case result':res[i][2]})
- i=i+1
- payload={'timestart': str(starttime),
- 'FUNCvirNet':{'duration': time1,
- 'result': result1,
- 'status': status1},
- 'FUNCvirNetL3':{'duration': time2,
- 'result': result2,
- 'status': status2}}
+ status2.append({'Case name:': res[i][0] + res[i][1],
+ 'Case result': res[i][2]})
+ i = i + 1
+ payload = {'timestart': str(starttime),
+ 'FUNCvirNet': {'duration': time1,
+ 'result': result1,
+ 'status': status1},
+ 'FUNCvirNetL3': {'duration': time2,
+ 'result': result2,
+ 'status': status2}}
return payload
+
def SetOnosIp():
cmd = "openstack catalog show network | grep publicURL"
cmd_output = os.popen(cmd).read()
- OC1=re.search(r"\d+\.\d+\.\d+\.\d+",cmd_output).group()
+ OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
os.environ['OC1'] = OC1
time.sleep(2)
- logger.debug( "ONOS IP is " + OC1)
+ logger.debug("ONOS IP is " + OC1)
+
def SetOnosIpForJoid():
cmd = "env | grep SDN_CONTROLLER"
cmd_output = os.popen(cmd).read()
- OC1=re.search(r"\d+\.\d+\.\d+\.\d+",cmd_output).group()
+ OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
os.environ['OC1'] = OC1
time.sleep(2)
- logger.debug( "ONOS IP is " + OC1)
+ logger.debug("ONOS IP is " + OC1)
+
def CleanOnosTest():
TESTONPATH = ONOSCI_PATH + "OnosSystemTest/"
cmd = "rm -rf " + TESTONPATH
os.system(cmd)
time.sleep(2)
- logger.debug( "Clean ONOS Teston" )
+ logger.debug("Clean ONOS Teston")
+
def main():
DownloadCodes()
if args.installer == "joid":
- logger.debug( "Installer is Joid")
+ logger.debug("Installer is Joid")
SetOnosIpForJoid()
else:
SetOnosIp()
@@ -179,14 +188,25 @@ def main():
logger.debug("Push result into DB")
# TODO check path result for the file
scenario = functest_utils.get_scenario(logger)
+ version = scenario
+ result = GetResult()
+
+ # ONOS success criteria = all tests OK
+ # i.e. FUNCvirNet & FUNCvirNetL3
+ status = "failed"
+ try:
+ if result['FUNCvirNet']['result'] == "Success" and result['FUNCvirNetL3']['result'] == "Success":
+ status = "passed"
+ except:
+ logger.error("Unable to set ONOS criteria")
+
pod_name = functest_utils.get_pod_name(logger)
build_tag = functest_utils.get_build_tag(logger)
- result = GetResult()
functest_utils.push_results_to_db(TEST_DB,
"functest",
"ONOS",
- logger, pod_name, scenario,
- build_tag, payload=result)
+ logger, pod_name, version, scenario,
+ status, build_tag, payload=result)
except:
logger.error("Error pushing results into Database")
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
index 2137e9493..7e1f89abf 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
@@ -133,16 +133,21 @@ CINDER_VOLUME_TYPE_NAME = "volume_test"
SUMMARY = []
-def push_results_to_db(case, payload):
+def push_results_to_db(case, payload, criteria):
url = TEST_DB + "/results"
installer = functest_utils.get_installer_type(logger)
scenario = functest_utils.get_scenario(logger)
+ # Until we found a way to manage version, use scenario
+ version = scenario
pod_name = functest_utils.get_pod_name(logger)
- # TODO pod_name hardcoded, info shall come from Jenkins
+
+ # evalutate success criteria
+
params = {"project_name": "functest", "case_name": case,
"pod_name": pod_name, "installer": installer,
- "version": scenario, "details": payload}
+ "version": version, "scenario": scenario,
+ "criteria": criteria, "details": payload}
headers = {'Content-Type': 'application/json'}
r = requests.post(url, data=json.dumps(params), headers=headers)
@@ -187,7 +192,7 @@ def live_migration_supported():
if config.read(TEMPEST_CONF_FILE) and \
config.has_section('compute-feature-enabled') and \
config.has_option('compute-feature-enabled', 'live_migration'):
- return config.getboolean('compute-feature-enabled', 'live_migration')
+ return config.getboolean('compute-feature-enabled', 'live_migration')
return False
@@ -347,17 +352,19 @@ def run_task(test_name):
.format(RESULTS_DIR, test_name)) as json_file:
json_data = json.load(json_file)
- # Push results in payload of testcase
- if args.report:
- logger.debug("Push result into DB")
- push_results_to_db("Rally_details", json_data)
-
""" parse JSON operation result """
+ status = "failed"
if task_succeed(json_results):
logger.info('Test scenario: "{}" OK.'.format(test_name) + "\n")
+ status = "passed"
else:
logger.info('Test scenario: "{}" Failed.'.format(test_name) + "\n")
+ # Push results in payload of testcase
+ if args.report:
+ logger.debug("Push result into DB")
+ push_results_to_db("Rally_details", json_data, status)
+
def main():
global SUMMARY
@@ -477,21 +484,27 @@ def main():
# "tests": int(total_nb_tests), "success": int(total_success)}
#logger.info("Results: "+str(json_results))
+ # Evaluation of the success criteria
+ status = "failed"
+ # for Rally we decided that the overall success rate must be above 90%
+ if total_success >= 90:
+ status = "passed"
+
if args.report:
logger.debug("Pushing Rally summary into DB...")
- push_results_to_db("Rally", payload)
+ push_results_to_db("Rally", payload, status)
if args.noclean:
exit(0)
logger.debug("Deleting image '%s' with ID '%s'..." \
- % (GLANCE_IMAGE_NAME, image_id))
+ % (GLANCE_IMAGE_NAME, image_id))
if not functest_utils.delete_glance_image(nova_client, image_id):
logger.error("Error deleting the glance image")
if not volume_types:
logger.debug("Deleting volume type '%s'..." \
- % CINDER_VOLUME_TYPE_NAME)
+ % CINDER_VOLUME_TYPE_NAME)
if not functest_utils.delete_volume_type(cinder_client, volume_type):
logger.error("Error in deleting volume type...")
diff --git a/testcases/features/doctor.py b/testcases/features/doctor.py
index 52ffaa900..a225d5a50 100644
--- a/testcases/features/doctor.py
+++ b/testcases/features/doctor.py
@@ -15,7 +15,6 @@
#
import logging
-import os
import sys
import time
import yaml
@@ -63,19 +62,27 @@ def main():
}
pod_name = functest_utils.get_pod_name(logger)
scenario = functest_utils.get_scenario(logger)
+ version = scenario
build_tag = functest_utils.get_build_tag(logger)
+
+ status = "failed"
+ if details['status'] == "OK":
+ status = "passed"
+
logger.info("Pushing result: TEST_DB_URL=%(db)s pod_name=%(pod)s "
- "scenario=%(s)s details=%(d)s" % {
+ "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
'db': TEST_DB_URL,
'pod': pod_name,
+ 'v': version,
's': scenario,
+ 'c': status,
'b': build_tag,
'd': details,
})
functest_utils.push_results_to_db(TEST_DB_URL,
- 'doctor','doctor-notification',
- logger, pod_name, scenario,
- build_tag, details)
+ 'doctor', 'doctor-notification',
+ logger, pod_name, version, scenario,
+ status, build_tag, details)
if __name__ == '__main__':
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index ec38ec21b..de0418211 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -16,7 +16,6 @@ import os
import requests
import subprocess
import sys
-import time
import yaml
import keystoneclient.v2_0.client as ksclient
@@ -80,7 +79,6 @@ ch.setFormatter(formatter)
logger.addHandler(ch)
-
def create_image(glance_client, name):
return image_id
@@ -117,10 +115,10 @@ def main():
logger.error("Error : Failed to get id for %s role" % role_name)
exit(-1)
- logger.info("Adding role '%s' to tenant '%s'..." % (role_id,TENANT_NAME))
+ logger.info("Adding role '%s' to tenant '%s'..." % (role_id, TENANT_NAME))
if not functest_utils.add_role_user(keystone, user_id, role_id, tenant_id):
logger.error("Error : Failed to add %s on tenant %s" %
- (ks_creds['username'],TENANT_NAME))
+ (ks_creds['username'], TENANT_NAME))
exit(-1)
logger.debug("Role added successfully.")
@@ -153,9 +151,8 @@ def main():
glance = glclient.Client(1, glance_endpoint, token=keystone.auth_token)
nova = nvclient.Client("2", **nv_creds)
-
logger.info("Creating image '%s' from '%s'..." % (IMAGE_NAME,
- GLANCE_IMAGE_PATH))
+ GLANCE_IMAGE_PATH))
image_id = functest_utils.create_glance_image(glance,
IMAGE_NAME,
GLANCE_IMAGE_PATH)
@@ -176,15 +173,14 @@ def main():
logger.error("Failed to create the Flavor...")
exit(-1)
logger.debug("Flavor '%s' with ID '%s' created successfully." %
- (FLAVOR_NAME, flavor_id))
+ (FLAVOR_NAME, flavor_id))
else:
logger.debug("Using existing flavor '%s' with ID '%s'..." % (FLAVOR_NAME,
- flavor_id))
-
+ flavor_id))
neutron = ntclient.Client(**nt_creds)
- private_net=functest_utils.get_private_net(neutron)
- if private_net == None:
+ private_net = functest_utils.get_private_net(neutron)
+ if private_net is None:
logger.error("There is no private network in the deployment. Aborting...")
exit(-1)
logger.debug("Using private network '%s' (%s)." % (private_net['name'],
@@ -199,15 +195,14 @@ def main():
os.environ["OS_TEST_FLAVOR"] = flavor_id
os.environ["OS_TEST_NETWORK"] = private_net['id']
-
os.chdir(PROMISE_REPO)
- results_file_name='promise-results.json'
- results_file=open(results_file_name,'w+')
+ results_file_name = 'promise-results.json'
+ results_file = open(results_file_name, 'w+')
cmd = 'npm run -s test -- --reporter json'
logger.info("Running command: %s" % cmd)
ret = subprocess.call(cmd, shell=True, stdout=results_file, \
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT)
results_file.close()
if ret == 0:
@@ -218,7 +213,7 @@ def main():
test_status = "Failed"
# Print output of file
- with open(results_file_name,'r') as results_file:
+ with open(results_file_name, 'r') as results_file:
data = results_file.read()
logger.debug("\n%s" % data)
json_data = json.loads(data)
@@ -233,20 +228,19 @@ def main():
duration = float(json_data["stats"]["duration"])/float(1000)
logger.info("\n" \
- "****************************************\n"\
- " Promise test report\n\n"\
- "****************************************\n"\
- " Suites: \t%s\n"\
- " Tests: \t%s\n"\
- " Passes: \t%s\n"\
- " Pending: \t%s\n"\
- " Failures:\t%s\n"\
- " Start: \t%s\n"\
- " End: \t%s\n"\
- " Duration:\t%s\n"\
- "****************************************\n\n"\
- % (suites, tests, passes, pending, failures, start_time, end_time, duration))
-
+ "****************************************\n"\
+ " Promise test report\n\n"\
+ "****************************************\n"\
+ " Suites: \t%s\n"\
+ " Tests: \t%s\n"\
+ " Passes: \t%s\n"\
+ " Pending: \t%s\n"\
+ " Failures:\t%s\n"\
+ " Start: \t%s\n"\
+ " End: \t%s\n"\
+ " Duration:\t%s\n"\
+ "****************************************\n\n"\
+ % (suites, tests, passes, pending, failures, start_time, end_time, duration))
if args.report:
pod_name = functest_utils.get_pod_name(logger)
@@ -260,9 +254,16 @@ def main():
"tests": int(tests), "failures": int(failures)}
logger.debug("Results json: "+str(json_results))
+ # criteria for Promise in Release B was 100% of tests OK
+ status = "failed"
+ if int(tests) > 32 and int(failures) < 1:
+ status = "passed"
+
params = {"project_name": "promise", "case_name": "promise",
"pod_name": str(pod_name), 'installer': installer,
- "version": scenario, "build_tag": build_tag, 'details': json_results}
+ "version": scenario, "scenario": scenario,
+ "criteria": status, "build_tag": build_tag,
+ 'details': json_results}
headers = {'Content-Type': 'application/json'}
logger.info("Pushing results to DB...")
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index ee6e0ed32..9a5d718bb 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -28,9 +28,9 @@ from git import Repo
# -----------------------------------------------------------
-#*********************************************
+# *********************************************
# CREDENTIALS
-#*********************************************
+# *********************************************
def check_credentials():
"""
Check if the OpenStack credentials (openrc) are sourced
@@ -68,17 +68,17 @@ def get_credentials(service):
tenant: os.environ.get("OS_TENANT_NAME", "admin"),
})
ssl = os.environ.get("OS_CACERT")
- if ssl != None:
- creds.update({"ca_cert":ssl})
+ if ssl is not None:
+ creds.update({"ca_cert": ssl})
if not os.path.isfile(ssl):
print "WARNING: The 'OS_CACERT' environment variable is set to %s "\
"but the file does not exist." % ssl
return creds
-#*********************************************
+# *********************************************
# NOVA
-#*********************************************
+# *********************************************
def get_instances(nova_client):
try:
instances = nova_client.servers.list(search_opts={'all_tenants': 1})
@@ -92,7 +92,7 @@ def get_instance_status(nova_client, instance):
try:
instance = nova_client.servers.get(instance.id)
return instance.status
- except Exception, e:
+ except:
# print "Error [get_instance_status(nova_client, '%s')]:" % \
# str(instance), e
return None
@@ -188,9 +188,9 @@ def delete_floating_ip(nova_client, floatingip_id):
return False
-#*********************************************
+# *********************************************
# NEUTRON
-#*********************************************
+# *********************************************
def get_network_list(neutron_client):
network_list = neutron_client.list_networks()['networks']
if len(network_list) == 0:
@@ -434,9 +434,9 @@ def remove_gateway_router(neutron_client, router_id):
return False
-#*********************************************
+# *********************************************
# SEC GROUPS
-#*********************************************
+# *********************************************
def get_security_groups(neutron_client):
try:
security_groups = neutron_client.list_security_groups()[
@@ -533,9 +533,9 @@ def delete_security_group(neutron_client, secgroup_id):
return False
-#*********************************************
+# *********************************************
# GLANCE
-#*********************************************
+# *********************************************
def get_images(nova_client):
try:
images = nova_client.images.list()
@@ -582,9 +582,9 @@ def delete_glance_image(nova_client, image_id):
return False
-#*********************************************
+# *********************************************
# CINDER
-#*********************************************
+# *********************************************
def get_volumes(cinder_client):
try:
volumes = cinder_client.volumes.list(search_opts={'all_tenants': 1})
@@ -659,9 +659,9 @@ def delete_volume_type(cinder_client, volume_type):
return False
-#*********************************************
+# *********************************************
# KEYSTONE
-#*********************************************
+# *********************************************
def get_tenants(keystone_client):
try:
tenants = keystone_client.tenants.list()
@@ -837,6 +837,15 @@ def get_scenario(logger=None):
return scenario
+def get_version(logger=None):
+ """
+ Get version
+ """
+ # TODO
+
+ return ""
+
+
def get_pod_name(logger=None):
"""
Get PoD Name from env variable NODE_NAME
@@ -865,7 +874,7 @@ def get_build_tag(logger=None):
def push_results_to_db(db_url, project, case_name, logger, pod_name,
- version, build_tag, payload):
+ version, scenario, criteria, build_tag, payload):
"""
POST results to the Result target DB
"""
@@ -873,7 +882,8 @@ def push_results_to_db(db_url, project, case_name, logger, pod_name,
installer = get_installer_type(logger)
params = {"project_name": project, "case_name": case_name,
"pod_name": pod_name, "installer": installer,
- "version": version, "build_tag": build_tag, "details": payload}
+ "version": version, "scenario": scenario, "criteria": criteria,
+ "build_tag": build_tag, "details": payload}
headers = {'Content-Type': 'application/json'}
try:
@@ -882,8 +892,8 @@ def push_results_to_db(db_url, project, case_name, logger, pod_name,
logger.debug(r)
return True
except Exception, e:
- print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s', '%s', '%s')]:" \
- % (db_url, project, case_name, pod_name, version, build_tag, payload), e
+ print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')]:" \
+ % (db_url, project, case_name, pod_name, version, scenario, criteria, build_tag, payload), e
return False
diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py
index 10246e5f9..9aff4d8d6 100644
--- a/testcases/vIMS/CI/vIMS.py
+++ b/testcases/vIMS/CI/vIMS.py
@@ -19,11 +19,9 @@ import argparse
import yaml
import pprint
import sys
-import shutil
import json
import datetime
import requests
-from git import Repo
import keystoneclient.v2_0.client as ksclient
import glanceclient.client as glclient
import novaclient.client as nvclient
@@ -32,7 +30,6 @@ from neutronclient.v2_0 import client as ntclient
from orchestrator import *
from clearwater import *
-import urllib
pp = pprint.PrettyPrinter(indent=4)
@@ -131,11 +128,12 @@ def step_failure(step_name, error_msg):
exit(-1)
-def push_results():
+def push_results(status):
if args.report:
logger.debug("Pushing results to DB....")
scenario = functest_utils.get_scenario(logger)
+ version = scenario
pod_name = functest_utils.get_pod_name(logger)
build_tag = functest_utils.get_build_tag(logger)
@@ -143,7 +141,9 @@ def push_results():
project="functest",
case_name="vIMS",
logger=logger, pod_name=pod_name,
- version=scenario,
+ version=version,
+ scenario=scenario,
+ criteria=status,
build_tag=build_tag,
payload=RESULTS)
@@ -175,13 +175,13 @@ def test_clearwater():
url = ellis_url + "accounts"
params = {"password": "functest",
- "full_name": "opnfv functest user",
- "email": "functest@opnfv.fr",
- "signup_code": "secret"
- }
+ "full_name": "opnfv functest user",
+ "email": "functest@opnfv.fr",
+ "signup_code": "secret"}
+
rq = requests.post(url, data=params)
i = 20
- while rq.status_code != 201 and i>0 :
+ while rq.status_code != 201 and i > 0:
rq = requests.post(url, data=params)
i = i-1
time.sleep(10)
@@ -195,7 +195,7 @@ def test_clearwater():
if cookies != "":
rq = requests.post(url, cookies=cookies)
i = 24
- while rq.status_code != 200 and i>0:
+ while rq.status_code != 200 and i > 0:
rq = requests.post(url, cookies=cookies)
i = i-1
time.sleep(25)
@@ -244,7 +244,19 @@ def test_clearwater():
logger.error("Unable to retrieve test results")
set_result("sig_test", duration, vims_test_result)
- push_results()
+
+ # success criteria for vIMS (for Brahmaputra)
+ # - orchestrator deployed
+ # - VNF deployed
+ status = "failed"
+ try:
+ # TODO precise condition, for the moment if duration > 3m,
+ # => I consider it is good..
+ if RESULTS['orchestrator']['duration'] > 180 and RESULT['vIMS']['duration'] > 180:
+ status = "passed"
+ except:
+ logger.error("Unable to set test status")
+ push_results(status)
try:
os.remove(VIMS_TEST_DIR + "temp.json")
@@ -254,7 +266,7 @@ def test_clearwater():
def main():
- ################ GENERAL INITIALISATION ################
+ # ############### GENERAL INITIALISATION ################
if not os.path.exists(VIMS_DATA_DIR):
os.makedirs(VIMS_DATA_DIR)
@@ -352,7 +364,7 @@ def main():
step_failure(
"init", "Failed to update cinder quota for tenant " + TENANT_NAME)
- ################ CLOUDIFY INITIALISATION ################
+ # ############### CLOUDIFY INITIALISATION ################
cfy = orchestrator(VIMS_DATA_DIR, CFY_INPUTS, logger)
@@ -413,7 +425,7 @@ def main():
cfy.download_manager_blueprint(
CFY_MANAGER_BLUEPRINT['url'], CFY_MANAGER_BLUEPRINT['branch'])
- ################ CLOUDIFY DEPLOYMENT ################
+ # ############### CLOUDIFY DEPLOYMENT ################
start_time_ts = time.time()
end_time_ts = start_time_ts
logger.info("Cloudify deployment Start Time:'%s'" % (
@@ -429,7 +441,7 @@ def main():
logger.info("Cloudify deployment duration:'%s'" % duration)
set_result("orchestrator", duration, "")
- ################ CLEARWATER INITIALISATION ################
+ # ############### CLEARWATER INITIALISATION ################
cw = clearwater(CW_INPUTS, cfy, logger)
@@ -473,7 +485,7 @@ def main():
cw.set_external_network_name(ext_net)
- ################ CLEARWATER DEPLOYMENT ################
+ # ############### CLEARWATER DEPLOYMENT ################
start_time_ts = time.time()
end_time_ts = start_time_ts
@@ -490,19 +502,19 @@ def main():
logger.info("vIMS VNF deployment duration:'%s'" % duration)
set_result("vIMS", duration, "")
- ################ CLEARWATER TEST ################
+ # ############### CLEARWATER TEST ################
test_clearwater()
- ########### CLEARWATER UNDEPLOYMENT ############
+ # ########## CLEARWATER UNDEPLOYMENT ############
cw.undeploy_vnf()
- ############ CLOUDIFY UNDEPLOYMENT #############
+ # ########### CLOUDIFY UNDEPLOYMENT #############
cfy.undeploy_manager()
- ############### GENERAL CLEANUP ################
+ # ############## GENERAL CLEANUP ################
if args.noclean:
exit(0)
diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py
index 508ac0ff5..530286c9c 100644
--- a/testcases/vPing/CI/libraries/vPing_ssh.py
+++ b/testcases/vPing/CI/libraries/vPing_ssh.py
@@ -20,7 +20,6 @@ import os
import paramiko
import pprint
import re
-import subprocess
import sys
import time
import yaml
@@ -160,11 +159,11 @@ def waitVmDeleted(nova, vm):
def create_private_neutron_net(neutron):
# Check if the network already exists
- network_id = functest_utils.get_network_id(neutron,NEUTRON_PRIVATE_NET_NAME)
- subnet_id = functest_utils.get_subnet_id(neutron,NEUTRON_PRIVATE_SUBNET_NAME)
- router_id = functest_utils.get_router_id(neutron,NEUTRON_ROUTER_NAME)
+ network_id = functest_utils.get_network_id(neutron, NEUTRON_PRIVATE_NET_NAME)
+ subnet_id = functest_utils.get_subnet_id(neutron, NEUTRON_PRIVATE_SUBNET_NAME)
+ router_id = functest_utils.get_router_id(neutron, NEUTRON_ROUTER_NAME)
- if network_id != '' and subnet_id != '' and router_id != '' :
+ if network_id != '' and subnet_id != '' and router_id != '':
logger.info("Using existing network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
else:
neutron.format = 'json'
@@ -208,6 +207,7 @@ def create_private_neutron_net(neutron):
'router_id': router_id}
return network_dic
+
def create_security_group(neutron_client):
sg_id = functest_utils.get_security_group_id(neutron_client, SECGROUP_NAME)
if sg_id != '':
@@ -215,8 +215,8 @@ def create_security_group(neutron_client):
else:
logger.info("Creating security group '%s'..." % SECGROUP_NAME)
SECGROUP = functest_utils.create_security_group(neutron_client,
- SECGROUP_NAME,
- SECGROUP_DESCR)
+ SECGROUP_NAME,
+ SECGROUP_DESCR)
if not SECGROUP:
logger.error("Failed to create the security group...")
return False
@@ -224,26 +224,27 @@ def create_security_group(neutron_client):
sg_id = SECGROUP['id']
logger.debug("Security group '%s' with ID=%s created successfully." %\
- (SECGROUP['name'], sg_id))
+ (SECGROUP['name'], sg_id))
logger.debug("Adding ICMP rules in security group '%s'..." % SECGROUP_NAME)
if not functest_utils.create_secgroup_rule(neutron_client, sg_id, \
- 'ingress', 'icmp'):
+ 'ingress', 'icmp'):
logger.error("Failed to create the security group rule...")
return False
logger.debug("Adding SSH rules in security group '%s'..." % SECGROUP_NAME)
if not functest_utils.create_secgroup_rule(neutron_client, sg_id, \
- 'ingress', 'tcp', '22', '22'):
+ 'ingress', 'tcp', '22', '22'):
logger.error("Failed to create the security group rule...")
return False
if not functest_utils.create_secgroup_rule(neutron_client, sg_id, \
- 'egress', 'tcp', '22', '22'):
+ 'egress', 'tcp', '22', '22'):
logger.error("Failed to create the security group rule...")
return False
return sg_id
+
def cleanup(nova, neutron, image_id, network_dic, sg_id, floatingip):
if args.noclean:
logger.debug("The OpenStack resources are not deleted.")
@@ -333,12 +334,17 @@ def push_results(start_time_ts, duration, test_status):
try:
logger.debug("Pushing result into DB...")
scenario = functest_utils.get_scenario(logger)
+ version = scenario
+ criteria = "failed"
+ if test_status == "OK":
+ criteria = "passed"
pod_name = functest_utils.get_pod_name(logger)
build_tag = functest_utils.get_build_tag(logger)
functest_utils.push_results_to_db(TEST_DB,
"functest",
"vPing",
- logger, pod_name, scenario, build_tag,
+ logger, pod_name, version, scenario,
+ criteria, build_tag,
payload={'timestart': start_time_ts,
'duration': duration,
'status': test_status})
@@ -369,7 +375,7 @@ def main():
logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME)
else:
logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH))
+ GLANCE_IMAGE_PATH))
image_id = functest_utils.create_glance_image(glance_client,
GLANCE_IMAGE_NAME,
GLANCE_IMAGE_PATH)
@@ -377,8 +383,7 @@ def main():
logger.error("Failed to create a Glance image...")
return(EXIT_CODE)
logger.debug("Image '%s' with ID=%s created successfully." %\
- (GLANCE_IMAGE_NAME, image_id))
-
+ (GLANCE_IMAGE_NAME, image_id))
network_dic = create_private_neutron_net(neutron_client)
if not network_dic:
@@ -407,7 +412,6 @@ def main():
logger.info("Instance %s found. Deleting..." % server.name)
server.delete()
-
# boot VM 1
start_time_ts = time.time()
end_time_ts = start_time_ts
@@ -470,7 +474,7 @@ def main():
floatip = floatip_dic['fip_addr']
floatip_id = floatip_dic['fip_id']
- if floatip == None:
+ if floatip is None:
logger.error("Cannot create floating IP.")
cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, floatip_dic)
return (EXIT_CODE)
@@ -483,8 +487,8 @@ def main():
return (EXIT_CODE)
logger.info("Trying to establish SSH connection to %s..." % floatip)
- username='cirros'
- password='cubswin:)'
+ username = 'cirros'
+ password = 'cubswin:)'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@@ -498,7 +502,7 @@ def main():
ssh.connect(floatip, username=username, password=password, timeout=2)
logger.debug("SSH connection established to %s." % floatip)
break
- except Exception, e:
+ except:
logger.debug("Waiting for %s..." % floatip)
time.sleep(6)
timeout -= 1
@@ -506,7 +510,7 @@ def main():
console_log = vm2.get_console_output()
# print each "Sending discover" captured on the console log
- if len(re.findall("Sending discover",console_log)) > discover_count and not got_ip:
+ if len(re.findall("Sending discover", console_log)) > discover_count and not got_ip:
discover_count += 1
logger.debug("Console-log '%s': Sending discover..." % NAME_VM_2)
@@ -523,8 +527,7 @@ def main():
logger.info("The instance failed to get an IP from "\
"the DHCP agent. The test will probably timeout...")
-
- if timeout == 0: # 300 sec timeout (5 min)
+ if timeout == 0: # 300 sec timeout (5 min)
logger.error("Cannot establish connection to IP '%s'. Aborting" % floatip)
cleanup(nova_client, neutron_client, image_id, network_dic, sg_id, floatip_dic)
return (EXIT_CODE)
@@ -533,10 +536,9 @@ def main():
ping_script = REPO_PATH + "testcases/vPing/CI/libraries/ping.sh"
try:
- scp.put(ping_script,"~/")
- except Exception, e:
- logger.error("Cannot SCP the file '%s' to VM '%s'" % (ping_script,floatip))
-
+ scp.put(ping_script, "~/")
+ except:
+ logger.error("Cannot SCP the file '%s' to VM '%s'" % (ping_script, floatip))
cmd = 'chmod 755 ~/ping.sh'
(stdin, stdout, stderr) = ssh.exec_command(cmd)
@@ -554,7 +556,6 @@ def main():
(stdin, stdout, stderr) = ssh.exec_command(cmd)
output = stdout.readlines()
-
for line in output:
if "vPing OK" in line:
logger.info("vPing detected!")
@@ -570,7 +571,7 @@ def main():
logger.info("Timeout reached.")
flag = True
break
- if flag :
+ if flag:
break
logger.debug("Pinging %s. Waiting for response..." % test_ip)
sec += 1
diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py
index 8f214205b..49689f604 100644
--- a/testcases/vPing/CI/libraries/vPing_userdata.py
+++ b/testcases/vPing/CI/libraries/vPing_userdata.py
@@ -107,6 +107,7 @@ SECGROUP_NAME = functest_yaml.get("vping"). \
SECGROUP_DESCR = functest_yaml.get("vping"). \
get("vping_sg_descr")
+
def pMsg(value):
"""pretty printing"""
@@ -155,15 +156,15 @@ def waitVmDeleted(nova, vm):
def create_private_neutron_net(neutron):
# Check if the network already exists
- network_id = functest_utils.get_network_id(neutron,NEUTRON_PRIVATE_NET_NAME)
- subnet_id = functest_utils.get_subnet_id(neutron,NEUTRON_PRIVATE_SUBNET_NAME)
- router_id = functest_utils.get_router_id(neutron,NEUTRON_ROUTER_NAME)
+ network_id = functest_utils.get_network_id(neutron, NEUTRON_PRIVATE_NET_NAME)
+ subnet_id = functest_utils.get_subnet_id(neutron, NEUTRON_PRIVATE_SUBNET_NAME)
+ router_id = functest_utils.get_router_id(neutron, NEUTRON_ROUTER_NAME)
- if network_id != '' and subnet_id != '' and router_id != '' :
- logger.info("Using existing network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
+ if network_id != '' and subnet_id != '' and router_id != '':
+ logger.info("Using existing network '%s'.." % NEUTRON_PRIVATE_NET_NAME)
else:
neutron.format = 'json'
- logger.info('Creating neutron network %s...' % NEUTRON_PRIVATE_NET_NAME)
+ logger.info('Creating neutron network %s..' % NEUTRON_PRIVATE_NET_NAME)
network_id = functest_utils. \
create_neutron_net(neutron, NEUTRON_PRIVATE_NET_NAME)
@@ -203,6 +204,7 @@ def create_private_neutron_net(neutron):
'router_id': router_id}
return network_dic
+
def create_security_group(neutron_client):
sg_id = functest_utils.get_security_group_id(neutron_client, SECGROUP_NAME)
if sg_id != '':
@@ -210,8 +212,8 @@ def create_security_group(neutron_client):
else:
logger.info("Creating security group '%s'..." % SECGROUP_NAME)
SECGROUP = functest_utils.create_security_group(neutron_client,
- SECGROUP_NAME,
- SECGROUP_DESCR)
+ SECGROUP_NAME,
+ SECGROUP_DESCR)
if not SECGROUP:
logger.error("Failed to create the security group...")
return False
@@ -219,17 +221,18 @@ def create_security_group(neutron_client):
sg_id = SECGROUP['id']
logger.debug("Security group '%s' with ID=%s created successfully." %\
- (SECGROUP['name'], sg_id))
+ (SECGROUP['name'], sg_id))
logger.debug("Adding ICMP rules in security group '%s'..." % SECGROUP_NAME)
if not functest_utils.create_secgroup_rule(neutron_client, sg_id, \
- 'ingress', 'icmp'):
+ 'ingress', 'icmp'):
logger.error("Failed to create the security group rule...")
return False
logger.debug("Adding SSH rules in security group '%s'..." % SECGROUP_NAME)
if not functest_utils.create_secgroup_rule(neutron_client, sg_id, \
- 'ingress', 'tcp', '22', '22'):
+ 'ingress', 'tcp',
+ '22', '22'):
logger.error("Failed to create the security group rule...")
return False
@@ -239,6 +242,7 @@ def create_security_group(neutron_client):
return False
return sg_id
+
def cleanup(nova, neutron, image_id, network_dic):
if args.noclean:
logger.debug("The OpenStack resources are not deleted.")
@@ -311,16 +315,22 @@ def cleanup(nova, neutron, image_id, network_dic):
return True
+
def push_results(start_time_ts, duration, test_status):
try:
logger.debug("Pushing result into DB...")
scenario = functest_utils.get_scenario(logger)
+ version = scenario
+ criteria = "failed"
+ if test_status == "OK":
+ criteria = "passed"
pod_name = functest_utils.get_pod_name(logger)
build_tag = functest_utils.get_build_tag(logger)
functest_utils.push_results_to_db(TEST_DB,
"functest",
"vPing_userdata",
- logger, pod_name, scenario, build_tag,
+ logger, pod_name, version, scenario,
+ criteria, build_tag,
payload={'timestart': start_time_ts,
'duration': duration,
'status': test_status})
@@ -351,7 +361,7 @@ def main():
logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME)
else:
logger.info("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH))
+ GLANCE_IMAGE_PATH))
image_id = functest_utils.create_glance_image(glance_client,
GLANCE_IMAGE_NAME,
GLANCE_IMAGE_PATH)
@@ -359,7 +369,7 @@ def main():
logger.error("Failed to create a Glance image...")
return(EXIT_CODE)
logger.debug("Image '%s' with ID=%s created successfully." %\
- (GLANCE_IMAGE_NAME, image_id))
+ (GLANCE_IMAGE_NAME, image_id))
network_dic = create_private_neutron_net(neutron_client)
if not network_dic:
@@ -485,8 +495,8 @@ def main():
break
elif sec % 10 == 0:
if "request failed" in console_log:
- logger.debug("It seems userdata is not supported in nova boot."+\
- " Waiting a bit...")
+ logger.debug("It seems userdata is not supported in nova boot." + \
+ " Waiting a bit...")
metadata_tries += 1
else:
logger.debug("Pinging %s. Waiting for response..." % test_ip)