aboutsummaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
Diffstat (limited to 'testcases')
-rw-r--r--testcases/Controllers/ONOS/Teston/CI/onosfunctest.py2
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/check_os.sh12
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/clean_openstack.py91
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/generate_defaults.py34
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py1
-rwxr-xr-xtestcases/config_functest.py39
-rw-r--r--testcases/config_functest.yaml2
-rw-r--r--testcases/features/promise.py78
-rw-r--r--testcases/functest_utils.py57
-rw-r--r--testcases/vIMS/CI/vIMS.py1
-rw-r--r--testcases/vPing/CI/libraries/vPing.py36
-rw-r--r--testcases/vPing/CI/libraries/vPing2.py107
12 files changed, 308 insertions, 152 deletions
diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
index 4b3779410..bf031cb47 100644
--- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
@@ -142,7 +142,7 @@ def GetResult():
return payload
def SetOnosIp():
- cmd = "keystone catalog --service network | grep publicURL"
+ cmd = "openstack catalog show network | grep publicURL"
cmd_output = os.popen(cmd).read()
OC1=re.search(r"\d+\.\d+\.\d+\.\d+",cmd_output).group()
os.environ['OC1'] = OC1
diff --git a/testcases/VIM/OpenStack/CI/libraries/check_os.sh b/testcases/VIM/OpenStack/CI/libraries/check_os.sh
index 63d4ea696..ab3d21922 100755
--- a/testcases/VIM/OpenStack/CI/libraries/check_os.sh
+++ b/testcases/VIM/OpenStack/CI/libraries/check_os.sh
@@ -37,7 +37,7 @@ if [ $RETVAL -ne 0 ]; then
fi
echo " ...OK"
-adminURL=$(keystone catalog --service identity 2>/dev/null|grep adminURL|awk '{print $4}')
+adminURL=$(openstack catalog show identity |grep adminURL|awk '{print $4}')
adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
@@ -52,7 +52,7 @@ echo " ...OK"
echo "Checking OpenStack basic services:"
-commands=('keystone endpoint-list' 'nova list' 'neutron net-list' \
+commands=('openstack endpoint list' 'nova list' 'neutron net-list' \
'glance image-list' 'cinder list')
for cmd in "${commands[@]}"
do
@@ -105,9 +105,9 @@ echo "neutron router-list:"
neutron router-list
echo "neutron security-group-list:"
neutron security-group-list
-echo "keystone tenant-list:"
-keystone tenant-list
-echo "keystone user-list:"
-keystone user-list
+echo "openstack project list:"
+openstack project list
+echo "openstack user list:"
+openstack user list
exit 0
diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
index 464defcc9..e47750052 100644
--- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
+++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
@@ -59,20 +59,26 @@ if not os.path.exists(REPO_PATH):
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
-with open(REPO_PATH+"testcases/VIM/OpenStack/CI/libraries/os_defaults.yaml") as f:
- defaults_yaml = yaml.safe_load(f)
-f.close()
-
-installer = os.environ["INSTALLER_TYPE"]
+DEFAULTS_FILE = '/home/opnfv/functest/conf/os_defaults.yaml'
+
+try:
+ with open(DEFAULTS_FILE) as f:
+ defaults_yaml = yaml.safe_load(f)
+except Exception, e:
+ logger.info("The file %s does not exist. Please run generate_defaults.py "
+ "to create the OpenStack defaults. "
+ "Aborting cleanup..." % DEFAULTS_FILE)
+ exit(0)
-default_images = defaults_yaml.get(installer).get("images")
-default_networks = defaults_yaml.get(installer).get("networks") +\
- defaults_yaml.get("common").get("networks")
-default_routers = defaults_yaml.get(installer).get("routers") +\
- defaults_yaml.get("common").get("routers")
-default_security_groups = defaults_yaml.get(installer).get("security_groups")
-default_users = defaults_yaml.get(installer).get("users")
-default_tenants = defaults_yaml.get(installer).get("tenants")
+default_images = defaults_yaml.get('images')
+default_instances = defaults_yaml.get('instances')
+default_volumes = defaults_yaml.get('volumes')
+default_networks = defaults_yaml.get('networks')
+default_routers = defaults_yaml.get('routers')
+default_security_groups = defaults_yaml.get('secgroups')
+default_floatingips = defaults_yaml.get('floatingips')
+default_users = defaults_yaml.get('users')
+default_tenants = defaults_yaml.get('tenants')
def separator():
logger.info("-------------------------------------------")
@@ -116,7 +122,7 @@ def remove_images(nova_client):
image_name = getattr(image, 'name')
image_id = getattr(image, 'id')
logger.debug("'%s', ID=%s " %(image_name,image_id))
- if image_name not in default_images:
+ if image_id not in default_images:
logger.debug("Removing image '%s', ID=%s ..." % (image_name,image_id))
if functest_utils.delete_glance_image(nova_client, image_id):
logger.debug(" > Done!")
@@ -136,19 +142,23 @@ def remove_volumes(cinder_client):
for volume in volumes:
volume_id = getattr(volume, 'id')
- logger.debug("Removing cinder volume %s ..." % volume_id)
- if functest_utils.delete_volume(cinder_client, volume_id):
- logger.debug(" > Done!")
- else:
- logger.debug("Trying forced removal...")
- if functest_utils.delete_volume(cinder_client,
- volume_id,
- forced=True):
+ volume_name = getattr(volume, 'display_name')
+ logger.debug("'%s', ID=%s " %(volume_name,volume_id))
+ if volume_id not in default_volumes:
+ logger.debug("Removing cinder volume %s ..." % volume_id)
+ if functest_utils.delete_volume(cinder_client, volume_id):
logger.debug(" > Done!")
else:
- logger.error("There has been a problem removing the "
- "volume %s..." % volume_id)
-
+ logger.debug("Trying forced removal...")
+ if functest_utils.delete_volume(cinder_client,
+ volume_id,
+ forced=True):
+ logger.debug(" > Done!")
+ else:
+ logger.error("There has been a problem removing the "
+ "volume %s..." % volume_id)
+ else:
+ logger.debug(" > this is a default volume and will NOT be deleted.")
def remove_floatingips(nova_client):
logger.info("Removing floating IPs...")
@@ -157,19 +167,28 @@ def remove_floatingips(nova_client):
logger.debug("No floating IPs found.")
return
+ init_len = len(floatingips)
+ deleted = 0
for fip in floatingips:
fip_id = getattr(fip, 'id')
- logger.debug("Removing floating IP %s ..." % fip_id)
- if functest_utils.delete_floating_ip(nova_client, fip_id):
- logger.debug(" > Done!")
+ fip_ip = getattr(fip, 'ip')
+ logger.debug("'%s', ID=%s " %(fip_ip,fip_id))
+ if fip_id not in default_floatingips:
+ logger.debug("Removing floating IP %s ..." % fip_id)
+ if functest_utils.delete_floating_ip(nova_client, fip_id):
+ logger.debug(" > Done!")
+ deleted += 1
+ else:
+ logger.error("There has been a problem removing the "
+ "floating IP %s..." % fip_id)
else:
- logger.error("There has been a problem removing the "
- "floating IP %s..." % fip_id)
+ logger.debug(" > this is a default floating IP and will NOT be deleted.")
+
timeout = 50
while timeout > 0:
floatingips = functest_utils.get_floating_ips(nova_client)
- if floatingips is None or len(floatingips) == 0:
+ if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
logger.debug("Waiting for floating ips to be released...")
@@ -189,7 +208,7 @@ def remove_networks(neutron_client):
net_id = network['id']
net_name = network['name']
logger.debug(" '%s', ID=%s " %(net_name,net_id))
- if net_name in default_networks:
+ if net_id in default_networks:
logger.debug(" > this is a default network and will NOT be deleted.")
elif network['router:external'] == True:
logger.debug(" > this is an external network and will NOT be deleted.")
@@ -273,7 +292,7 @@ def remove_routers(neutron_client, routers):
for router in routers:
router_id = router['id']
router_name = router['name']
- if router_name not in default_routers:
+ if router_id not in default_routers:
logger.debug("Checking '%s' with ID=(%s) ..." % (router_name,router_id))
if router['external_gateway_info'] != None:
logger.debug("Router has gateway to external network. Removing link...")
@@ -303,7 +322,7 @@ def remove_security_groups(neutron_client):
secgroup_name = secgroup['name']
secgroup_id = secgroup['id']
logger.debug("'%s', ID=%s " %(secgroup_name,secgroup_id))
- if secgroup_name not in default_security_groups:
+ if secgroup_id not in default_security_groups:
logger.debug(" Removing '%s'..." % secgroup_name)
if functest_utils.delete_security_group(neutron_client, secgroup_id):
logger.debug(" > Done!")
@@ -326,7 +345,7 @@ def remove_users(keystone_client):
user_name = getattr(user, 'name')
user_id = getattr(user, 'id')
logger.debug("'%s', ID=%s " %(user_name,user_id))
- if user_name not in default_users:
+ if user_id not in default_users:
logger.debug(" Removing '%s'..." % user_name)
if functest_utils.delete_user(keystone_client,user_id):
logger.debug(" > Done!")
@@ -348,7 +367,7 @@ def remove_tenants(keystone_client):
tenant_name=getattr(tenant, 'name')
tenant_id = getattr(tenant, 'id')
logger.debug("'%s', ID=%s " %(tenant_name,tenant_id))
- if tenant_name not in default_tenants:
+ if tenant_id not in default_tenants:
logger.debug(" Removing '%s'..." % tenant_name)
if functest_utils.delete_tenant(keystone_client,tenant_id):
logger.debug(" > Done!")
diff --git a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
index 0c88c2fd8..72987ddda 100644
--- a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
+++ b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
@@ -39,7 +39,7 @@ args = parser.parse_args()
""" logging configuration """
-logger = logging.getLogger('clean_openstack')
+logger = logging.getLogger('generate_defaults')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
@@ -85,8 +85,18 @@ def get_images(nova_client):
return {'images': dic_images}
+def get_volumes(cinder_client):
+ logger.debug("Getting volumes...")
+ dic_volumes = {}
+ volumes = functest_utils.get_volumes(cinder_client)
+ if volumes != None:
+ for volume in volumes:
+ dic_volumes.update({volume.id:volume.display_name})
+ return {'volumes': dic_volumes}
+
+
def get_networks(neutron_client):
- logger.info("Getting networks")
+ logger.debug("Getting networks")
dic_networks = {}
networks = functest_utils.get_network_list(neutron_client)
if networks != None:
@@ -94,8 +104,9 @@ def get_networks(neutron_client):
dic_networks.update({network['id']:network['name']})
return {'networks': dic_networks}
+
def get_routers(neutron_client):
- logger.info("Getting routers")
+ logger.debug("Getting routers")
dic_routers = {}
routers = functest_utils.get_router_list(neutron_client)
if routers != None:
@@ -105,7 +116,7 @@ def get_routers(neutron_client):
def get_security_groups(neutron_client):
- logger.info("Getting Security groups...")
+ logger.debug("Getting Security groups...")
dic_secgroups = {}
secgroups = functest_utils.get_security_groups(neutron_client)
if not (secgroups is None or len(secgroups) == 0):
@@ -114,6 +125,16 @@ def get_security_groups(neutron_client):
return {'secgroups': dic_secgroups}
+def get_floatinips(nova_client):
+ logger.debug("Getting Floating IPs...")
+ dic_floatingips = {}
+ floatingips = functest_utils.get_floating_ips(nova_client)
+ if not (floatingips is None or len(floatingips) == 0):
+ for floatingip in floatingips:
+ dic_floatingips.update({floatingip.id:floatingip.ip})
+ return {'floatingips': dic_floatingips}
+
+
def get_users(keystone_client):
logger.debug("Getting users...")
dic_users = {}
@@ -158,16 +179,21 @@ def main():
defaults = {}
defaults.update(get_instances(nova_client))
defaults.update(get_images(nova_client))
+ defaults.update(get_volumes(cinder_client))
defaults.update(get_networks(neutron_client))
defaults.update(get_routers(neutron_client))
defaults.update(get_security_groups(neutron_client))
+ defaults.update(get_floatinips(nova_client))
defaults.update(get_users(keystone_client))
defaults.update(get_tenants(keystone_client))
with open(DEFAULTS_FILE, 'w+') as yaml_file:
yaml_file.write(yaml.safe_dump(defaults, default_flow_style=False))
yaml_file.seek(0)
+ logger.info("Openstack Defaults found in the deployment:")
print yaml_file.read()
+ logger.debug("NOTE: These objects will NOT be deleted after "+\
+ "running the tests.")
exit(0)
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 3b937e92e..6b1530577 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -19,6 +19,7 @@ import logging
import os
import re
import requests
+import shutil
import subprocess
import sys
import time
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index d1a197601..21c569cb0 100755
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -162,24 +162,16 @@ def action_check():
dirs = [RALLY_DIR, RALLY_INSTALLATION_DIR, VPING_DIR, ODL_DIR]
for dir in dirs:
if not os.path.exists(dir):
- logger.debug("The directory '%s' does NOT exist." % dir)
+ logger.debug(" %s NOT found" % dir)
errors = True
errors_all = True
else:
logger.debug(" %s found" % dir)
- if not errors:
- logger.debug("...OK")
- else:
- logger.debug("...FAIL")
-
logger.debug("Checking Rally deployment...")
if not check_rally():
logger.debug(" Rally deployment NOT installed.")
errors_all = True
- logger.debug("...FAIL")
- else:
- logger.debug("...OK")
logger.debug("Checking Image...")
errors = False
@@ -191,11 +183,6 @@ def action_check():
logger.debug(" Image file found in %s" % IMAGE_PATH)
- if not errors:
- logger.debug("...OK")
- else:
- logger.debug("...FAIL")
-
#TODO: check OLD environment setup
return not errors_all
@@ -214,10 +201,6 @@ def action_clean():
logger.debug("Removing Result directory")
shutil.rmtree(RALLY_RESULT_DIR,ignore_errors=True)
- logger.debug("Cleaning up the OpenStack deployment...")
- cmd='python ' + FUNCTEST_REPO + \
- '/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py --debug'
- functest_utils.execute_command(cmd,logger)
logger.info("Functest environment clean!")
@@ -296,21 +279,21 @@ def check_rally():
def create_private_neutron_net(neutron):
neutron.format = 'json'
- logger.info('Creating neutron network %s...' % NEUTRON_PRIVATE_NET_NAME)
+ logger.info("Creating network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
network_id = functest_utils. \
create_neutron_net(neutron, NEUTRON_PRIVATE_NET_NAME)
if not network_id:
return False
- logger.debug("Network '%s' created successfully" % network_id)
+ logger.debug("Network '%s' created successfully." % network_id)
- logger.info('Updating neutron network %s...' % NEUTRON_PRIVATE_NET_NAME)
+ logger.info("Updating network '%s' with shared=True..." % NEUTRON_PRIVATE_NET_NAME)
if functest_utils.update_neutron_net(neutron, network_id, shared=True):
- logger.debug("Network '%s' updated successfully" % network_id)
+ logger.debug("Network '%s' updated successfully." % network_id)
else:
- logger.info('Updating neutron network %s failed' % network_id)
+ logger.info("Updating neutron network '%s' failed" % network_id)
- logger.debug('Creating Subnet....')
+ logger.info("Creating Subnet....")
subnet_id = functest_utils. \
create_neutron_subnet(neutron,
NEUTRON_PRIVATE_SUBNET_NAME,
@@ -318,16 +301,16 @@ def create_private_neutron_net(neutron):
network_id)
if not subnet_id:
return False
- logger.debug("Subnet '%s' created successfully" % subnet_id)
- logger.debug('Creating Router...')
+ logger.debug("Subnet '%s' created successfully." % subnet_id)
+ logger.info("Creating Router...")
router_id = functest_utils. \
create_neutron_router(neutron, NEUTRON_ROUTER_NAME)
if not router_id:
return False
- logger.debug("Router '%s' created successfully" % router_id)
- logger.debug('Adding router to subnet...')
+ logger.debug("Router '%s' created successfully." % router_id)
+ logger.info("Adding router to subnet...")
result = functest_utils.add_interface_router(neutron, router_id, subnet_id)
diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml
index bab1a4b94..28455a3ba 100644
--- a/testcases/config_functest.yaml
+++ b/testcases/config_functest.yaml
@@ -25,7 +25,7 @@ general:
dir_rally_res: /home/opnfv/functest/results/rally/
dir_functest_data: /home/opnfv/functest/data
dir_vIMS_data: /home/opnfv/functest/data/vIMS
- dir_rally_inst: ~/.rally
+ dir_rally_inst: /home/opnfv/.rally
repositories:
# branch and commit ID to which the repos will be reset (HEAD)
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index b0fadf708..a92029427 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -10,6 +10,7 @@
# Maintainer : jose.lausuch@ericsson.com
#
import argparse
+import json
import logging
import os
import subprocess
@@ -36,7 +37,7 @@ with open('/home/opnfv/functest/conf/config_functest.yaml') as f:
dirs = functest_yaml.get('general').get('directories')
FUNCTEST_REPO = dirs.get('dir_repo_functest')
PROMISE_REPO = dirs.get('dir_repo_promise')
-TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
+TEST_DB = functest_yaml.get('results').get('test_db_url')
TENANT_NAME = functest_yaml.get('promise').get('general').get('tenant_name')
TENANT_DESCRIPTION = functest_yaml.get('promise').get(
@@ -199,16 +200,14 @@ def main():
os.chdir(PROMISE_REPO)
- results_file=open('promise-results.json','w+')
- cmd = 'DEBUG=1 npm run -s test -- --reporter json'
- start_time_ts = time.time()
+ 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)
results_file.close()
- end_time_ts = time.time()
- duration = round(end_time_ts - start_time_ts, 1)
if ret == 0:
logger.info("The test succeeded.")
@@ -218,25 +217,56 @@ def main():
test_status = "Failed"
# Print output of file
- results_file=open('promise-results.json','r')
- print results_file.read()
- results_file.close()
-
+ with open(results_file_name,'r') as results_file:
+ data = results_file.read()
+ logger.debug("\n%s" % data)
+ json_data = json.loads(data)
+
+ suites = json_data["stats"]["suites"]
+ tests = json_data["stats"]["tests"]
+ passes = json_data["stats"]["passes"]
+ pending = json_data["stats"]["pending"]
+ failures = json_data["stats"]["failures"]
+ start_time = json_data["stats"]["start"]
+ end_time = json_data["stats"]["end"]
+ 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))
+
+
+ if args.report:
+ pod_name = functest_utils.get_pod_name(logger)
+ installer = functest_utils.get_installer_type(logger)
+ scenario = functest_utils.get_scenario(logger)
+ git_version = functest_utils.get_git_branch(PROMISE_REPO)
+ url = TEST_DB + "/results"
+
+ json_results = {"timestart": start_time, "duration": duration,
+ "tests": int(tests), "failures": int(failures)}
+ logger.debug("Results json: "+str(json_results))
+
+ params = {"project_name": "promise", "case_name": "promise",
+ "pod_name": str(pod_name), 'installer': installer,
+ "version": scenario, 'details': json_results}
+ headers = {'Content-Type': 'application/json'}
+
+ logger.info("Pushing results to DB...")
+ r = requests.post(url, data=json.dumps(params), headers=headers)
+ logger.debug(r)
- details = {
- 'timestart': start_time_ts,
- 'duration': duration,
- 'status': test_status,
- }
- pod_name = functest_utils.get_pod_name()
- git_version = functest_utils.get_git_branch(PROMISE_REPO)
- #functest_utils.push_results_to_db(TEST_DB_URL,
- # 'promise',
- # None,
- # pod_name,
- # git_version,
- # details)
- #
if __name__ == '__main__':
main()
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index da79c2c9a..57ec1863f 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -88,8 +88,8 @@ def get_instance_status(nova_client, instance):
instance = nova_client.servers.get(instance.id)
return instance.status
except Exception, e:
- print "Error [get_instance_status(nova_client, '%s')]:" % \
- str(instance), e
+ #print "Error [get_instance_status(nova_client, '%s')]:" % \
+ # str(instance), e
return None
@@ -423,6 +423,58 @@ def get_security_groups(neutron_client):
return None
+def create_security_group(neutron_client, sg_name, sg_description):
+ json_body= {'security_group' : { 'name' : sg_name, \
+ 'description' : sg_description }}
+ try:
+ secgroup = neutron_client.create_security_group(json_body)
+ return secgroup['security_group']
+ except Exception, e:
+ print "Error [create_security_group(neutron_client, '%s', '%s')]:" % \
+ (sg_name,sg_description), e
+ return False
+
+
+def create_secgroup_rule(neutron_client, sg_id, direction, protocol,
+ port_range_min = None, port_range_max = None):
+ if port_range_min == None and port_range_max == None:
+ json_body = { 'security_group_rule' : \
+ { 'direction' : direction, \
+ 'security_group_id' : sg_id, \
+ 'protocol' : protocol } }
+ elif port_range_min != None and port_range_max != None:
+ json_body = { 'security_group_rule' : \
+ { 'direction' : direction, \
+ 'security_group_id' : sg_id, \
+ 'port_range_min': port_range_min, \
+ 'port_range_max' : port_range_max, \
+ 'protocol' : protocol } }
+ else:
+ print "Error [create_secgroup_rule(neutron_client, '%s', '%s', "\
+ "'%s', '%s', '%s', '%s')]:" %(neutron_client, sg_id, direction, \
+ port_range_min, port_range_max, protocol),\
+ " Invalid values for port_range_min, port_range_max"
+ return False
+ try:
+ neutron_client.create_security_group_rule(json_body)
+ return True
+ except Exception, e:
+ print "Error [create_secgroup_rule(neutron_client, '%s', '%s', "\
+ "'%s', '%s', '%s', '%s')]:" %(neutron_client, sg_id, direction, \
+ port_range_min, port_range_max, protocol), e
+ return False
+
+
+def add_secgroup_to_instance(nova_client, instance_id, secgroup_id):
+ try:
+ nova_client.servers.add_security_group(instance_id, secgroup_id)
+ return True
+ except Exception, e:
+ print "Error [add_secgroup_to_instance(nova_client, '%s', '%s')]: " % \
+ (instance_id, secgroup_id), e
+ return False
+
+
def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota):
json_body = {"quota": {
"security_group": sg_quota,
@@ -449,6 +501,7 @@ def delete_security_group(neutron_client, secgroup_id):
+
#*********************************************
# GLANCE
#*********************************************
diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py
index ae2ad9d21..a8ac97f5c 100644
--- a/testcases/vIMS/CI/vIMS.py
+++ b/testcases/vIMS/CI/vIMS.py
@@ -364,6 +364,7 @@ def main():
logger.info("Prepare virtualenv for cloudify-cli")
cmd = "chmod +x " + VIMS_DIR + "create_venv.sh"
functest_utils.execute_command(cmd, logger)
+ time.sleep(3)
cmd = VIMS_DIR + "create_venv.sh " + VIMS_DATA_DIR
functest_utils.execute_command(cmd, logger)
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index 0b09b6d4f..1368bbec1 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -270,6 +270,20 @@ def cleanup(nova, neutron, image_id, network_dic, port_id1, port_id2):
return True
+def push_results(start_time_ts, duration, test_status):
+ try:
+ logger.debug("Pushing result into DB...")
+ scenario = functest_utils.get_scenario(logger)
+ pod_name = functest_utils.get_pod_name(logger)
+ functest_utils.push_results_to_db(TEST_DB,
+ "vPing_userdata",
+ logger, pod_name, scenario,
+ payload={'timestart': start_time_ts,
+ 'duration': duration,
+ 'status': test_status})
+ except:
+ logger.error("Error pushing results into Database '%s'" % sys.exc_info()[0])
+
def main():
@@ -466,31 +480,17 @@ def main():
logger.info("vPing OK")
test_status = "OK"
elif EXIT_CODE == -2:
+ duration = 0
logger.info("Userdata is not supported in nova boot. Aborting test...")
else:
+ duration = 0
logger.error("vPing FAILED")
cleanup(nova_client, neutron_client, image_id, network_dic,
port_id1, port_id2)
- try:
- if args.report and EXIT_CODE != -2:
- # Don't report if userdata is not supported
- logger.debug("Push result into DB")
- # TODO check path result for the file
- scenario = functest_utils.get_scenario(logger)
- pod_name = functest_utils.get_pod_name(logger)
- functest_utils.push_results_to_db(TEST_DB,
- "vPing_userdata",
- logger, pod_name, scenario,
- payload={'timestart': start_time_ts,
- 'duration': duration,
- 'status': test_status})
- # with open("vPing-result.json", "w") as outfile:
- # json.dump({'timestart': start_time_ts, 'duration': duration,
- # 'status': test_status}, outfile, indent=4)
- except:
- logger.error("Error pushing results into Database '%s'" % sys.exc_info()[0])
+ if args.report:
+ push_results(start_time_ts, duration, test_status)
exit(EXIT_CODE)
diff --git a/testcases/vPing/CI/libraries/vPing2.py b/testcases/vPing/CI/libraries/vPing2.py
index a60ae000f..1ce6dc9e5 100644
--- a/testcases/vPing/CI/libraries/vPing2.py
+++ b/testcases/vPing/CI/libraries/vPing2.py
@@ -197,7 +197,7 @@ def create_private_neutron_net(neutron):
return network_dic
-def cleanup(nova, neutron, image_id, network_dic, port_id1, port_id2):
+def cleanup(nova, neutron, image_id, network_dic, port_id1, port_id2, secgroup_id):
# delete both VMs
logger.info("Cleaning up...")
@@ -232,7 +232,7 @@ def cleanup(nova, neutron, image_id, network_dic, port_id1, port_id2):
logger.debug("Instance %s terminated." % NAME_VM_2)
# delete created network
- logger.info("Deleting network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
+ logger.debug("Deleting network '%s'..." % NEUTRON_PRIVATE_NET_NAME)
net_id = network_dic["net_id"]
subnet_id = network_dic["subnet_id"]
router_id = network_dic["router_id"]
@@ -274,8 +274,28 @@ def cleanup(nova, neutron, image_id, network_dic, port_id1, port_id2):
logger.debug(
"Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME)
+ if not functest_utils.delete_security_group(neutron, secgroup_id):
+ logger.error("Unable to delete security group '%s'" % secgroup_id)
+ return False
+ logger.debug(
+ "Security group '%s' deleted successfully" % secgroup_id)
+
return True
+def push_results(start_time_ts, duration, test_status):
+ try:
+ logger.debug("Pushing result into DB...")
+ scenario = functest_utils.get_scenario(logger)
+ pod_name = functest_utils.get_pod_name(logger)
+ functest_utils.push_results_to_db(TEST_DB,
+ "vPing",
+ logger, pod_name, scenario,
+ payload={'timestart': start_time_ts,
+ 'duration': duration,
+ 'status': test_status})
+ except:
+ logger.error("Error pushing results into Database '%s'" % sys.exc_info()[0])
+
def main():
@@ -302,7 +322,8 @@ def main():
if not image_id:
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))
# Check if the given image exists
image = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
if image == '':
@@ -339,6 +360,36 @@ def main():
logger.info("Instance %s found. Deleting..." % server.name)
server.delete()
+ SECGROUP_NAME = "vPing-sg"
+ SECGROUP_DESCR = "Security group for vPing test case"
+ logger.info("Creating security group '%s'..." % SECGROUP_NAME)
+ SECGROUP = functest_utils.create_security_group(neutron_client,
+ SECGROUP_NAME,
+ SECGROUP_DESCR)
+ SECGROUP_ID = SECGROUP['id']
+ if not SECGROUP:
+ logger.error("Failed to create the security group...")
+ return(EXIT_CODE)
+ logger.debug("Security group '%s' with ID=%s created successfully." %\
+ (SECGROUP['name'], SECGROUP_ID))
+
+ logger.debug("Adding ICMP rules in security group '%s'..." % SECGROUP_NAME)
+ if not functest_utils.create_secgroup_rule(neutron_client, SECGROUP_ID, \
+ 'ingress', 'icmp'):
+ logger.error("Failed to create the security group rule...")
+ return(EXIT_CODE)
+
+ logger.debug("Adding SSH rules in security group '%s'..." % SECGROUP_NAME)
+ if not functest_utils.create_secgroup_rule(neutron_client, SECGROUP_ID, \
+ 'ingress', 'tcp', '22', '22'):
+ logger.error("Failed to create the security group rule...")
+ return(EXIT_CODE)
+
+ if not functest_utils.create_secgroup_rule(neutron_client, SECGROUP_ID, \
+ 'egress', 'tcp', '22', '22'):
+ logger.error("Failed to create the security group rule...")
+ return(EXIT_CODE)
+
# boot VM 1
# basic boot
# tune (e.g. flavor, images, network) to your specific
@@ -373,10 +424,10 @@ def main():
# wait until VM status is active
if not waitVmActive(nova_client, vm1):
-
logger.error("Instance '%s' cannot be booted. Status is '%s'" % (
NAME_VM_1, functest_utils.get_instance_status(nova_client, vm1)))
- cleanup(nova_client, neutron_client, image_id, network_dic, port_id1)
+ cleanup(nova_client, neutron_client, image_id, network_dic,
+ port_id1, SECGROUP_ID)
return (EXIT_CODE)
else:
logger.info("Instance '%s' is ACTIVE." % NAME_VM_1)
@@ -391,6 +442,9 @@ def main():
test_ip = IP_1
logger.debug("Instance '%s' got %s" % (NAME_VM_1, test_ip))
+ logger.info("Adding '%s' to security group '%s'..." % (NAME_VM_1, SECGROUP_NAME))
+ functest_utils.add_secgroup_to_instance(nova_client, vm1.id, SECGROUP['id'])
+
# boot VM 2
# we will boot then execute a ping script with cloud-init
# the long chain corresponds to the ping procedure converted with base 64
@@ -410,8 +464,8 @@ def main():
logger.info("Creating instance '%s' with IP %s..." % (NAME_VM_2, IP_2))
logger.debug(
- "Configuration:\n name=%s \n flavor=%s \n image=%s \n network=%s "
- "\n" % (NAME_VM_2, flavor, image, network_id))
+ "Configuration:\n name=%s \n flavor=%s \n image=%s \n "
+ "network=%s \n" % (NAME_VM_2, flavor, image, network_id))
vm2 = nova_client.servers.create(
name=NAME_VM_2,
flavor=flavor,
@@ -423,25 +477,28 @@ def main():
logger.error("Instance '%s' cannot be booted. Status is '%s'" % (
NAME_VM_2, functest_utils.get_instance_status(nova_client, vm2)))
cleanup(nova_client, neutron_client, image_id, network_dic,
- port_id1, port_id2)
+ port_id1, port_id2, SECGROUP_ID)
return (EXIT_CODE)
else:
logger.info("Instance '%s' is ACTIVE." % NAME_VM_2)
- logger.info("Creating floating IP for the second VM...")
+ logger.info("Adding '%s' to security group '%s'..." % (NAME_VM_2, SECGROUP_NAME))
+ functest_utils.add_secgroup_to_instance(nova_client, vm2.id, SECGROUP['id'])
+
+ logger.info("Creating floating IP for VM '%s'..." % NAME_VM_2)
floatip = functest_utils.create_floating_ip(neutron_client)
if floatip == None:
logger.error("Cannot create floating IP.")
cleanup(nova_client, neutron_client, image_id, network_dic,
- port_id1, port_id2)
+ port_id1, port_id2, SECGROUP_ID)
return (EXIT_CODE)
logger.info("Floating IP created: '%s'" % floatip)
- logger.info("Associating floating ip: '%s' to VM2 " % floatip)
+ logger.info("Associating floating ip: '%s' to VM '%s' " % (floatip, NAME_VM_2))
if not functest_utils.add_floating_ip(nova_client, vm2.id, floatip):
logger.error("Cannot associate floating IP to VM.")
cleanup(nova_client, neutron_client, image_id, network_dic,
- port_id1, port_id2)
+ port_id1, port_id2, SECGROUP_ID)
return (EXIT_CODE)
logger.info("Trying to establish SSH connection to %s..." % floatip)
@@ -465,7 +522,7 @@ def main():
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,
- port_id1, port_id2)
+ port_id1, port_id2, SECGROUP_ID)
return (EXIT_CODE)
scp = SCPClient(ssh.get_transport())
@@ -517,7 +574,7 @@ def main():
# we consider start time at VM1 booting
end_time_ts = time.time()
duration = round(end_time_ts - start_time_ts, 1)
- logger.info("vPing duration:'%s'" % duration)
+ logger.info("vPing duration:'%s' s." % duration)
EXIT_CODE = 0
flag = True
break
@@ -531,32 +588,18 @@ def main():
sec += 1
cleanup(nova_client, neutron_client, image_id, network_dic,
- port_id1, port_id2)
+ port_id1, port_id2, SECGROUP_ID)
test_status = "NOK"
if EXIT_CODE == 0:
logger.info("vPing OK")
test_status = "OK"
else:
+ duration = 0
logger.error("vPing FAILED")
- try:
- if args.report:
- logger.debug("Push result into DB")
- # TODO check path result for the file
- scenario = functest_utils.get_scenario(logger)
- pod_name = functest_utils.get_pod_name(logger)
- functest_utils.push_results_to_db(TEST_DB,
- "vPing",
- logger, pod_name, scenario,
- payload={'timestart': start_time_ts,
- 'duration': duration,
- 'status': test_status})
- # with open("vPing-result.json", "w") as outfile:
- # json.dump({'timestart': start_time_ts, 'duration': duration,
- # 'status': test_status}, outfile, indent=4)
- except:
- logger.error("Error pushing results into Database '%s'" % sys.exc_info()[0])
+ if args.report:
+ push_results(start_time_ts, duration, test_status)
exit(EXIT_CODE)