diff options
23 files changed, 652 insertions, 530 deletions
diff --git a/CI/__init__.py b/CI/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/CI/__init__.py diff --git a/CI/testcases.yaml b/CI/testcases.yaml index 1a71f91a1..42458bbef 100644 --- a/CI/testcases.yaml +++ b/CI/testcases.yaml @@ -1,117 +1,196 @@ -healthcheck: - order: 0 - description : | - This is the optional healthcheck - that can provided by the installer - or the internal in functest - testcases: - healthcheck: - installer: any - sdn: any - feat: any - mode: any -smoke: - order: 1 - description : | - This is the set of basic functest - tests and smoke tempest in serial mode. - testcases: - vping_ssh: - installer: any - sdn: any - feat: any - mode: any +tiers: + - + name: healthcheck + order: 0 + ci: daily + description : >- + This is the first tier to be executed to verify the basic + operations in the VIM. + testcases: + - + name: healthcheck + description: >- + This test case verifies the basic OpenStack services like + Keystone, Glance, Cinder, Neutron and Nova. - vping_userdata: - installer: any - sdn: any - feat: any - mode: any + dependencies: + installer: '' + scenario: '' - tempest_smoke_serial: - installer: any - sdn: any - feat: any - mode: any + - + name: smoke + order: 1 + ci: daily + description : >- + This is the second tier in Functest and consist of a set of basic + Functional tests to validate the OpenStack deployment. + testcases: + - + name: vping_ssh + description: |- + This test case verifies: + ····1) SSH to an instance using floating IPs over the public network. + ····2) Connectivity between 2 instances over a private network. + dependencies: + installer: '' + scenario: '^((?!bgpvpn).)*$' - rally_smoke: - installer: any - sdn: any - feat: any - mode: any + - + name: vping_userdata + description: |- + This test case verifies: + ····1) Boot a VM with given userdata. + ····2) Connectivity between 2 instances over a private network. + dependencies: + installer: '' + scenario: '' - security_groups: - installer: any - sdn: any - feat: any - mode: any -sdn_suites: - order: 2 - description : | - test cases for the SDN controllers - testcases: - odl: - installer: any - sdn: odl_l2|odl_l3 - feat: any - mode: any - onos: - installer: any - sdn: onos - feat: any - mode: any - ovno: - installer: any - sdn: ocl - feat: any - mode: any -features: - order: 4 - description : | - test from feature projects integrated in functest - testcases: - promise: - installer: fuel|joid - sdn: any - feat: any - mode: any - sdnvpn: - installer: fuel|apex - sdn: odl_l2 - feat: bgpvpn - mode: any - policy-test: - installer: any - sdn: odl_l2|odl_l3 - feat: any - mode: any -tempest: - order: 5 - description : | - this is the execution of the full tempest suite in parallel - testcases: - tempest_full_parallel: - installer: any - sdn: any - feat: any - mode: any -rally: - order: 6 - description : | - Full Rally suite - testcases: - tempest_full_parallel: - installer: any - sdn: any - feat: any - mode: any -vnf: - order: 7 - description : | - collection of VNF test cases - testcases: - vims: - installer: any - sdn: any - feat: any - mode: any
\ No newline at end of file + - + name: tempest_smoke_serial + description: >- + This test case runs the smoke subset of the OpenStack + Tempest suite. The list of test cases is generated by + Tempest automatically and depend on the parameters of + the OpenStack deplopyment. + dependencies: + installer: '' + scenario: '' + + - + name: rally_sanity + description: >- + This test case runs a sub group of tests of the OpenStack + Rally suite in smoke mode. + dependencies: + installer: '' + scenario: '' + + - + name: security_groups + description: >- + This test case verifies the functionality of the OpenStack + security groups and that the port rules created are + fullfilled. + dependencies: + installer: '' + scenario: '' + + - + name: sdn_suites + order: 2 + ci: daily + description : >- + This tier contains the test suites corresponding to the different + SDN Controllers existing in OPNFV. + testcases: + - + name: odl + description: >- + Test Suite for the OpenDaylight SDN Controller. It integrates + some test suites from upstream using Robot as the test + framework. + dependencies: + installer: '' + scenario: 'odl' + + - + name: onos + description: >- + Test Suite for the ONOS SDN Controller. It integrates + some test suites from upstream using TestON as the test + framework. + dependencies: + installer: '' + scenario: 'onos' + + - + name: ovno + description: >- + Test Suite for the Open Contrail SDN Controller. + framework. + dependencies: + installer: '' + scenario: 'ocl' + + - + name: features + order: 3 + ci: daily + description : >- + This tier contains the test suites from feature projects + integrated in functest + testcases: + - + name: promise + description: >- + Test suite from Promise project. + dependencies: + installer: '(fuel)|(joid)' + scenario: '' + + - + name: doctor + description: >- + Test suite from Dcotor project. + dependencies: + installer: 'apex' + scenario: '' + + - + name: sdnvpn + description: >- + Test suite from SDNVPN project. + dependencies: + installer: '(fuel)|(apex)' + scenario: 'bgpvpn' + + - + name: tempest + order: 4 + ci: weekly + description : >- + This tier contains the test suites from feature projects + integrated in functest + testcases: + - + name: tempest_full_parallel + description: >- + This test case runs the full set of the OpenStack + Tempest suite. The list of test cases is generated by + Tempest automatically and depend on the parameters of + the OpenStack deplopyment. + dependencies: + installer: '' + scenario: '' + + - + name: rally + order: 5 + ci: weekly + description : >- + This tier contains the Rally suite from the OpenStack community. + testcases: + - + name: rally_full + description: >- + This test case runs the full suite of scenarios of the OpenStack + Rally suite using several threads and iterations. + dependencies: + installer: '' + scenario: '' + + - + name: vnf + order: 6 + ci: weekly + description : >- + This tier contains a collection of VNF test cases. + testcases: + - + name: vims + description: >- + This test case deploys an OpenSource vIMS solution from Clearwater + using the Cloudify orchestrator. It also runs some signaling traffic. + dependencies: + installer: '' + scenario: '(ocl)|(nosdn)|^(os-odl)((?!bgpvpn).)*$' diff --git a/CI/tier_builder.py b/CI/tier_builder.py new file mode 100644 index 000000000..e66e97a38 --- /dev/null +++ b/CI/tier_builder.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# jose.lausuch@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# + +import yaml + +import tier_handler as th + + +class TierBuilder: + def __init__(self, ci_installer, ci_scenario, testcases_file): + self.ci_installer = ci_installer + self.ci_scenario = ci_scenario + self.testcases_file = testcases_file + self.dic_tier_array = None + self.tier_objects = [] + self.testcases_yaml = None + self.generate_tiers() + + def read_test_yaml(self): + with open(self.testcases_file) as f: + self.testcases_yaml = yaml.safe_load(f) + + self.dic_tier_array = [] + for tier in self.testcases_yaml.get("tiers"): + self.dic_tier_array.append(tier) + + def generate_tiers(self): + if self.dic_tier_array is None: + self.read_test_yaml() + + del self.tier_objects[:] + for dic_tier in self.dic_tier_array: + tier = th.Tier(name=dic_tier['name'], + order=dic_tier['order'], + ci=dic_tier['ci'], + description=dic_tier['description']) + + for dic_testcase in dic_tier['testcases']: + installer = dic_testcase['dependencies']['installer'] + scenario = dic_testcase['dependencies']['scenario'] + dep = th.Dependency(installer, scenario) + + testcase = th.TestCase(name=dic_testcase['name'], + dependency=dep, + description=dic_testcase['description']) + if testcase.is_compatible(self.ci_installer, self.ci_scenario): + tier.add_test(testcase) + + self.tier_objects.append(tier) + + def __str__(self): + output = "" + for i in range(0, len(self.tier_objects)): + output += str(self.tier_objects[i]) + "\n" + return output diff --git a/CI/tier_handler.py b/CI/tier_handler.py new file mode 100644 index 000000000..0b7559498 --- /dev/null +++ b/CI/tier_handler.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# jose.lausuch@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# + + +import re + + +class Tier: + def __init__(self, name, order, ci, description=""): + self.tests_array = [] + self.name = name + self.order = order + self.ci = ci + self.description = description + + def add_test(self, testcase): + self.tests_array.append(testcase) + + def get_tests(self): + array_str = [] + for test in self.tests_array: + array_str.append(test.name) + return array_str + + def __str__(self): + return ("Tier info:\n" + " Name: " + self.name + "\n" + " Description: " + self.description + "\n" + " Order: " + str(self.order) + "\n" + " Test cases: " + str(self.get_tests()) + "\n") + + +class TestCase: + def __init__(self, name, dependency, description=""): + self.name = name + self.dependency = dependency + self.description = description + + def is_compatible(self, ci_installer, ci_scenario): + if re.search(self.dependency.get_installer(), ci_installer) is None: + return False + + if re.search(self.dependency.get_scenario(), ci_scenario) is None: + return False + + return True + + def __str__(self): + return ("Testcase info:\n" + " Name: " + self.name + "\n" + " Description: " + self.description + "\n" + " " + str(self.dependency) + "\n") + + +class Dependency: + def __init__(self, installer, scenario): + self.installer = installer + self.scenario = scenario + + def get_installer(self): + return self.installer + + def get_scenario(self): + return self.scenario + + def __str__(self): + return ("Dependency info:\n" + " installer: " + self.installer + "\n" + " scenario: " + self.scenario + "\n") diff --git a/CI/tier_manager.py b/CI/tier_manager.py deleted file mode 100644 index cd1512319..000000000 --- a/CI/tier_manager.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# -# jose.lausuch@ericsson.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -# - - -class Tier: - def __init__(self, name, description, order): - self.tests_array = [] - self.name = name - self.description = description - self.order = order - - def add_test(self, testcase): - self.tests_array.append(testcase) - - def get_tests(self): - array_str = [] - for test in self.tests_array: - array_str.append(test.name) - return array_str - - def __str__(self): - return "Tier info:\n" + \ - "\tName: " + self.name + "\n" + \ - "\tDescription: " + self.description + "\n" + \ - "\tOrder: " + self.order + "\n" + \ - "\tTest cases: " + str(self.get_tests()) + "\n" - - -class Testcase: - def __init__(self, name, description, dependency): - self.name = name - self.description = description - self.dependency = dependency - - def __str__(self): - return "Testcase info:\n" + \ - "\tName: " + self.name + "\n" + \ - "\tName: " + self.name + "\n" + \ - "\tDescription: " + self.description + "\n" + \ - "\tDependencies: " + str(self.dependency) + "\n" - - -class Dependency: - def __init__(self, installer, sdn, feature, mode): - self.installer = installer - self.sdn = sdn - self.feature = feature - self.mode = mode - - def __str__(self): - return "Dependency info:\n" + \ - "\t" + self.installer + " os-[" + self.sdn + "]-[" + \ - self.feature + "]-[" + self.mode + "]" + "\n" + \ - "\t\t- installer: " + self.installer + "\n" + \ - "\t\t- sdn Controller: " + self.sdn + "\n" + \ - "\t\t- feature: " + self.feature + "\n" + \ - "\t\t- mode: " + self.mode + "\n" diff --git a/docker/run_tests.sh b/docker/run_tests.sh index c258136da..1ef90b24e 100755 --- a/docker/run_tests.sh +++ b/docker/run_tests.sh @@ -191,7 +191,7 @@ bgpvpn = True" >> /etc/tempest/tempest.conf ;; esac - if [[ -n $clean_flag ]]; then + if [ $clean == "true" ]; then clean_openstack fi } diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py index 15bb73c91..77de092e4 100644 --- a/testcases/Controllers/ONOS/Teston/CI/adapters/client.py +++ b/testcases/Controllers/ONOS/Teston/CI/adapters/client.py @@ -36,8 +36,8 @@ class client(environment): self.ChangeTestCasePara(testname, self.masterusername, self.masterpassword) runhandle = handle - runtest = self.home + "/OnosSystemTest/TestON/bin/cli.py run " + \ - testname + runtest = (self.home + "/OnosSystemTest/TestON/bin/cli.py run " + + testname) runhandle.sendline(runtest) circletime = 0 lastshowscreeninfo = '' diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py index 4fc636aba..49f7f9632 100644 --- a/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py +++ b/testcases/Controllers/ONOS/Teston/CI/adapters/environment.py @@ -136,8 +136,8 @@ class environment(connection): print "try to connect " + str(host) result = self.CheckSshNoPasswd(host) if not result: - print "ssh lgin failed,try to copy master publickey" + \ - "to agent " + str(host) + print ("ssh lgin failed,try to copy master publickey" + + "to agent " + str(host)) self.CopyPublicKey(host) self.OnosPushKeys(handle, "onos-push-keys " + self.OCT, masterpass) self.OnosPushKeys(handle, "onos-push-keys " + self.OC1, agentpass) @@ -201,18 +201,18 @@ class environment(connection): filepath = '/root/' else: filepath = '/home/' + self.masterusername + '/' - filepath = filepath + "OnosSystemTest/TestON/tests/" \ - + testcase + "/" + testcase + ".topo" + filepath = (filepath + "OnosSystemTest/TestON/tests/" + + testcase + "/" + testcase + ".topo") line = open(filepath, 'r').readlines() lenall = len(line) - 1 for i in range(lenall - 2): if("localhost" in line[i]) or ("OCT" in line[i]): line[i + 1] = re.sub(">\w+", ">" + user, line[i + 1]) line[i + 2] = re.sub(">\w+", ">" + password, line[i + 2]) - if "OC1" in line[i] or "OC2" in line[i] or "OC3" in line[i] or \ - "OCN" in line[i] or "OCN2" in line[i]: - line[i + 1] = re.sub(">\w+", ">root", line[i + 1]) - line[i + 2] = re.sub(">\w+", ">root", line[i + 2]) + if ("OC1" in line[i] or "OC2" in line[i] or "OC3" in line[i] or + "OCN" in line[i] or "OCN2" in line[i]): + line[i + 1] = re.sub(">\w+", ">root", line[i + 1]) + line[i + 2] = re.sub(">\w+", ">root", line[i + 2]) NewFile = open(filepath, 'w') NewFile.writelines(line) NewFile.close diff --git a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py index a4591ac72..d4a145566 100644 --- a/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py +++ b/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py @@ -67,8 +67,8 @@ class foundation: get("onoscli_username")) self.agentpassword = str(functest_yaml.get("ONOS").get("general"). get("onoscli_password")) - self.runtimeout = functest_yaml.get("ONOS").\ - get("general").get("runtimeout") + self.runtimeout = functest_yaml.get("ONOS").get("general").get( + "runtimeout") self.OCT = str(functest_yaml.get("ONOS").get("environment").get("OCT")) self.OC1 = str(functest_yaml.get("ONOS").get("environment").get("OC1")) self.OC2 = str(functest_yaml.get("ONOS").get("environment").get("OC2")) diff --git a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py index 8186e7da6..f6b7f61c7 100644 --- a/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py +++ b/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py @@ -47,10 +47,10 @@ f.close() # onos parameters TEST_DB = functest_yaml.get("results").get("test_db_url") -ONOS_REPO_PATH = functest_yaml.get("general").\ - get("directories").get("dir_repos") -ONOS_CONF_DIR = functest_yaml.get("general").\ - get("directories").get("dir_functest_conf") +ONOS_REPO_PATH = functest_yaml.get("general").get("directories").get( + "dir_repos") +ONOS_CONF_DIR = functest_yaml.get("general").get("directories").get( + "dir_functest_conf") REPO_PATH = ONOS_REPO_PATH + '/functest/' if not os.path.exists(REPO_PATH): logger.error("Functest repository directory not found '%s'" % REPO_PATH) diff --git a/testcases/SECTests/OpenSCAP.py b/testcases/SECTests/OpenSCAP.py index 0ab0ce3d7..40d155c1a 100644 --- a/testcases/SECTests/OpenSCAP.py +++ b/testcases/SECTests/OpenSCAP.py @@ -147,12 +147,12 @@ def run_scanner(): parserout.password, com) elif args['which'] == 'oval': - com = '{0} oval eval --results {1}/{2}' + \ - ' --report {1}/{3} {4}'.format(oscap, - tmpdir.rstrip(), - parserout.results, - parserout.report, - parserout.secpolicy) + com = ('{0} oval eval --results {1}/{2}' + + ' --report {1}/{3} {4}'.format(oscap, + tmpdir.rstrip(), + parserout.results, + parserout.report, + parserout.secpolicy)) connect = connect.connectionManager(parserout.host, parserout.user, parserout.password, diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py index c5cfb07a8..7c82a4b93 100644 --- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py +++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py @@ -270,10 +270,8 @@ def remove_ports(neutron_client, ports, network_ids): elif port['device_owner'] == 'network:router_interface': logger.debug("Detaching port %s (subnet %s) from router %s ..." % (port_id, subnet_id, router_id)) - if openstack_utils.\ - remove_interface_router(neutron_client, - router_id, - subnet_id): + if openstack_utils.remove_interface_router( + neutron_client, router_id, subnet_id): time.sleep(5) # leave 5 seconds to detach logger.debug(" > Done!") else: diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index 562c2e58e..7d37df901 100755 --- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py @@ -99,8 +99,8 @@ with open("/home/opnfv/functest/conf/config_functest.yaml") as f: f.close() HOME = os.environ['HOME'] + "/" -SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general"). \ - get("directories").get("dir_rally_scn") +SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general").get( + "directories").get("dir_rally_scn") TEMPLATE_DIR = SCENARIOS_DIR + "scenario/templates" SUPPORT_DIR = SCENARIOS_DIR + "scenario/support" @@ -110,22 +110,22 @@ TENANTS_AMOUNT = 3 ITERATIONS_AMOUNT = 10 CONCURRENCY = 4 -RESULTS_DIR = functest_yaml.get("general").get("directories"). \ - get("dir_rally_res") -TEMPEST_CONF_FILE = functest_yaml.get("general").get("directories"). \ - get("dir_results") + '/tempest/tempest.conf' +RESULTS_DIR = functest_yaml.get("general").get("directories").get( + "dir_rally_res") +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") - -GLANCE_IMAGE_NAME = functest_yaml.get("general"). \ - get("openstack").get("image_name") -GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \ - get("openstack").get("image_file_name") -GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \ - get("openstack").get("image_disk_format") -GLANCE_IMAGE_PATH = functest_yaml.get("general"). \ - get("directories").get("dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME +PRIVATE_NETWORK = functest_yaml.get("general").get("openstack").get( + "neutron_private_net_name") + +GLANCE_IMAGE_NAME = functest_yaml.get("general").get("openstack").get( + "image_name") +GLANCE_IMAGE_FILENAME = functest_yaml.get("general").get("openstack").get( + "image_file_name") +GLANCE_IMAGE_FORMAT = functest_yaml.get("general").get("openstack").get( + "image_disk_format") +GLANCE_IMAGE_PATH = functest_yaml.get("general").get("directories").get( + "dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME CINDER_VOLUME_TYPE_NAME = "volume_test" @@ -188,9 +188,9 @@ def task_succeed(json_raw): def live_migration_supported(): config = iniparse.ConfigParser() - if config.read(TEMPEST_CONF_FILE) and \ - config.has_section('compute-feature-enabled') and \ - config.has_option('compute-feature-enabled', 'live_migration'): + 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 False @@ -242,12 +242,12 @@ def get_output(proc, test_name): if args.verbose: result += line else: - if "Load duration" in line or \ - "started" in line or \ - "finished" in line or \ - " Preparing" in line or \ - "+-" in line or \ - "|" in line: + if ("Load duration" in line or + "started" in line or + "finished" in line or + " Preparing" in line or + "+-" in line or + "|" in line): result += line elif "test scenario" in line: result += "\n" + line @@ -255,13 +255,13 @@ def get_output(proc, test_name): result += line + "\n\n" # parse output for summary report - if "| " in line and \ - "| action" not in line and \ - "| Starting" not in line and \ - "| Completed" not in line and \ - "| ITER" not in line and \ - "| " not in line and \ - "| total" not in line: + if ("| " in line and + "| action" not in line and + "| Starting" not in line and + "| Completed" not in line and + "| ITER" not in line and + "| " not in line and + "| total" not in line): nb_tests += 1 elif "| total" in line: percentage = ((line.split('|')[8]).strip(' ')).strip('%') @@ -316,9 +316,9 @@ def run_task(test_name): logger.debug('Scenario fetched from : {}'.format(test_file_name)) - cmd_line = "rally task start --abort-on-sla-failure " + \ - "--task {} ".format(task_file) + \ - "--task-args \"{}\" ".format(build_task_args(test_name)) + cmd_line = ("rally task start --abort-on-sla-failure " + + "--task {} ".format(task_file) + + "--task-args \"{}\" ".format(build_task_args(test_name))) logger.debug('running command line : {}'.format(cmd_line)) p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, @@ -385,9 +385,8 @@ def main(): neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = openstack_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) - glance_endpoint = keystone_client.\ - service_catalog.url_for(service_type='image', - endpoint_type='publicURL') + glance_endpoint = keystone_client.service_catalog.url_for( + service_type='image', endpoint_type='publicURL') glance_client = glanceclient.Client(1, glance_endpoint, token=keystone_client.auth_token) creds_cinder = openstack_utils.get_credentials("cinder") @@ -402,8 +401,8 @@ def main(): volume_types = openstack_utils.list_volume_types(cinder_client, private=False) if not volume_types: - volume_type = openstack_utils.\ - create_volume_type(cinder_client, CINDER_VOLUME_TYPE_NAME) + volume_type = openstack_utils.create_volume_type( + cinder_client, CINDER_VOLUME_TYPE_NAME) if not volume_type: logger.error("Failed to create volume type...") exit(-1) @@ -442,17 +441,17 @@ def main(): logger.debug("Test name: " + args.test_name) run_task(args.test_name) - report = "\n"\ - " "\ - "\n"\ - " Rally Summary Report\n"\ - "\n"\ - "+===================+============+===============+===========+"\ - "\n"\ - "| Module | Duration | nb. Test Run | Success |"\ - "\n"\ - "+===================+============+===============+===========+"\ - "\n" + report = ("\n" + " " + "\n" + " Rally Summary Report\n" + "\n" + "+===================+============+===============+===========+" + "\n" + "| Module | Duration | nb. Test Run | Success |" + "\n" + "+===================+============+===============+===========+" + "\n") payload = [] # for each scenario we draw a row for the table @@ -469,10 +468,11 @@ def main(): total_nb_tests += int(s['nb_tests']) success = "{0:<10}".format(str(s['success']) + '%') total_success += float(s['success']) - report += "" + \ - "| " + name + " | " + duration + " | " + \ - nb_tests + " | " + success + "|\n" + \ - "+-------------------+------------+---------------+-----------+\n" + report += ("" + + "| " + name + " | " + duration + " | " + + nb_tests + " | " + success + "|\n" + + "+-------------------+------------" + "+---------------+-----------+\n") payload.append({'module': name, 'details': {'duration': s['overall_duration'], 'nb tests': s['nb_tests'], @@ -485,8 +485,8 @@ def main(): total_success_str = "{0:<10}".format(str(total_success) + '%') report += "+===================+============+===============+===========+" report += "\n" - report += "| TOTAL: | " + total_duration_str2 + " | " + \ - total_nb_tests_str + " | " + total_success_str + "|\n" + report += ("| TOTAL: | " + total_duration_str2 + " | " + + total_nb_tests_str + " | " + total_success_str + "|\n") report += "+===================+============+===============+===========+" report += "\n" diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py index b2240c9c2..d8c477b37 100644 --- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py +++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py @@ -23,6 +23,7 @@ import shutil import subprocess import time import yaml +import ConfigParser import keystoneclient.v2_0.client as ksclient from neutronclient.v2_0 import client as neutronclient @@ -78,25 +79,22 @@ f.close() TEST_DB = functest_yaml.get("results").get("test_db_url") MODE = "smoke" -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") -RESULTS_DIR = functest_yaml.get("general").\ - get("directories").get("dir_results") +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") +RESULTS_DIR = functest_yaml.get("general").get("directories").get( + "dir_results") TEMPEST_RESULTS_DIR = RESULTS_DIR + '/tempest' -TEST_LIST_DIR = functest_yaml.get("general").\ - get("directories").get("dir_tempest_cases") +TEST_LIST_DIR = functest_yaml.get("general").get("directories").get( + "dir_tempest_cases") TEMPEST_LIST_FILE = REPO_PATH + TEST_LIST_DIR + 'test_list.txt' TEMPEST_DEFCORE = REPO_PATH + TEST_LIST_DIR + 'defcore_req.txt' @@ -198,8 +196,8 @@ def configure_tempest(mode): if deployment_uuid == "": logger.debug(" Rally deployment NOT found") return False - deployment_dir = RALLY_INSTALLATION_DIR + "/tempest/for-deployment-" + \ - deployment_uuid + deployment_dir = (RALLY_INSTALLATION_DIR + "/tempest/for-deployment-" + + deployment_uuid) logger.debug("Finding tempest.conf file...") tempest_conf_file = deployment_dir + "/tempest.conf" @@ -217,7 +215,9 @@ def configure_tempest(mode): cmd += "testr list-tests >" + TEMPEST_LIST_FILE + ";cd" functest_utils.execute_command(cmd, logger) - logger.debug(" Updating fixed_network_name...") + logger.debug("Updating selected tempest.conf parameters...") + config = ConfigParser.RawConfigParser() + config.read(tempest_conf_file) private_net_name = "" creds_neutron = openstack_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) @@ -226,24 +226,12 @@ def configure_tempest(mode): logger.error("No shared private networks found.") else: private_net_name = private_net['name'] - cmd = "crudini --set " + tempest_conf_file + \ - " compute fixed_network_name " + \ - private_net_name - functest_utils.execute_command(cmd, logger) - - logger.debug(" Updating non-admin credentials...") - cmd = "crudini --set " + tempest_conf_file + " identity tenant_name " \ - + TENANT_NAME - functest_utils.execute_command(cmd, logger) - cmd = "crudini --set " + tempest_conf_file + " identity username " \ - + USER_NAME - functest_utils.execute_command(cmd, logger) - cmd = "crudini --set " + tempest_conf_file + " identity password " \ - + USER_PASSWORD - functest_utils.execute_command(cmd, logger) - cmd = "sed -i 's/.*ssh_user_regex.*/ssh_user_regex = " + SSH_USER_REGEX + \ - "/' " + tempest_conf_file - functest_utils.execute_command(cmd, logger) + 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) + with open(tempest_conf_file, 'wb') as config_file: + config.write(config_file) # Copy tempest.conf to /home/opnfv/functest/results/tempest/ shutil.copyfile(tempest_conf_file, TEMPEST_RESULTS_DIR + '/tempest.conf') @@ -264,12 +252,12 @@ def run_tempest(OPTION): if CI_DEBUG == "true" or CI_DEBUG == "True": subprocess.call(cmd_line, shell=True, stderr=subprocess.STDOUT) else: - header = "Tempest environment:\n"\ - " Installer: %s\n Scenario: %s\n Node: %s\n Date: %s\n" % \ - (os.getenv('INSTALLER_TYPE', 'Unknown'), - os.getenv('DEPLOY_SCENARIO', 'Unknown'), - os.getenv('NODE_NAME', 'Unknown'), - time.strftime("%a %b %d %H:%M:%S %Z %Y")) + header = ("Tempest environment:\n" + " Installer: %s\n Scenario: %s\n Node: %s\n Date: %s\n" % + (os.getenv('INSTALLER_TYPE', 'Unknown'), + os.getenv('DEPLOY_SCENARIO', 'Unknown'), + os.getenv('NODE_NAME', 'Unknown'), + time.strftime("%a %b %d %H:%M:%S %Z %Y"))) f_stdout = open(TEMPEST_RESULTS_DIR + "/tempest.log", 'w+') f_stderr = open(TEMPEST_RESULTS_DIR + "/tempest-error.log", 'w+') diff --git a/testcases/config_functest.py b/testcases/config_functest.py index 6db2e2b1e..942805527 100755 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -20,8 +20,8 @@ from neutronclient.v2_0 import client as neutronclient actions = ['start', 'check', 'clean'] parser = argparse.ArgumentParser() -parser.add_argument("action", help="Possible actions are: \ - '{d[0]}|{d[1]}|{d[2]}' ".format(d=actions)) +parser.add_argument("action", help="Possible actions are: " + "'{d[0]}|{d[1]}|{d[2]}' ".format(d=actions)) parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") parser.add_argument("-f", "--force", help="Force", action="store_true") args = parser.parse_args() @@ -57,40 +57,40 @@ f.close() """ global variables """ # Directories -RALLY_DIR = FUNCTEST_REPO + functest_yaml.get("general").\ - get("directories").get("dir_rally") -RALLY_REPO_DIR = functest_yaml.get("general").\ - get("directories").get("dir_repo_rally") -RALLY_INSTALLATION_DIR = functest_yaml.get("general").\ - get("directories").get("dir_rally_inst") -RALLY_RESULT_DIR = functest_yaml.get("general").\ - get("directories").get("dir_rally_res") -TEMPEST_REPO_DIR = functest_yaml.get("general").\ - get("directories").get("dir_repo_tempest") -VPING_DIR = FUNCTEST_REPO + functest_yaml.\ - get("general").get("directories").get("dir_vping") -ODL_DIR = FUNCTEST_REPO + functest_yaml.\ - get("general").get("directories").get("dir_odl") -DATA_DIR = functest_yaml.get("general").\ - get("directories").get("dir_functest_data") +RALLY_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( + "directories").get("dir_rally") +RALLY_REPO_DIR = functest_yaml.get("general").get( + "directories").get("dir_repo_rally") +RALLY_INSTALLATION_DIR = functest_yaml.get("general").get( + "directories").get("dir_rally_inst") +RALLY_RESULT_DIR = functest_yaml.get("general").get( + "directories").get("dir_rally_res") +TEMPEST_REPO_DIR = functest_yaml.get("general").get( + "directories").get("dir_repo_tempest") +VPING_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( + "directories").get("dir_vping") +ODL_DIR = FUNCTEST_REPO + functest_yaml.get("general").get( + "directories").get("dir_odl") +DATA_DIR = functest_yaml.get("general").get( + "directories").get("dir_functest_data") # Tempest/Rally configuration details DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name") # Image (cirros) -IMAGE_FILE_NAME = functest_yaml.get("general").\ - get("openstack").get("image_file_name") +IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get( + "image_file_name") IMAGE_PATH = DATA_DIR + "/" + IMAGE_FILE_NAME # NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general"). \ - get("openstack").get("neutron_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general"). \ - get("openstack").get("neutron_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general"). \ - get("openstack").get("neutron_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("general"). \ - get("openstack").get("neutron_router_name") +NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general").get( + "openstack").get("neutron_private_net_name") +NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general").get( + "openstack").get("neutron_private_subnet_name") +NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general").get( + "openstack").get("neutron_private_subnet_cidr") +NEUTRON_ROUTER_NAME = functest_yaml.get("general").get( + "openstack").get("neutron_router_name") creds_neutron = openstack_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) @@ -205,8 +205,8 @@ def install_rally(): functest_utils.execute_command(cmd, logger) logger.debug("Installing tempest from existing repo...") - cmd = "rally verify install --source " + TEMPEST_REPO_DIR + \ - " --system-wide" + cmd = ("rally verify install --source " + TEMPEST_REPO_DIR + + " --system-wide") functest_utils.execute_command(cmd, logger) cmd = "rally deployment check" @@ -248,8 +248,8 @@ def check_rally(): def create_private_neutron_net(neutron): neutron.format = 'json' logger.info("Creating network '%s'..." % NEUTRON_PRIVATE_NET_NAME) - network_id = openstack_utils. \ - create_neutron_net(neutron, NEUTRON_PRIVATE_NET_NAME) + network_id = openstack_utils.create_neutron_net( + neutron, NEUTRON_PRIVATE_NET_NAME) if not network_id: return False @@ -263,17 +263,15 @@ def create_private_neutron_net(neutron): logger.info("Updating neutron network '%s' failed" % network_id) logger.info("Creating Subnet....") - subnet_id = openstack_utils. \ - create_neutron_subnet(neutron, - NEUTRON_PRIVATE_SUBNET_NAME, - NEUTRON_PRIVATE_SUBNET_CIDR, - network_id) + 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.info("Creating Router...") - router_id = openstack_utils. \ - create_neutron_router(neutron, NEUTRON_ROUTER_NAME) + router_id = openstack_utils.create_neutron_router(neutron, + NEUTRON_ROUTER_NAME) if not router_id: return False diff --git a/testcases/features/promise.py b/testcases/features/promise.py index 72c5ecb3f..794841fbf 100644 --- a/testcases/features/promise.py +++ b/testcases/features/promise.py @@ -53,12 +53,12 @@ FLAVOR_RAM = functest_yaml.get('promise').get('general').get('flavor_ram') FLAVOR_DISK = functest_yaml.get('promise').get('general').get('flavor_disk') -GLANCE_IMAGE_FILENAME = functest_yaml.get('general'). \ - get('openstack').get('image_file_name') -GLANCE_IMAGE_FORMAT = functest_yaml.get('general'). \ - get('openstack').get('image_disk_format') -GLANCE_IMAGE_PATH = functest_yaml.get('general'). \ - get('directories').get('dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME +GLANCE_IMAGE_FILENAME = functest_yaml.get('general').get('openstack').get( + 'image_file_name') +GLANCE_IMAGE_FORMAT = functest_yaml.get('general').get('openstack').get( + 'image_disk_format') +GLANCE_IMAGE_PATH = functest_yaml.get('general').get('directories').get( + 'dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME """ logging configuration """ logger = logging.getLogger('Promise') @@ -141,9 +141,8 @@ def main(): "project_id": TENANT_NAME, }) - glance_endpoint = keystone.\ - service_catalog.url_for(service_type='image', - endpoint_type='publicURL') + glance_endpoint = keystone.service_catalog.url_for( + service_type='image', endpoint_type='publicURL') glance = glclient.Client(1, glance_endpoint, token=keystone.auth_token) nova = nvclient.Client("2", **nv_creds) diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index ded740e0d..8eba43be8 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -160,10 +160,10 @@ 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', '%s', '%s')]:" \ - % (db_url, project, case_name, pod_name, version, - scenario, criteria, 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/openstack_utils.py b/testcases/openstack_utils.py index 32eadd8af..ff3968d67 100644 --- a/testcases/openstack_utils.py +++ b/testcases/openstack_utils.py @@ -68,8 +68,8 @@ def get_credentials(service): "ca_file": cacert}) creds.update({"insecure": "True", "https_insecure": "True"}) if not os.path.isfile(cacert): - print "WARNING: The 'OS_CACERT' environment variable is " + \ - "set to %s but the file does not exist." % cacert + print ("WARNING: The 'OS_CACERT' environment variable is " + + "set to %s but the file does not exist." % cacert) return creds @@ -90,8 +90,8 @@ def get_instance_status(nova_client, instance): instance = nova_client.servers.get(instance.id) return instance.status except: - # print "Error [get_instance_status(nova_client, '%s')]:" % \ - # str(instance), e + # print ("Error [get_instance_status(nova_client, '%s')]:" % + # str(instance), e) return None @@ -100,8 +100,8 @@ def get_instance_by_name(nova_client, instance_name): instance = nova_client.servers.find(name=instance_name) return instance except Exception, e: - print "Error [get_instance_by_name(nova_client, '%s')]:" % \ - instance_name, e + print ("Error [get_instance_by_name(nova_client, '%s')]:" % + instance_name, e) return None @@ -138,8 +138,8 @@ def create_flavor(nova_client, flavor_name, ram, disk, vcpus): try: flavor = nova_client.flavors.create(flavor_name, ram, vcpus, disk) except Exception, e: - print "Error [create_flavor(nova_client, '%s', '%s', '%s', "\ - "'%s')]:" % (flavor_name, ram, disk, vcpus), e + print ("Error [create_flavor(nova_client, '%s', '%s', '%s', " + "'%s')]:" % (flavor_name, ram, disk, vcpus), e) return None return flavor.id @@ -162,8 +162,8 @@ def add_floating_ip(nova_client, server_id, floatingip_id): nova_client.servers.add_floating_ip(server_id, floatingip_id) return True except Exception, e: - print "Error [add_floating_ip(nova_client, '%s', '%s')]:" % \ - (server_id, floatingip_id), e + print ("Error [add_floating_ip(nova_client, '%s', '%s')]:" % + (server_id, floatingip_id), e) return False @@ -181,8 +181,8 @@ def delete_floating_ip(nova_client, floatingip_id): nova_client.floating_ips.delete(floatingip_id) return True except Exception, e: - print "Error [delete_floating_ip(nova_client, '%s')]:" \ - % floatingip_id, e + print ("Error [delete_floating_ip(nova_client, '%s')]:" % + floatingip_id, e) return False @@ -295,8 +295,8 @@ def create_neutron_subnet(neutron_client, name, cidr, net_id): subnet = neutron_client.create_subnet(body=json_body) return subnet['subnets'][0]['id'] except Exception, e: - print "Error [create_neutron_subnet(neutron_client, '%s', '%s', "\ - "'%s')]:" % (name, cidr, net_id), e + print ("Error [create_neutron_subnet(neutron_client, '%s', '%s', " + "'%s')]:" % (name, cidr, net_id), e) return False @@ -321,8 +321,8 @@ def create_neutron_port(neutron_client, name, network_id, ip): port = neutron_client.create_port(body=json_body) return port['port']['id'] except Exception, e: - print "Error [create_neutron_port(neutron_client, '%s', '%s', "\ - "'%s')]:" % (name, network_id, ip), e + print ("Error [create_neutron_port(neutron_client, '%s', '%s', " + "'%s')]:" % (name, network_id, ip), e) return False @@ -332,8 +332,8 @@ def update_neutron_net(neutron_client, network_id, shared=False): neutron_client.update_network(network_id, body=json_body) return True except Exception, e: - print "Error [update_neutron_net(neutron_client, '%s', '%s')]:" % \ - (network_id, str(shared)), e + print ("Error [update_neutron_net(neutron_client, '%s', '%s')]:" % + (network_id, str(shared)), e) return False @@ -346,8 +346,8 @@ def update_neutron_port(neutron_client, port_id, device_owner): body=json_body) return port['port']['id'] except Exception, e: - print "Error [update_neutron_port(neutron_client, '%s', '%s')]:" % \ - (port_id, device_owner), e + print ("Error [update_neutron_port(neutron_client, '%s', '%s')]:" % + (port_id, device_owner), e) return False @@ -357,8 +357,8 @@ def add_interface_router(neutron_client, router_id, subnet_id): neutron_client.add_interface_router(router=router_id, body=json_body) return True except Exception, e: - print "Error [add_interface_router(neutron_client, '%s', '%s')]:" % \ - (router_id, subnet_id), e + print ("Error [add_interface_router(neutron_client, '%s', '%s')]:" % + (router_id, subnet_id), e) return False @@ -369,8 +369,8 @@ def add_gateway_router(neutron_client, router_id): neutron_client.add_gateway_router(router_id, router_dict) return True except Exception, e: - print "Error [add_gateway_router(neutron_client, '%s')]:" \ - % router_id, e + print ("Error [add_gateway_router(neutron_client, '%s')]:" % + router_id, e) return False @@ -379,8 +379,8 @@ def delete_neutron_net(neutron_client, network_id): neutron_client.delete_network(network_id) return True except Exception, e: - print "Error [delete_neutron_net(neutron_client, '%s')]:" \ - % network_id, e + print ("Error [delete_neutron_net(neutron_client, '%s')]:" % + network_id, e) return False @@ -389,8 +389,8 @@ def delete_neutron_subnet(neutron_client, subnet_id): neutron_client.delete_subnet(subnet_id) return True except Exception, e: - print "Error [delete_neutron_subnet(neutron_client, '%s')]:" \ - % subnet_id, e + print ("Error [delete_neutron_subnet(neutron_client, '%s')]:" % + subnet_id, e) return False @@ -399,8 +399,8 @@ def delete_neutron_router(neutron_client, router_id): neutron_client.delete_router(router=router_id) return True except Exception, e: - print "Error [delete_neutron_router(neutron_client, '%s')]:" % \ - router_id, e + print ("Error [delete_neutron_router(neutron_client, '%s')]:" % + router_id, e) return False @@ -420,8 +420,8 @@ def remove_interface_router(neutron_client, router_id, subnet_id): body=json_body) return True except Exception, e: - print "Error [remove_interface_router(neutron_client, '%s', '%s')]:" \ - % (router_id, subnet_id), e + print ("Error [remove_interface_router(neutron_client, '%s', '%s')]:" % + (router_id, subnet_id), e) return False @@ -430,8 +430,8 @@ def remove_gateway_router(neutron_client, router_id): neutron_client.remove_gateway_router(router_id) return True except Exception, e: - print "Error [remove_gateway_router(neutron_client, '%s')]:" \ - % router_id, e + print ("Error [remove_gateway_router(neutron_client, '%s')]:" % + router_id, e) return False @@ -465,8 +465,8 @@ def create_security_group(neutron_client, sg_name, sg_description): 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 + print ("Error [create_security_group(neutron_client, '%s', '%s')]:" % + (sg_name, sg_description), e) return False @@ -483,20 +483,20 @@ def create_secgroup_rule(neutron_client, sg_id, direction, protocol, '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" + 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 + 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 @@ -505,8 +505,8 @@ def add_secgroup_to_instance(nova_client, instance_id, secgroup_id): 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 + print ("Error [add_secgroup_to_instance(nova_client, '%s', '%s')]: " % + (instance_id, secgroup_id), e) return False @@ -521,8 +521,8 @@ def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota): body=json_body) return True except Exception, e: - print "Error [update_sg_quota(neutron_client, '%s', '%s', " \ - "'%s')]:" % (tenant_id, sg_quota, sg_rule_quota), e + print ("Error [update_sg_quota(neutron_client, '%s', '%s', " + "'%s')]:" % (tenant_id, sg_quota, sg_rule_quota), e) return False @@ -531,8 +531,8 @@ def delete_security_group(neutron_client, secgroup_id): neutron_client.delete_security_group(secgroup_id) return True except Exception, e: - print "Error [delete_security_group(neutron_client, '%s')]:" \ - % secgroup_id, e + print ("Error [delete_security_group(neutron_client, '%s')]:" % + secgroup_id, e) return False @@ -571,8 +571,8 @@ def create_glance_image(glance_client, image_name, file_path, public=True): data=fimage) return image.id except Exception, e: - print "Error [create_glance_image(glance_client, '%s', '%s', "\ - "'%s')]:" % (image_name, file_path, str(public)), e + print ("Error [create_glance_image(glance_client, '%s', '%s', " + "'%s')]:" % (image_name, file_path, str(public)), e) return False @@ -581,7 +581,7 @@ def delete_glance_image(nova_client, image_id): nova_client.images.delete(image_id) return True except Exception, e: - print "Error [delete_glance_image(nova_client, '%s')]:" % image_id, e + print ("Error [delete_glance_image(nova_client, '%s')]:" % image_id, e) return False @@ -629,9 +629,9 @@ def update_cinder_quota(cinder_client, tenant_id, vols_quota, cinder_client.quotas.update(tenant_id, **quotas_values) return True except Exception, e: - print "Error [update_cinder_quota(cinder_client, '%s', '%s', '%s'" \ - "'%s')]:" % (tenant_id, vols_quota, - snapshots_quota, gigabytes_quota), e + print ("Error [update_cinder_quota(cinder_client, '%s', '%s', '%s'" + "'%s')]:" % (tenant_id, vols_quota, + snapshots_quota, gigabytes_quota), e) return False @@ -647,8 +647,8 @@ def delete_volume(cinder_client, volume_id, forced=False): cinder_client.volumes.delete(volume_id) return True except Exception, e: - print "Error [delete_volume(cinder_client, '%s', '%s')]:" % \ - (volume_id, str(forced)), e + print ("Error [delete_volume(cinder_client, '%s', '%s')]:" % + (volume_id, str(forced)), e) return False @@ -657,8 +657,8 @@ def delete_volume_type(cinder_client, volume_type): cinder_client.volume_types.delete(volume_type) return True except Exception, e: - print "Error [delete_volume_type(cinder_client, '%s')]:" \ - % volume_type, e + print ("Error [delete_volume_type(cinder_client, '%s')]:" % + volume_type, e) return False @@ -720,8 +720,8 @@ def create_tenant(keystone_client, tenant_name, tenant_description): enabled=True) return tenant.id except Exception, e: - print "Error [create_tenant(cinder_client, '%s', '%s')]:" % \ - (tenant_name, tenant_description), e + print ("Error [create_tenant(cinder_client, '%s', '%s')]:" % + (tenant_name, tenant_description), e) return False @@ -733,8 +733,9 @@ def create_user(keystone_client, user_name, user_password, enabled=True) return user.id except Exception, e: - print "Error [create_user(keystone_client, '%s', '%s', '%s'" \ - "'%s')]:" % (user_name, user_password, user_email, tenant_id), e + print ("Error [create_user(keystone_client, '%s', '%s', '%s'" + "'%s')]:" % (user_name, user_password, user_email, tenant_id), + e) return False @@ -743,8 +744,8 @@ def add_role_user(keystone_client, user_id, role_id, tenant_id): keystone_client.roles.add_user_role(user_id, role_id, tenant_id) return True except Exception, e: - print "Error [add_role_user(keystone_client, '%s', '%s'" \ - "'%s')]:" % (user_id, role_id, tenant_id), e + print ("Error [add_role_user(keystone_client, '%s', '%s'" + "'%s')]:" % (user_id, role_id, tenant_id), e) return False diff --git a/testcases/tests/TestFunctestUtils.py b/testcases/tests/TestFunctestUtils.py index e1f81ecdf..4e06b3e48 100644 --- a/testcases/tests/TestFunctestUtils.py +++ b/testcases/tests/TestFunctestUtils.py @@ -83,8 +83,9 @@ class TestFunctestUtils(unittest.TestCase): test = generateTestcaseList(functest_yaml) - expected_list = "vping_ssh vping_userdata tempest odl doctor " + \ - "promise policy-test odl-vpn_service-tests vims rally " + expected_list = ("vping_ssh vping_userdata tempest odl doctor " + + "promise policy-test odl-vpn_service-tests vims " + + "rally ") self.assertEqual(test, expected_list) def tearDown(self): diff --git a/testcases/vIMS/CI/orchestrator.py b/testcases/vIMS/CI/orchestrator.py index 7dbbda716..c61f654ca 100644 --- a/testcases/vIMS/CI/orchestrator.py +++ b/testcases/vIMS/CI/orchestrator.py @@ -101,16 +101,16 @@ class orchestrator: if self.logger: self.logger.info("Launching the cloudify-manager deployment") script = "set -e; " - script += "source " + self.testcase_dir + \ - "venv_cloudify/bin/activate; " + script += ("source " + self.testcase_dir + + "venv_cloudify/bin/activate; ") script += "cd " + self.testcase_dir + "; " script += "cfy init -r; " script += "cd cloudify-manager-blueprint; " - script += "cfy local create-requirements -o requirements.txt " + \ - "-p openstack-manager-blueprint.yaml; " + script += ("cfy local create-requirements -o requirements.txt " + + "-p openstack-manager-blueprint.yaml; ") script += "pip install -r requirements.txt; " - script += "timeout 1800 cfy bootstrap --install-plugins " + \ - "-p openstack-manager-blueprint.yaml -i inputs.yaml; " + script += ("timeout 1800 cfy bootstrap --install-plugins " + + "-p openstack-manager-blueprint.yaml -i inputs.yaml; ") cmd = "/bin/bash -c '" + script + "'" error = execute_command(cmd, self.logger) if error: @@ -166,14 +166,14 @@ class orchestrator: if self.logger: self.logger.info("Launching the {0} deployment".format(bp_name)) script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; " - script += "cd " + self.testcase_dir + \ - blueprint['destination_folder'] + "; " - script += "cfy blueprints upload -b " + \ - bp_name + " -p openstack-blueprint.yaml; " - script += "cfy deployments create -b " + bp_name + \ - " -d " + dep_name + " --inputs inputs.yaml; " - script += "cfy executions start -w install -d " \ - + dep_name + " --timeout 1800; " + script += ("cd " + self.testcase_dir + + blueprint['destination_folder'] + "; ") + script += ("cfy blueprints upload -b " + + bp_name + " -p openstack-blueprint.yaml; ") + script += ("cfy deployments create -b " + bp_name + + " -d " + dep_name + " --inputs inputs.yaml; ") + script += ("cfy executions start -w install -d " + + dep_name + " --timeout 1800; ") cmd = "/bin/bash -c '" + script + "'" error = execute_command(cmd, self.logger) @@ -187,8 +187,8 @@ class orchestrator: self.logger.info("Launching the {0} undeployment".format(dep_name)) script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; " script += "cd " + self.testcase_dir + "; " - script += "cfy executions start -w uninstall -d " + dep_name \ - + " --timeout 1800 ; " + script += ("cfy executions start -w uninstall -d " + dep_name + + " --timeout 1800 ; ") script += "cfy deployments delete -d " + dep_name + "; " cmd = "/bin/bash -c '" + script + "'" diff --git a/testcases/vIMS/CI/vIMS.py b/testcases/vIMS/CI/vIMS.py index 555015838..6f99d5930 100644 --- a/testcases/vIMS/CI/vIMS.py +++ b/testcases/vIMS/CI/vIMS.py @@ -69,8 +69,8 @@ with open("/home/opnfv/functest/conf/config_functest.yaml") as f: f.close() # Cloudify parameters -VIMS_DIR = REPO_PATH + \ - functest_yaml.get("general").get("directories").get("dir_vIMS") +VIMS_DIR = (REPO_PATH + + functest_yaml.get("general").get("directories").get("dir_vIMS")) VIMS_DATA_DIR = functest_yaml.get("general").get( "directories").get("dir_vIMS_data") + "/" VIMS_TEST_DIR = functest_yaml.get("general").get( @@ -219,12 +219,12 @@ def test_clearwater(): resolvconf += "\nnameserver " + ns if dns_ip != "": - script = 'echo -e "nameserver ' + dns_ip + resolvconf + \ - '" > /etc/resolv.conf; ' + script = ('echo -e "nameserver ' + dns_ip + resolvconf + + '" > /etc/resolv.conf; ') script += 'source /etc/profile.d/rvm.sh; ' script += 'cd ' + VIMS_TEST_DIR + '; ' - script += 'rake test[' + \ - CW_INPUTS["public_domain"] + '] SIGNUP_CODE="secret"' + script += ('rake test[' + CW_INPUTS["public_domain"] + + '] SIGNUP_CODE="secret"') cmd = "/bin/bash -c '" + script + "'" output_file = "output.txt" @@ -329,9 +329,8 @@ def main(): }) logger.info("Upload some OS images if it doesn't exist") - glance_endpoint = keystone.\ - service_catalog.url_for(service_type='image', - endpoint_type='publicURL') + glance_endpoint = keystone.service_catalog.url_for( + service_type='image', endpoint_type='publicURL') glance = glclient.Client(1, glance_endpoint, token=keystone.auth_token) for img in IMAGES.keys(): @@ -397,8 +396,8 @@ def main(): logger.error( "Failed to find %s flavor. " "Try with ram range default requirement !" % flavor_name) - flavor_id = openstack_utils.\ - get_flavor_id_by_ram_range(nova, 4000, 8196) + flavor_id = openstack_utils.get_flavor_id_by_ram_range( + nova, 4000, 8196) if flavor_id == '': step_failure("orchestrator", @@ -474,8 +473,8 @@ def main(): logger.error( "Failed to find %s flavor. Try with ram range " "default requirement !" % flavor_name) - flavor_id = openstack_utils.\ - get_flavor_id_by_ram_range(nova, 4000, 8196) + flavor_id = openstack_utils.get_flavor_id_by_ram_range( + nova, 4000, 8196) if flavor_id == '': step_failure( diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py index f7e9884ee..66b3f10e0 100644 --- a/testcases/vPing/CI/libraries/vPing_ssh.py +++ b/testcases/vPing/CI/libraries/vPing_ssh.py @@ -81,31 +81,28 @@ TEST_DB = functest_yaml.get("results").get("test_db_url") NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1") NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2") GLANCE_IMAGE_NAME = functest_yaml.get("vping").get("image_name") -GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \ - get("openstack").get("image_file_name") -GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \ - get("openstack").get("image_disk_format") -GLANCE_IMAGE_PATH = functest_yaml.get("general"). \ - get("directories").get("dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME - +GLANCE_IMAGE_FILENAME = functest_yaml.get("general").get("openstack").get( + "image_file_name") +GLANCE_IMAGE_FORMAT = functest_yaml.get("general").get("openstack").get( + "image_disk_format") +GLANCE_IMAGE_PATH = functest_yaml.get("general").get("directories").get( + "dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME FLAVOR = functest_yaml.get("vping").get("vm_flavor") # NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping"). \ - get("vping_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping"). \ - get("vping_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping"). \ - get("vping_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("vping"). \ - get("vping_router_name") +NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get( + "vping_private_net_name") +NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( + "vping_private_subnet_name") +NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( + "vping_private_subnet_cidr") +NEUTRON_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") +SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name") +SECGROUP_DESCR = functest_yaml.get("vping").get("vping_sg_descr") def pMsg(value): @@ -170,24 +167,22 @@ def create_private_neutron_net(neutron): 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) + 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) + 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) + router_id = openstack_utils.create_neutron_router( + neutron, NEUTRON_ROUTER_NAME) if not router_id: return False @@ -240,15 +235,13 @@ def create_security_group(neutron_client): logger.debug("Adding SSH rules in security group '%s'..." % SECGROUP_NAME) - if not openstack_utils.\ - create_secgroup_rule(neutron_client, sg_id, - 'ingress', 'tcp', '22', '22'): + if not openstack_utils.create_secgroup_rule( + neutron_client, sg_id, 'ingress', 'tcp', '22', '22'): logger.error("Failed to create the security group rule...") return False - if not openstack_utils.\ - create_secgroup_rule(neutron_client, sg_id, - 'egress', 'tcp', '22', '22'): + if not openstack_utils.create_secgroup_rule( + neutron_client, sg_id, 'egress', 'tcp', '22', '22'): logger.error("Failed to create the security group rule...") return False return sg_id @@ -285,9 +278,8 @@ def main(): neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = openstack_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) - glance_endpoint = keystone_client.\ - service_catalog.url_for(service_type='image', - endpoint_type='publicURL') + glance_endpoint = keystone_client.service_catalog.url_for( + service_type='image', endpoint_type='publicURL') glance_client = glanceclient.Client(1, glance_endpoint, token=keystone_client.auth_token) EXIT_CODE = -1 @@ -438,8 +430,8 @@ 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) diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py index 798cf1c63..09acb2df2 100644 --- a/testcases/vPing/CI/libraries/vPing_userdata.py +++ b/testcases/vPing/CI/libraries/vPing_userdata.py @@ -78,31 +78,28 @@ TEST_DB = functest_yaml.get("results").get("test_db_url") NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1") NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2") GLANCE_IMAGE_NAME = functest_yaml.get("vping").get("image_name") -GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \ - get("openstack").get("image_file_name") -GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \ - get("openstack").get("image_disk_format") -GLANCE_IMAGE_PATH = functest_yaml.get("general"). \ - get("directories").get("dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME +GLANCE_IMAGE_FILENAME = functest_yaml.get("general").get( + "openstack").get("image_file_name") +GLANCE_IMAGE_FORMAT = functest_yaml.get("general").get( + "openstack").get("image_disk_format") +GLANCE_IMAGE_PATH = functest_yaml.get("general").get("directories").get( + "dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME FLAVOR = functest_yaml.get("vping").get("vm_flavor") # NEUTRON Private Network parameters -NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping"). \ - get("vping_private_net_name") -NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping"). \ - get("vping_private_subnet_name") -NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping"). \ - get("vping_private_subnet_cidr") -NEUTRON_ROUTER_NAME = functest_yaml.get("vping"). \ - get("vping_router_name") +NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get( + "vping_private_net_name") +NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get( + "vping_private_subnet_name") +NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get( + "vping_private_subnet_cidr") +NEUTRON_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") +SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name") +SECGROUP_DESCR = functest_yaml.get("vping").get("vping_sg_descr") def pMsg(value): @@ -165,24 +162,22 @@ def create_private_neutron_net(neutron): 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) + 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) + 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) + router_id = openstack_utils.create_neutron_router( + neutron, NEUTRON_ROUTER_NAME) if not router_id: return False @@ -279,9 +274,8 @@ def main(): neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = openstack_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) - glance_endpoint = keystone_client.\ - service_catalog.url_for(service_type='image', - endpoint_type='publicURL') + glance_endpoint = keystone_client.service_catalog.url_for( + service_type='image', endpoint_type='publicURL') glance_client = glanceclient.Client(1, glance_endpoint, token=keystone_client.auth_token) EXIT_CODE = -1 @@ -375,9 +369,9 @@ def main(): # the long chain corresponds to the ping procedure converted with base 64 # tune (e.g. flavor, images, network) to your specific openstack # configuration here - u = "#!/bin/sh\n\nwhile true; do\n ping -c 1 %s 2>&1 >/dev/null\n " \ - "RES=$?\n if [ \"Z$RES\" = \"Z0\" ] ; then\n echo 'vPing OK'\n " \ - "break\n else\n echo 'vPing KO'\n fi\n sleep 1\ndone\n" % test_ip + u = ("#!/bin/sh\n\nwhile true; do\n ping -c 1 %s 2>&1 >/dev/null\n " + "RES=$?\n if [ \"Z$RES\" = \"Z0\" ] ; then\n echo 'vPing OK'\n " + "break\n else\n echo 'vPing KO'\n fi\n sleep 1\ndone\n" % test_ip) # create VM logger.info("Creating instance '%s'..." % NAME_VM_2) @@ -421,8 +415,8 @@ def main(): logger.info("vPing duration:'%s'" % duration) EXIT_CODE = 0 break - elif "failed to read iid from metadata" in console_log or \ - metadata_tries > 5: + elif ("failed to read iid from metadata" in console_log or + metadata_tries > 5): EXIT_CODE = -2 break elif sec == PING_TIMEOUT: |