diff options
-rw-r--r-- | ci/config_functest.yaml | 14 | ||||
-rwxr-xr-x | testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py | 31 | ||||
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/run_tempest.py | 59 | ||||
-rw-r--r-- | testcases/features/promise.py | 23 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing_ssh.py | 76 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing_userdata.py | 71 | ||||
-rw-r--r-- | utils/openstack_utils.py | 56 |
7 files changed, 159 insertions, 171 deletions
diff --git a/ci/config_functest.yaml b/ci/config_functest.yaml index e463df202..29a74afd5 100644 --- a/ci/config_functest.yaml +++ b/ci/config_functest.yaml @@ -62,11 +62,17 @@ tempest: tenant_description: Tenant for Tempest test suite user_name: tempest user_password: tempest - input-scenario: - ssh_user_regex: '[["^.*[Cc]irros.*$", "cirros"], ["^.*[Tt]est[VvMm].*$", "cirros"], ["^.*rally_verify.*$", "cirros"]]' + private_net_name: tempest-net + private_subnet_name: tempest-subnet + private_subnet_cidr: 192.168.150.0/24 + router_name: tempest-router rally: deployment_name: opnfv-rally + network_name: rally-net + subnet_name: rally-subnet + subnet_cidr: 192.168.140.0/24 + router_name: rally-router vIMS: general: @@ -144,6 +150,10 @@ promise: flavor_vcpus: 1 flavor_ram: 512 flavor_disk: 0 + network_name: promise-net + subnet_name: promise-subnet + subnet_cidr: 192.168.121.0/24 + router_name: promise-router results: test_db_url: http://testresults.opnfv.org/testapi diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index 6aa6ee064..4dc1e16d5 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py @@ -67,6 +67,7 @@ parser.add_argument("-z", "--sanity", args = parser.parse_args() client_dict = {} +network_dict = {} if args.verbose: RALLY_STDERR = subprocess.STDOUT @@ -103,8 +104,11 @@ RESULTS_DIR = functest_yaml.get("general").get("directories").get( TEMPEST_CONF_FILE = functest_yaml.get("general").get("directories").get( "dir_results") + '/tempest/tempest.conf' TEST_DB = functest_yaml.get("results").get("test_db_url") -PRIVATE_NETWORK = functest_yaml.get("general").get("openstack").get( - "neutron_private_net_name") + +PRIVATE_NET_NAME = functest_yaml.get("rally").get("network_name") +PRIVATE_SUBNET_NAME = functest_yaml.get("rally").get("subnet_name") +PRIVATE_SUBNET_CIDR = functest_yaml.get("rally").get("subnet_cidr") +ROUTER_NAME = functest_yaml.get("rally").get("router_name") GLANCE_IMAGE_NAME = functest_yaml.get("general").get("openstack").get( "image_name") @@ -209,8 +213,7 @@ def build_task_args(test_file_name): else: task_args['floating_network'] = '' - net_id = openstack_utils.get_network_id(client_dict['neutron'], - PRIVATE_NETWORK) + net_id = network_dict['net_id'] task_args['netid'] = str(net_id) task_args['live_migration'] = live_migration_supported() @@ -379,6 +382,7 @@ def run_task(test_name): def main(): global SUMMARY + global network_dict # configure script if not (args.test_name in tests): logger.error('argument not valid') @@ -438,6 +442,25 @@ def main(): % (GLANCE_IMAGE_NAME, image_id)) image_exists = True + logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME) + network_dict = openstack_utils.create_network_full(logger, + client_dict['neutron'], + PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) + if not network_dict: + logger.error("Failed to create network...") + exit(-1) + else: + if not openstack_utils.update_neutron_net(client_dict['neutron'], + network_dict['net_id'], + shared=True): + logger.error("Failed to update network...") + exit(-1) + else: + logger.debug("Network '%s' available..." % PRIVATE_NET_NAME) + if args.test_name == "all": for test_name in tests: if not (test_name == 'all' or diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index 02d9b331a..4c8e61a72 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -20,7 +20,6 @@ import re import requests import shutil import subprocess -import sys import time import yaml import ConfigParser @@ -68,14 +67,16 @@ f.close() TEST_DB = functest_yaml.get("results").get("test_db_url") MODE = "smoke" +PRIVATE_NET_NAME = functest_yaml.get("tempest").get("private_net_name") +PRIVATE_SUBNET_NAME = functest_yaml.get("tempest").get("private_subnet_name") +PRIVATE_SUBNET_CIDR = functest_yaml.get("tempest").get("private_subnet_cidr") +ROUTER_NAME = functest_yaml.get("tempest").get("router_name") TENANT_NAME = functest_yaml.get("tempest").get("identity").get("tenant_name") TENANT_DESCRIPTION = functest_yaml.get("tempest").get("identity").get( "tenant_description") USER_NAME = functest_yaml.get("tempest").get("identity").get("user_name") USER_PASSWORD = functest_yaml.get("tempest").get("identity").get( "user_password") -SSH_USER_REGEX = functest_yaml.get("tempest").get("input-scenario").get( - "ssh_user_regex") DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name") RALLY_INSTALLATION_DIR = functest_yaml.get("general").get("directories").get( "dir_rally_inst") @@ -133,7 +134,7 @@ def push_results_to_db(case, payload, criteria): def create_tempest_resources(): ks_creds = os_utils.get_credentials("keystone") - logger.info("Creating tenant and user for Tempest suite") + logger.debug("Creating tenant and user for Tempest suite") keystone = ksclient.Client(**ks_creds) tenant_id = os_utils.create_tenant(keystone, TENANT_NAME, @@ -146,25 +147,26 @@ def create_tempest_resources(): if user_id == '': logger.error("Error : Failed to create %s user" % USER_NAME) - -def free_tempest_resources(): - ks_creds = os_utils.get_credentials("keystone") - logger.info("Deleting tenant and user for Tempest suite)") - keystone = ksclient.Client(**ks_creds) - - user_id = os_utils.get_user_id(keystone, USER_NAME) - if user_id == '': - logger.error("Error : Failed to get id of %s user" % USER_NAME) - else: - if not os_utils.delete_user(keystone, user_id): - logger.error("Error : Failed to delete %s user" % USER_NAME) - - tenant_id = os_utils.get_tenant_id(keystone, TENANT_NAME) - if tenant_id == '': - logger.error("Error : Failed to get id of %s tenant" % TENANT_NAME) + logger.debug("Creating private network for Tempest suite") + creds_neutron = os_utils.get_credentials("neutron") + neutron_client = neutronclient.Client(**creds_neutron) + network_dic = os_utils.create_network_full(logger, + neutron_client, + PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) + if network_dic: + if not os_utils.update_neutron_net(neutron_client, + network_dic['net_id'], + shared=True): + logger.error("Failed to update private network...") + exit(-1) + else: + logger.debug("Network '%s' is available..." % PRIVATE_NET_NAME) else: - if not os_utils.delete_tenant(keystone, tenant_id): - logger.error("Error : Failed to delete %s tenant" % TENANT_NAME) + logger.error("Private network creation failed") + exit(-1) def configure_tempest(mode): @@ -207,16 +209,7 @@ def configure_tempest(mode): logger.debug("Updating selected tempest.conf parameters...") config = ConfigParser.RawConfigParser() config.read(tempest_conf_file) - private_net_name = "" - creds_neutron = os_utils.get_credentials("neutron") - neutron_client = neutronclient.Client(**creds_neutron) - private_net = os_utils.get_private_net(neutron_client) - if private_net is None: - logger.error("No shared private networks found.") - sys.exit(1) - else: - private_net_name = private_net['name'] - config.set('compute', 'fixed_network_name', private_net_name) + config.set('compute', 'fixed_network_name', PRIVATE_NET_NAME) config.set('identity', 'tenant_name', TENANT_NAME) config.set('identity', 'username', USER_NAME) config.set('identity', 'password', USER_PASSWORD) @@ -331,8 +324,6 @@ def main(): if args.noclean: exit(0) - free_tempest_resources() - if __name__ == '__main__': main() diff --git a/testcases/features/promise.py b/testcases/features/promise.py index f10e054cd..c74c7cfa7 100644 --- a/testcases/features/promise.py +++ b/testcases/features/promise.py @@ -60,6 +60,12 @@ GLANCE_IMAGE_FORMAT = functest_yaml.get('general').get('openstack').get( GLANCE_IMAGE_PATH = functest_yaml.get('general').get('directories').get( 'dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME +NET_NAME = functest_yaml.get('promise').get('general').get('network_name') +SUBNET_NAME = functest_yaml.get('promise').get('general').get('subnet_name') +SUBNET_CIDR = functest_yaml.get('promise').get('general').get('subnet_cidr') +ROUTER_NAME = functest_yaml.get('promise').get('general').get('router_name') + + """ logging configuration """ logger = ft_logger.Logger("promise").getLogger() @@ -160,13 +166,16 @@ def main(): % (FLAVOR_NAME, flavor_id)) neutron = ntclient.Client(**nt_creds) - private_net = openstack_utils.get_private_net(neutron) - if private_net is None: - logger.error("There is no private network in the deployment." - "Aborting...") + + network_dic = openstack_utils.create_network_full(logger, + neutron, + NET_NAME, + SUBNET_NAME, + ROUTER_NAME, + SUBNET_CIDR) + if network_dic is False: + logger.error("Failed to create the private network...") exit(-1) - logger.debug("Using private network '%s' (%s)." % (private_net['name'], - private_net['id'])) logger.info("Exporting environment variables...") os.environ["NODE_ENV"] = "functest" @@ -175,7 +184,7 @@ def main(): os.environ["OS_PASSWORD"] = USER_PWD os.environ["OS_TEST_IMAGE"] = image_id os.environ["OS_TEST_FLAVOR"] = flavor_id - os.environ["OS_TEST_NETWORK"] = private_net['id'] + os.environ["OS_TEST_NETWORK"] = network_dic["net_id"] os.chdir(PROMISE_REPO) results_file_name = 'promise-results.json' diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py index bd0b9b291..fa9770ba8 100644 --- a/testcases/vPing/CI/libraries/vPing_ssh.py +++ b/testcases/vPing/CI/libraries/vPing_ssh.py @@ -78,13 +78,13 @@ FLAVOR = functest_yaml.get("vping").get("vm_flavor") # NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get( +PRIVATE_NET_NAME = functest_yaml.get("vping").get( "vping_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( +PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( "vping_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( +PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( "vping_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("vping").get( +ROUTER_NAME = functest_yaml.get("vping").get( "vping_router_name") SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name") @@ -136,63 +136,6 @@ def waitVmDeleted(nova, vm): return False -def create_private_neutron_net(neutron): - - # Check if the network already exists - network_id = openstack_utils.get_network_id(neutron, - NEUTRON_PRIVATE_NET_NAME) - subnet_id = openstack_utils.get_subnet_id(neutron, - NEUTRON_PRIVATE_SUBNET_NAME) - router_id = openstack_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) - else: - neutron.format = 'json' - logger.info('Creating neutron network %s...' - % NEUTRON_PRIVATE_NET_NAME) - network_id = openstack_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('Creating Subnet....') - subnet_id = openstack_utils.create_neutron_subnet( - neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR, - network_id) - if not subnet_id: - return False - logger.debug("Subnet '%s' created successfully" % subnet_id) - logger.debug('Creating Router...') - router_id = openstack_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...') - - if not openstack_utils.add_interface_router(neutron, - router_id, - subnet_id): - return False - logger.debug("Interface added successfully.") - - logger.debug('Adding gateway to router...') - if not openstack_utils.add_gateway_router(neutron, router_id): - return False - logger.debug("Gateway added successfully.") - - network_dic = {'net_id': network_id, - 'subnet_id': subnet_id, - 'router_id': router_id} - return network_dic - - def create_security_group(neutron_client): sg_id = openstack_utils.get_security_group_id(neutron_client, SECGROUP_NAME) @@ -291,7 +234,12 @@ def main(): logger.debug("Image '%s' with ID=%s created successfully." % (GLANCE_IMAGE_NAME, image_id)) - network_dic = create_private_neutron_net(neutron_client) + network_dic = openstack_utils.create_network_full(logger, + neutron_client, + PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) if not network_dic: logger.error( "There has been a problem when creating the neutron network") @@ -345,7 +293,7 @@ def main(): logger.info("Instance '%s' is ACTIVE." % NAME_VM_1) # Retrieve IP of first VM - test_ip = vm1.networks.get(NEUTRON_PRIVATE_NET_NAME)[0] + test_ip = vm1.networks.get(PRIVATE_NET_NAME)[0] logger.debug("Instance '%s' got private ip '%s'." % (NAME_VM_1, test_ip)) logger.info("Adding '%s' to security group '%s'..." @@ -401,7 +349,7 @@ def main(): nolease = False got_ip = False discover_count = 0 - cidr_first_octet = NEUTRON_PRIVATE_SUBNET_CIDR.split('.')[0] + cidr_first_octet = PRIVATE_SUBNET_CIDR.split('.')[0] while timeout > 0: try: ssh.connect(floatip, username=username, diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py index 473c1f823..2b2963144 100644 --- a/testcases/vPing/CI/libraries/vPing_userdata.py +++ b/testcases/vPing/CI/libraries/vPing_userdata.py @@ -75,13 +75,13 @@ FLAVOR = functest_yaml.get("vping").get("vm_flavor") # NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get( +PRIVATE_NET_NAME = functest_yaml.get("vping").get( "vping_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( +PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( "vping_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( +PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( "vping_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("vping").get("vping_router_name") +ROUTER_NAME = functest_yaml.get("vping").get("vping_router_name") SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name") SECGROUP_DESCR = functest_yaml.get("vping").get("vping_sg_descr") @@ -132,60 +132,6 @@ def waitVmDeleted(nova, vm): return False -def create_private_neutron_net(neutron): - - # Check if the network already exists - network_id = openstack_utils.get_network_id(neutron, - NEUTRON_PRIVATE_NET_NAME) - subnet_id = openstack_utils.get_subnet_id(neutron, - NEUTRON_PRIVATE_SUBNET_NAME) - router_id = openstack_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) - else: - neutron.format = 'json' - logger.info('Creating neutron network %s..' % NEUTRON_PRIVATE_NET_NAME) - network_id = openstack_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('Creating Subnet....') - subnet_id = openstack_utils.create_neutron_subnet( - neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR, - network_id) - if not subnet_id: - return False - logger.debug("Subnet '%s' created successfully" % subnet_id) - logger.debug('Creating Router...') - router_id = openstack_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...') - - if not openstack_utils.add_interface_router(neutron, router_id, - subnet_id): - return False - logger.debug("Interface added successfully.") - - logger.debug('Adding gateway to router...') - if not openstack_utils.add_gateway_router(neutron, router_id): - return False - logger.debug("Gateway added successfully.") - - network_dic = {'net_id': network_id, - 'subnet_id': subnet_id, - 'router_id': router_id} - return network_dic - - def create_security_group(neutron_client): sg_id = openstack_utils.get_security_group_id(neutron_client, SECGROUP_NAME) @@ -286,7 +232,12 @@ def main(): logger.debug("Image '%s' with ID=%s created successfully." % (GLANCE_IMAGE_NAME, image_id)) - network_dic = create_private_neutron_net(neutron_client) + network_dic = openstack_utils.create_network_full(logger, + neutron_client, + PRIVATE_NET_NAME, + PRIVATE_SUBNET_NAME, + ROUTER_NAME, + PRIVATE_SUBNET_CIDR) if not network_dic: logger.error( "There has been a problem when creating the neutron network") @@ -346,7 +297,7 @@ def main(): logger.info("Instance '%s' is ACTIVE." % NAME_VM_1) # Retrieve IP of first VM - test_ip = vm1.networks.get(NEUTRON_PRIVATE_NET_NAME)[0] + test_ip = vm1.networks.get(PRIVATE_NET_NAME)[0] logger.debug("Instance '%s' got %s" % (NAME_VM_1, test_ip)) # boot VM 2 diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index 2ae2842d4..fc89fd2b8 100644 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -445,6 +445,62 @@ def remove_gateway_router(neutron_client, router_id): return False +def create_network_full(logger, + neutron_client, + net_name, + subnet_name, + router_name, + cidr): + + # Check if the network already exists + network_id = get_network_id(neutron_client, net_name) + subnet_id = get_subnet_id(neutron_client, subnet_name) + router_id = get_router_id(neutron_client, router_name) + + if network_id != '' and subnet_id != '' and router_id != '': + logger.info("A network with name '%s' already exists..." % net_name) + else: + neutron_client.format = 'json' + logger.info('Creating neutron network %s...' % net_name) + network_id = create_neutron_net(neutron_client, net_name) + + if not network_id: + return False + + logger.debug("Network '%s' created successfully" % network_id) + logger.debug('Creating Subnet....') + subnet_id = create_neutron_subnet(neutron_client, subnet_name, + cidr, network_id) + if not subnet_id: + return False + + logger.debug("Subnet '%s' created successfully" % subnet_id) + logger.debug('Creating Router...') + router_id = create_neutron_router(neutron_client, router_name) + + if not router_id: + return False + + logger.debug("Router '%s' created successfully" % router_id) + logger.debug('Adding router to subnet...') + + if not add_interface_router(neutron_client, router_id, subnet_id): + return False + + logger.debug("Interface added successfully.") + + logger.debug('Adding gateway to router...') + if not add_gateway_router(neutron_client, router_id): + return False + + logger.debug("Gateway added successfully.") + + network_dic = {'net_id': network_id, + 'subnet_id': subnet_id, + 'router_id': router_id} + return network_dic + + # ********************************************* # SEC GROUPS # ********************************************* |