aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests
diff options
context:
space:
mode:
authorhelenyao <yaohelan@huawei.com>2016-11-21 06:50:06 -0500
committerjose.lausuch <jose.lausuch@ericsson.com>2016-11-24 15:14:45 +0100
commit3e3c96b2aa15d7757f281ce00518a67e2a1225a9 (patch)
tree9b15e0ceab33a9301ca7cde1a0a36e05f2347584 /functest/opnfv_tests
parent7a776398ef8b17bd9af5367d712707a903c1c86a (diff)
Extracted all global parameters into functest_constants.py
JIRA: FUNCTEST-533 1. Extracted all global variables into functest_constants.py and updated all affected areas accordingly 2. Used os.path.join to replace '/' to come up with the path for better cross-platform support and improve the path accuracy 3. Removed unused variables 4. Updated the hardcoded path in Dockerfile by using variable reference 5. Removed "/" ending from all path variables 6. Updated the unit test Change-Id: Ib30a81d1f0c83fbaef042d63c187c27bd18301bb Signed-off-by: helenyao <yaohelan@huawei.com>
Diffstat (limited to 'functest/opnfv_tests')
-rwxr-xr-xfunctest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py50
-rwxr-xr-xfunctest/opnfv_tests/Controllers/ONOS/Sfc/Sfc.py18
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py4
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py46
-rwxr-xr-xfunctest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py43
-rwxr-xr-xfunctest/opnfv_tests/OpenStack/examples/create_instance_and_ip.py74
-rwxr-xr-xfunctest/opnfv_tests/OpenStack/rally/run_rally-cert.py140
-rwxr-xr-xfunctest/opnfv_tests/OpenStack/tempest/gen_tempest_conf.py22
-rwxr-xr-xfunctest/opnfv_tests/OpenStack/tempest/run_tempest.py187
-rwxr-xr-xfunctest/opnfv_tests/features/copper.py11
-rwxr-xr-xfunctest/opnfv_tests/features/doctor.py11
-rwxr-xr-xfunctest/opnfv_tests/features/domino.py8
-rwxr-xr-xfunctest/opnfv_tests/features/multisite.py1
-rwxr-xr-xfunctest/opnfv_tests/features/promise.py119
-rw-r--r--functest/opnfv_tests/security_scan/connect.py3
-rw-r--r--functest/opnfv_tests/security_scan/scripts/internet_check.py2
-rwxr-xr-xfunctest/opnfv_tests/security_scan/security_scan.py39
-rwxr-xr-xfunctest/opnfv_tests/vnf/vIMS/vIMS.py83
-rwxr-xr-xfunctest/opnfv_tests/vnf/vRNC/parser.py9
19 files changed, 415 insertions, 455 deletions
diff --git a/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py b/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
index 8c003abf..0ddb58cd 100755
--- a/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
+++ b/functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
@@ -23,6 +23,7 @@ from robot.utils.robottime import timestamp_to_secs
from functest.core import TestCasesBase
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as op_utils
+import functest.utils.functest_constants as ft_constants
class ODLResultVisitor(ResultVisitor):
@@ -48,11 +49,14 @@ class ODLResultVisitor(ResultVisitor):
class ODLTestCases(TestCasesBase.TestCasesBase):
- repos = "/home/opnfv/repos/"
- odl_test_repo = repos + "odl_test/"
- neutron_suite_dir = odl_test_repo + "csit/suites/openstack/neutron/"
- basic_suite_dir = odl_test_repo + "csit/suites/integration/basic/"
- res_dir = '/home/opnfv/functest/results/odl/'
+ repos = ft_constants.REPOS_DIR
+ odl_test_repo = os.path.join(repos, "odl_test")
+ neutron_suite_dir = os.path.join(odl_test_repo,
+ "csit/suites/openstack/neutron")
+ basic_suite_dir = os.path.join(odl_test_repo,
+ "csit/suites/integration/basic")
+ res_dir = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR, "odl")
+
logger = ft_logger.Logger("opendaylight").getLogger()
def __init__(self):
@@ -60,7 +64,8 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
@classmethod
def set_robotframework_vars(cls, odlusername="admin", odlpassword="admin"):
- odl_variables_files = cls.odl_test_repo + 'csit/variables/Variables.py'
+ odl_variables_files = os.path.join(cls.odl_test_repo,
+ 'csit/variables/Variables.py')
try:
for line in fileinput.input(odl_variables_files,
inplace=True):
@@ -74,7 +79,8 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
return False
def parse_results(self):
- result = ExecutionResult(self.res_dir + 'output.xml')
+ output_dir = os.path.join(self.res_dir, 'output.xml')
+ result = ExecutionResult(output_dir)
visitor = ODLResultVisitor()
result.visit(visitor)
self.criteria = result.suite.status
@@ -109,10 +115,11 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
self.logger.exception(
"Cannot create {}".format(self.res_dir))
return self.EX_RUN_ERROR
- stdout_file = self.res_dir + 'stdout.txt'
+ stdout_file = os.path.join(self.res_dir, 'stdout.txt')
+ output_dir = os.path.join(self.res_dir, 'output.xml')
with open(stdout_file, 'w+') as stdout:
robot.run(*dirs, variable=variables,
- output=self.res_dir + 'output.xml',
+ output=output_dir,
log='NONE',
report='NONE',
stdout=stdout)
@@ -148,23 +155,29 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
kwargs['odlrestconfport'] = '8181'
kwargs['odlusername'] = 'admin'
kwargs['odlpassword'] = 'admin'
- installer_type = None
- if 'INSTALLER_TYPE' in os.environ:
- installer_type = os.environ['INSTALLER_TYPE']
- kwargs['osusername'] = os.environ['OS_USERNAME']
- kwargs['ostenantname'] = os.environ['OS_TENANT_NAME']
- kwargs['ospassword'] = os.environ['OS_PASSWORD']
+
+ installer_type = ft_constants.CI_INSTALLER_TYPE
+ kwargs['osusername'] = ft_constants.OS_USERNAME
+ kwargs['ostenantname'] = ft_constants.OS_TENANT_NAME
+ kwargs['ospassword'] = ft_constants.OS_PASSWORD
+
if installer_type == 'fuel':
kwargs['odlwebport'] = '8282'
elif installer_type == 'apex':
- kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
+ if ft_constants.SDN_CONTROLLER_IP is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER_IP
kwargs['odlwebport'] = '8181'
elif installer_type == 'joid':
- kwargs['odlip'] = os.environ['SDN_CONTROLLER']
+ if ft_constants.SDN_CONTROLLER is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER
elif installer_type == 'compass':
kwargs['odlwebport'] = '8181'
else:
- kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
+ if ft_constants.SDN_CONTROLLER_IP is None:
+ return self.EX_RUN_ERROR
+ kwargs['odlip'] = ft_constants.SDN_CONTROLLER_IP
except KeyError as e:
self.logger.error("Cannot run ODL testcases. "
"Please check env var: "
@@ -176,6 +189,7 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
return self.main(**kwargs)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-k', '--keystoneip',
diff --git a/functest/opnfv_tests/Controllers/ONOS/Sfc/Sfc.py b/functest/opnfv_tests/Controllers/ONOS/Sfc/Sfc.py
index bea2828d..e3f08041 100755
--- a/functest/opnfv_tests/Controllers/ONOS/Sfc/Sfc.py
+++ b/functest/opnfv_tests/Controllers/ONOS/Sfc/Sfc.py
@@ -25,7 +25,7 @@
import time
import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as functest_utils
+import functest.utils.functest_utils as ft_utils
from Sfc_fun import Sfc_fun
logger = ft_logger.Logger("sfc").getLogger()
@@ -81,7 +81,7 @@ def ConfigSfc():
logger.info(
"Testcase 4 : Configure Port Chain and verify flows are added")
logger.info("4.1 Creation of Port Chain")
- check(Sfc_obj.createPortChain, CREATED, "Creation of Port Chain")
+ check(Sfc_obj.createPortChain, CREATED, "Creation of Port Chain")
def VerifySfcTraffic():
@@ -152,13 +152,13 @@ def PushDB(status, info):
# ONOS SFC success criteria = all tests OK
duration = round(stop_time - start_time, 1)
logger.info("Result is " + status)
- functest_utils.push_results_to_db("functest",
- "onos_sfc",
- start_time,
- stop_time,
- status,
- details={'duration': duration,
- 'error': info})
+ ft_utils.push_results_to_db("functest",
+ "onos_sfc",
+ start_time,
+ stop_time,
+ status,
+ details={'duration': duration,
+ 'error': info})
except:
logger.error("Error pushing results into Database")
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py
index f2755b66..01f70b85 100644
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py
+++ b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py
@@ -141,8 +141,8 @@ class environment(connection):
result = self.CheckSshNoPasswd(host)
if not result:
self.logger.info(
- "ssh login failed,try to copy master publickey" +
- "to agent " + str(host))
+ "ssh login 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)
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py
index 603e9933..6f7a40ff 100644
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py
+++ b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py
@@ -17,6 +17,7 @@ import os
import re
import time
+import functest.utils.functest_constants as ft_constants
import functest.utils.functest_utils as ft_utils
@@ -25,8 +26,8 @@ class foundation:
def __init__(self):
# currentpath = os.getcwd()
- REPO_PATH = ft_utils.FUNCTEST_REPO + '/'
- currentpath = REPO_PATH + 'opnfv_tests/Controllers/ONOS/Teston/CI'
+ currentpath = \
+ ft_constants.FUNCTEST_TEST_DIR + '/Controllers/ONOS/Teston/CI'
self.cipath = currentpath
self.logdir = os.path.join(currentpath, 'log')
self.workhome = currentpath[0: currentpath.rfind('opnfv_tests') - 1]
@@ -54,30 +55,23 @@ class foundation:
"""
Get Default Parameters value
"""
- self.Result_DB = str(
- ft_utils.get_functest_config('results.test_db_url'))
- self.masterusername = str(
- ft_utils.get_functest_config('ONOS.general.onosbench_username'))
- self.masterpassword = str(
- ft_utils.get_functest_config('ONOS.general.onosbench_password'))
- self.agentusername = str(
- ft_utils.get_functest_config('ONOS.general.onoscli_username'))
- self.agentpassword = str(
- ft_utils.get_functest_config('ONOS.general.onoscli_password'))
- self.runtimeout = \
- ft_utils.get_functest_config('ONOS.general.runtimeout')
- self.OCT = str(ft_utils.get_functest_config('ONOS.environment.OCT'))
- self.OC1 = str(ft_utils.get_functest_config('ONOS.environment.OC1'))
- self.OC2 = str(ft_utils.get_functest_config('ONOS.environment.OC2'))
- self.OC3 = str(ft_utils.get_functest_config('ONOS.environment.OC3'))
- self.OCN = str(ft_utils.get_functest_config('ONOS.environment.OCN'))
- self.OCN2 = str(ft_utils.get_functest_config('ONOS.environment.OCN2'))
- self.installer_master = str(
- ft_utils.get_functest_config('ONOS.environment.installer_master'))
- self.installer_master_username = str(ft_utils.get_functest_config(
- 'ONOS.environment.installer_master_username'))
- self.installer_master_password = str(ft_utils.get_functest_config(
- 'ONOS.environment.installer_master_password'))
+ self.Result_DB = str(ft_utils.get_db_url())
+ self.masterusername = str(ft_constants.ONOSBENCH_USERNAME)
+ self.masterpassword = str(ft_constants.ONOSBENCH_PASSWORD)
+ self.agentusername = str(ft_constants.ONOSCLI_USERNAME)
+ self.agentpassword = str(ft_constants.ONOSCLI_PASSWORD)
+ self.runtimeout = ft_constants.ONOS_RUNTIMEOUT
+ self.OCT = str(ft_constants.ONOS_OCT)
+ self.OC1 = str(ft_constants.ONOS_OC1)
+ self.OC2 = str(ft_constants.ONOS_OC2)
+ self.OC3 = str(ft_constants.ONOS_OC3)
+ self.OCN = str(ft_constants.ONOS_OCN)
+ self.OCN2 = str(ft_constants.ONOS_OCN2)
+ self.installer_master = str(ft_constants.ONOS_INSTALLER_MASTER)
+ self.installer_master_username = \
+ str(ft_constants.ONOS_INSTALLER_MASTER_USERNAME)
+ self.installer_master_password = \
+ ft_constants.ONOS_INSTALLER_MASTER_PASSWORD
self.hosts = [self.OC1, self.OCN, self.OCN2]
self.localhost = self.OCT
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py b/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py
index c8045fd1..300f56d1 100755
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py
+++ b/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py
@@ -25,6 +25,8 @@ from neutronclient.v2_0 import client as neutronclient
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as openstack_utils
+import functest.utils.functest_constants as ft_constants
+
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--testcase", help="Testcase name")
@@ -35,27 +37,15 @@ args = parser.parse_args()
logger = ft_logger.Logger("onos").getLogger()
# onos parameters
-TEST_DB = ft_utils.get_functest_config("results.test_db_url")
-ONOS_REPO_PATH = \
- ft_utils.get_functest_config("general.directories.dir_repos")
-ONOS_CONF_DIR = \
- ft_utils.get_functest_config("general.directories.dir_functest_conf")
-
-ONOSCI_PATH = ONOS_REPO_PATH + "/"
+ONOSCI_PATH = ft_constants.REPOS_DIR + "/"
starttime = datetime.datetime.now()
-HOME = os.environ['HOME'] + "/"
-INSTALLER_TYPE = os.environ['INSTALLER_TYPE']
-DEPLOY_SCENARIO = os.environ['DEPLOY_SCENARIO']
-ONOSCI_PATH = ONOS_REPO_PATH + "/"
-GLANCE_IMAGE_NAME = ft_utils.get_functest_config("onos_sfc.image_name")
-GLANCE_IMAGE_FILENAME = \
- ft_utils.get_functest_config("onos_sfc.image_file_name")
-GLANCE_IMAGE_PATH = \
- ft_utils.get_functest_config("general.directories.dir_functest_data") + \
- "/" + GLANCE_IMAGE_FILENAME
-SFC_PATH = ft_utils.FUNCTEST_REPO + "/" + \
- ft_utils.get_functest_config("general.directories.dir_onos_sfc")
+INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
+ONOS_SFC_IMAGE_NAME = ft_constants.ONOS_SFC_IMAGE_NAME
+ONOS_SFC_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
+ ft_constants.ONOS_SFC_IMAGE_FILENAME)
+ONOS_SFC_PATH = os.path.join(ft_constants.FUNCTEST_REPO_DIR,
+ ft_constants.ONOS_SFC_RELATIVE_PATH)
def RunScript(testname):
@@ -173,18 +163,18 @@ def CleanOnosTest():
def CreateImage():
glance_client = openstack_utils.get_glance_client()
image_id = openstack_utils.create_glance_image(glance_client,
- GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH)
+ ONOS_SFC_IMAGE_NAME,
+ ONOS_SFC_IMAGE_PATH)
EXIT_CODE = -1
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))
+ % (ONOS_SFC_IMAGE_NAME, image_id))
def SfcTest():
- cmd = "python " + SFC_PATH + "Sfc.py"
+ cmd = "python " + ONOS_SFC_PATH + "/Sfc.py"
logger.debug("Run sfc tests")
os.system(cmd)
@@ -197,8 +187,8 @@ def GetIp(type):
def Replace(before, after):
- file = "Sfc_fun.py"
- cmd = "sed -i 's/" + before + "/" + after + "/g' " + SFC_PATH + file
+ file = "/Sfc_fun.py"
+ cmd = "sed -i 's/" + before + "/" + after + "/g' " + ONOS_SFC_PATH + file
os.system(cmd)
@@ -207,7 +197,7 @@ def SetSfcConf():
Replace("neutron_ip", GetIp("neutron"))
Replace("nova_ip", GetIp("nova"))
Replace("glance_ip", GetIp("glance"))
- pwd = os.environ['OS_PASSWORD']
+ pwd = ft_constants.OS_PASSWORD
Replace("console", pwd)
creds_neutron = openstack_utils.get_credentials("neutron")
neutron_client = neutronclient.Client(**creds_neutron)
@@ -266,5 +256,6 @@ def main():
else:
OnosTest()
+
if __name__ == '__main__':
main()
diff --git a/functest/opnfv_tests/OpenStack/examples/create_instance_and_ip.py b/functest/opnfv_tests/OpenStack/examples/create_instance_and_ip.py
index 50cdf8a5..6a2abe60 100755
--- a/functest/opnfv_tests/OpenStack/examples/create_instance_and_ip.py
+++ b/functest/opnfv_tests/OpenStack/examples/create_instance_and_ip.py
@@ -11,11 +11,10 @@
#
import argparse
-import os
import sys
import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
+import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
@@ -28,34 +27,27 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("create_instance_and_ip").getLogger()
-HOME = os.environ['HOME'] + "/"
+HOME = ft_constants.HOME + "/"
VM_BOOT_TIMEOUT = 180
-INSTANCE_NAME = ft_utils.get_functest_config("example.example_vm_name")
-FLAVOR = ft_utils.get_functest_config("example.example_flavor")
-IMAGE_NAME = ft_utils.get_functest_config("example.example_image_name")
-IMAGE_FILENAME = \
- ft_utils.get_functest_config("general.openstack.image_file_name")
-IMAGE_FORMAT = \
- ft_utils.get_functest_config("general.openstack.image_disk_format")
-IMAGE_PATH = \
- ft_utils.get_functest_config("general.directories.dir_functest_data") + \
+EXAMPLE_INSTANCE_NAME = ft_constants.EXAMPLE_INSTANCE_NAME
+EXAMPLE_FLAVOR = ft_constants.EXAMPLE_FLAVOR
+EXAMPLE_IMAGE_NAME = ft_constants.EXAMPLE_IMAGE_NAME
+IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
+IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
+IMAGE_PATH = ft_constants.FUNCTEST_DATA_DIR + \
"/" + IMAGE_FILENAME
# NEUTRON Private Network parameters
-NET_NAME = ft_utils.get_functest_config("example.example_private_net_name")
-SUBNET_NAME = \
- ft_utils.get_functest_config("example.example_private_subnet_name")
-SUBNET_CIDR = \
- ft_utils.get_functest_config("example.example_private_subnet_cidr")
-ROUTER_NAME = ft_utils.get_functest_config("example.example_router_name")
+EXAMPLE_PRIVATE_NET_NAME = ft_constants.EXAMPLE_PRIVATE_NET_NAME
+EXAMPLE_PRIVATE_SUBNET_NAME = ft_constants.EXAMPLE_PRIVATE_SUBNET_NAME
+EXAMPLE_PRIVATE_SUBNET_CIDR = ft_constants.EXAMPLE_PRIVATE_SUBNET_CIDR
+EXAMPLE_ROUTER_NAME = ft_constants.EXAMPLE_ROUTER_NAME
-SECGROUP_NAME = ft_utils.get_functest_config("example.example_sg_name")
-SECGROUP_DESCR = ft_utils.get_functest_config("example.example_sg_descr")
-
-TEST_DB = ft_utils.get_functest_config("results.test_db_url")
+EXAMPLE_SECGROUP_NAME = ft_constants.EXAMPLE_SECGROUP_NAME
+EXAMPLE_SECGROUP_DESCR = ft_constants.EXAMPLE_SECGROUP_DESCR
def main():
@@ -65,17 +57,17 @@ def main():
glance_client = os_utils.get_glance_client()
image_id = os_utils.create_glance_image(glance_client,
- IMAGE_NAME,
+ EXAMPLE_IMAGE_NAME,
IMAGE_PATH,
disk=IMAGE_FORMAT,
container="bare",
public=True)
network_dic = os_utils.create_network_full(neutron_client,
- NET_NAME,
- SUBNET_NAME,
- ROUTER_NAME,
- SUBNET_CIDR)
+ EXAMPLE_PRIVATE_NET_NAME,
+ EXAMPLE_PRIVATE_SUBNET_NAME,
+ EXAMPLE_ROUTER_NAME,
+ EXAMPLE_PRIVATE_SUBNET_CIDR)
if not network_dic:
logger.error(
"There has been a problem when creating the neutron network")
@@ -84,31 +76,34 @@ def main():
network_id = network_dic["net_id"]
sg_id = os_utils.create_security_group_full(neutron_client,
- SECGROUP_NAME, SECGROUP_DESCR)
+ EXAMPLE_SECGROUP_NAME,
+ EXAMPLE_SECGROUP_DESCR)
# boot INTANCE
- logger.info("Creating instance '%s'..." % INSTANCE_NAME)
+ logger.info("Creating instance '%s'..." % EXAMPLE_INSTANCE_NAME)
logger.debug(
"Configuration:\n name=%s \n flavor=%s \n image=%s \n "
- "network=%s \n" % (INSTANCE_NAME, FLAVOR, image_id, network_id))
- instance = os_utils.create_instance_and_wait_for_active(FLAVOR,
- image_id,
- network_id,
- INSTANCE_NAME)
+ "network=%s \n"
+ % (EXAMPLE_INSTANCE_NAME, EXAMPLE_FLAVOR, image_id, network_id))
+ instance = \
+ os_utils.create_instance_and_wait_for_active(EXAMPLE_FLAVOR,
+ image_id,
+ network_id,
+ EXAMPLE_INSTANCE_NAME)
if instance is None:
logger.error("Error while booting instance.")
sys.exit(-1)
# Retrieve IP of INSTANCE
- instance_ip = instance.networks.get(NET_NAME)[0]
+ instance_ip = instance.networks.get(EXAMPLE_PRIVATE_NET_NAME)[0]
logger.debug("Instance '%s' got private ip '%s'." %
- (INSTANCE_NAME, instance_ip))
+ (EXAMPLE_INSTANCE_NAME, instance_ip))
logger.info("Adding '%s' to security group '%s'..."
- % (INSTANCE_NAME, SECGROUP_NAME))
+ % (EXAMPLE_INSTANCE_NAME, EXAMPLE_SECGROUP_NAME))
os_utils.add_secgroup_to_instance(nova_client, instance.id, sg_id)
- logger.info("Creating floating IP for VM '%s'..." % INSTANCE_NAME)
+ logger.info("Creating floating IP for VM '%s'..." % EXAMPLE_INSTANCE_NAME)
floatip_dic = os_utils.create_floating_ip(neutron_client)
floatip = floatip_dic['fip_addr']
# floatip_id = floatip_dic['fip_id']
@@ -119,12 +114,13 @@ def main():
logger.info("Floating IP created: '%s'" % floatip)
logger.info("Associating floating ip: '%s' to VM '%s' "
- % (floatip, INSTANCE_NAME))
+ % (floatip, EXAMPLE_INSTANCE_NAME))
if not os_utils.add_floating_ip(nova_client, instance.id, floatip):
logger.error("Cannot associate floating IP to VM.")
sys.exit(-1)
sys.exit(0)
+
if __name__ == '__main__':
main()
diff --git a/functest/opnfv_tests/OpenStack/rally/run_rally-cert.py b/functest/opnfv_tests/OpenStack/rally/run_rally-cert.py
index 8b8adce4..6d8f0160 100755
--- a/functest/opnfv_tests/OpenStack/rally/run_rally-cert.py
+++ b/functest/opnfv_tests/OpenStack/rally/run_rally-cert.py
@@ -28,6 +28,7 @@ import yaml
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
+import functest.utils.functest_constants as ft_constants
tests = ['authenticate', 'glance', 'cinder', 'heat', 'keystone',
'neutron', 'nova', 'quotas', 'requests', 'vm', 'all']
@@ -61,7 +62,6 @@ parser.add_argument("-z", "--sanity",
args = parser.parse_args()
-network_dict = {}
if args.verbose:
RALLY_STDERR = subprocess.STDOUT
@@ -69,18 +69,17 @@ else:
RALLY_STDERR = open(os.devnull, 'w')
""" logging configuration """
-logger = ft_logger.Logger("run_rally").getLogger()
-
-
-HOME = os.environ['HOME'] + "/"
-RALLY_DIR = ft_utils.FUNCTEST_REPO + '/' + \
- ft_utils.get_functest_config('general.directories.dir_rally')
-SANITY_MODE_DIR = RALLY_DIR + "scenario/sanity"
-FULL_MODE_DIR = RALLY_DIR + "scenario/full"
-TEMPLATE_DIR = RALLY_DIR + "scenario/templates"
-SUPPORT_DIR = RALLY_DIR + "scenario/support"
-TEMP_DIR = RALLY_DIR + "var"
-BLACKLIST_FILE = RALLY_DIR + "blacklist.txt"
+logger = ft_logger.Logger("run_rally-cert").getLogger()
+
+RALLY_DIR = os.path.join(ft_constants.FUNCTEST_REPO_DIR,
+ ft_constants.RALLY_RELATIVE_PATH)
+RALLY_SCENARIO_DIR = os.path.join(RALLY_DIR, "scenario")
+SANITY_MODE_DIR = os.path.join(RALLY_SCENARIO_DIR, "sanity")
+FULL_MODE_DIR = os.path.join(RALLY_SCENARIO_DIR, "full")
+TEMPLATE_DIR = os.path.join(RALLY_SCENARIO_DIR, "templates")
+SUPPORT_DIR = os.path.join(RALLY_SCENARIO_DIR, "support")
+TEMP_DIR = os.path.join(RALLY_DIR, "var")
+BLACKLIST_FILE = os.path.join(RALLY_DIR, "blacklist.txt")
FLAVOR_NAME = "m1.tiny"
USERS_AMOUNT = 2
@@ -88,33 +87,27 @@ TENANTS_AMOUNT = 3
ITERATIONS_AMOUNT = 10
CONCURRENCY = 4
-RESULTS_DIR = \
- ft_utils.get_functest_config('general.directories.dir_rally_res')
-TEMPEST_CONF_FILE = \
- ft_utils.get_functest_config('general.directories.dir_results') + \
- '/tempest/tempest.conf'
-TEST_DB = ft_utils.get_functest_config('results.test_db_url')
-
-PRIVATE_NET_NAME = ft_utils.get_functest_config('rally.network_name')
-PRIVATE_SUBNET_NAME = ft_utils.get_functest_config('rally.subnet_name')
-PRIVATE_SUBNET_CIDR = ft_utils.get_functest_config('rally.subnet_cidr')
-ROUTER_NAME = ft_utils.get_functest_config('rally.router_name')
-
-GLANCE_IMAGE_NAME = \
- ft_utils.get_functest_config('general.openstack.image_name')
-GLANCE_IMAGE_FILENAME = \
- ft_utils.get_functest_config('general.openstack.image_file_name')
-GLANCE_IMAGE_FORMAT = \
- ft_utils.get_functest_config('general.openstack.image_disk_format')
-GLANCE_IMAGE_PATH = \
- ft_utils.get_functest_config('general.directories.dir_functest_data') + \
- "/" + GLANCE_IMAGE_FILENAME
+RESULTS_DIR = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR, 'rally')
+TEMPEST_CONF_FILE = os.path.join(ft_constants.FUNCTEST_RESULTS_DIR,
+ 'tempest/tempest.conf')
+RALLY_PRIVATE_NET_NAME = ft_constants.RALLY_PRIVATE_NET_NAME
+RALLY_PRIVATE_SUBNET_NAME = ft_constants.RALLY_PRIVATE_SUBNET_NAME
+RALLY_PRIVATE_SUBNET_CIDR = ft_constants.RALLY_PRIVATE_SUBNET_CIDR
+RALLY_ROUTER_NAME = ft_constants.RALLY_ROUTER_NAME
+
+GLANCE_IMAGE_NAME = ft_constants.GLANCE_IMAGE_NAME
+GLANCE_IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
+GLANCE_IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
+GLANCE_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
+ GLANCE_IMAGE_FILENAME)
CINDER_VOLUME_TYPE_NAME = "volume_test"
-SUMMARY = []
-neutron_client = None
+class GlobalVariables:
+ SUMMARY = []
+ neutron_client = None
+ network_dict = {}
def get_task_id(cmd_raw):
@@ -179,16 +172,16 @@ def build_task_args(test_file_name):
else:
task_args['smoke'] = args.smoke
- ext_net = os_utils.get_external_net(neutron_client)
+ ext_net = os_utils.get_external_net(GlobalVariables.neutron_client)
if ext_net:
task_args['floating_network'] = str(ext_net)
else:
task_args['floating_network'] = ''
- net_id = network_dict['net_id']
+ net_id = GlobalVariables.network_dict['net_id']
task_args['netid'] = str(net_id)
- auth_url = os.getenv('OS_AUTH_URL')
+ auth_url = ft_constants.OS_AUTH_URL
if auth_url is not None:
task_args['request_url'] = auth_url.rsplit(":", 1)[0]
else:
@@ -198,7 +191,6 @@ def build_task_args(test_file_name):
def get_output(proc, test_name):
- global SUMMARY
result = ""
nb_tests = 0
overall_duration = 0.0
@@ -255,7 +247,7 @@ def get_output(proc, test_name):
'overall_duration': overall_duration,
'nb_tests': nb_tests,
'success': success_avg}
- SUMMARY.append(scenario_summary)
+ GlobalVariables.SUMMARY.append(scenario_summary)
logger.debug("\n" + result)
@@ -279,8 +271,8 @@ def excl_scenario():
with open(BLACKLIST_FILE, 'r') as black_list_file:
black_list_yaml = yaml.safe_load(black_list_file)
- installer_type = os.getenv('INSTALLER_TYPE')
- deploy_scenario = os.getenv('DEPLOY_SCENARIO')
+ installer_type = ft_constants.CI_INSTALLER_TYPE
+ deploy_scenario = ft_constants.CI_SCENARIO
if (bool(installer_type) * bool(deploy_scenario)):
if 'scenario' in black_list_yaml.keys():
for item in black_list_yaml['scenario']:
@@ -345,22 +337,24 @@ def apply_blacklist(case_file_name, result_file_name):
def prepare_test_list(test_name):
- scenario_file_name = '{}opnfv-{}.yaml'.format(RALLY_DIR + "scenario/",
- test_name)
+ test_yaml_file_name = 'opnfv-{}.yaml'.format(test_name)
+ scenario_file_name = os.path.join(RALLY_SCENARIO_DIR, test_yaml_file_name)
+
if not os.path.exists(scenario_file_name):
if args.sanity:
- scenario_file_name = '{}opnfv-{}.yaml'.format(SANITY_MODE_DIR +
- "/", test_name)
+ scenario_file_name = os.path.join(SANITY_MODE_DIR,
+ test_yaml_file_name)
else:
- scenario_file_name = '{}opnfv-{}.yaml'.format(FULL_MODE_DIR +
- "/", test_name)
+ scenario_file_name = os.path.join(FULL_MODE_DIR,
+ test_yaml_file_name)
+
if not os.path.exists(scenario_file_name):
logger.info("The scenario '%s' does not exist."
% scenario_file_name)
exit(-1)
logger.debug('Scenario fetched from : {}'.format(scenario_file_name))
- test_file_name = '{}opnfv-{}.yaml'.format(TEMP_DIR + "/", test_name)
+ test_file_name = os.path.join(TEMP_DIR, test_yaml_file_name)
if not os.path.exists(TEMP_DIR):
os.makedirs(TEMP_DIR)
@@ -385,11 +379,10 @@ def run_task(test_name):
# :param test_name: name for the rally test
# :return: void
#
- global SUMMARY
logger.info('Starting test scenario "{}" ...'.format(test_name))
start_time = time.time()
- task_file = '{}task.yaml'.format(RALLY_DIR)
+ task_file = os.path.join(RALLY_DIR, 'task.yaml')
if not os.path.exists(task_file):
logger.error("Task file '%s' does not exist." % task_file)
exit(-1)
@@ -428,9 +421,10 @@ def run_task(test_name):
os.makedirs(RESULTS_DIR)
# write html report file
- report_file_name = '{}opnfv-{}.html'.format(RESULTS_DIR, test_name)
+ report_html_name = 'opnfv-{}.html'.format(test_name)
+ report_html_dir = os.path.join(RESULTS_DIR, report_html_name)
cmd_line = "rally task report {} --out {}".format(task_id,
- report_file_name)
+ report_html_dir)
logger.debug('running command line : {}'.format(cmd_line))
os.popen(cmd_line)
@@ -440,12 +434,13 @@ def run_task(test_name):
logger.debug('running command line : {}'.format(cmd_line))
cmd = os.popen(cmd_line)
json_results = cmd.read()
- with open('{}opnfv-{}.json'.format(RESULTS_DIR, test_name), 'w') as f:
+ report_json_name = 'opnfv-{}.json'.format(test_name)
+ report_json_dir = os.path.join(RESULTS_DIR, report_json_name)
+ with open(report_json_dir, 'w') as f:
logger.debug('saving json file')
f.write(json_results)
- with open('{}opnfv-{}.json'
- .format(RESULTS_DIR, test_name)) as json_file:
+ with open(report_json_dir) as json_file:
json_data = json.load(json_file)
""" parse JSON operation result """
@@ -469,12 +464,9 @@ def run_task(test_name):
def main():
- global SUMMARY
- global network_dict
- global neutron_client
- nova_client = os_utils.get_nova_client()
- neutron_client = os_utils.get_neutron_client()
+ GlobalVariables.nova_client = os_utils.get_nova_client()
+ GlobalVariables.neutron_client = os_utils.get_neutron_client()
cinder_client = os_utils.get_cinder_client()
start_time = time.time()
@@ -484,7 +476,7 @@ def main():
logger.error('argument not valid')
exit(-1)
- SUMMARY = []
+ GlobalVariables.SUMMARY = []
volume_types = os_utils.list_volume_types(cinder_client,
private=False)
@@ -506,12 +498,13 @@ def main():
if not image_id:
exit(-1)
- logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME)
- network_dict = os_utils.create_shared_network_full(PRIVATE_NET_NAME,
- PRIVATE_SUBNET_NAME,
- ROUTER_NAME,
- PRIVATE_SUBNET_CIDR)
- if not network_dict:
+ logger.debug("Creating network '%s'..." % RALLY_PRIVATE_NET_NAME)
+ GlobalVariables.network_dict = \
+ os_utils.create_shared_network_full(RALLY_PRIVATE_NET_NAME,
+ RALLY_PRIVATE_SUBNET_NAME,
+ RALLY_ROUTER_NAME,
+ RALLY_PRIVATE_SUBNET_CIDR)
+ if not GlobalVariables.network_dict:
exit(1)
if args.test_name == "all":
@@ -541,7 +534,7 @@ def main():
total_duration = 0.0
total_nb_tests = 0
total_success = 0.0
- for s in SUMMARY:
+ for s in GlobalVariables.SUMMARY:
name = "{0:<17}".format(s['test_name'])
duration = float(s['overall_duration'])
total_duration += duration
@@ -565,8 +558,8 @@ def main():
total_duration_str2 = "{0:<10}".format(total_duration_str)
total_nb_tests_str = "{0:<13}".format(total_nb_tests)
- if len(SUMMARY):
- success_rate = total_success / len(SUMMARY)
+ if len(GlobalVariables.SUMMARY):
+ success_rate = total_success / len(GlobalVariables.SUMMARY)
else:
success_rate = 100
success_rate = "{:0.2f}".format(success_rate)
@@ -609,7 +602,8 @@ def main():
if not image_exists:
logger.debug("Deleting image '%s' with ID '%s'..."
% (GLANCE_IMAGE_NAME, image_id))
- if not os_utils.delete_glance_image(nova_client, image_id):
+ if not os_utils.delete_glance_image(GlobalVariables.nova_client,
+ image_id):
logger.error("Error deleting the glance image")
if not volume_types:
diff --git a/functest/opnfv_tests/OpenStack/tempest/gen_tempest_conf.py b/functest/opnfv_tests/OpenStack/tempest/gen_tempest_conf.py
index ca671d00..8e298d36 100755
--- a/functest/opnfv_tests/OpenStack/tempest/gen_tempest_conf.py
+++ b/functest/opnfv_tests/OpenStack/tempest/gen_tempest_conf.py
@@ -18,8 +18,12 @@ import functest.utils.functest_utils as ft_utils
import functest.utils.functest_logger as ft_logger
from run_tempest import configure_tempest
from run_tempest import TEMPEST_RESULTS_DIR
+import functest.utils.functest_constants as ft_constants
-logger = ft_logger.Logger("multisite").getLogger()
+logger = ft_logger.Logger("gen_tempest_conf").getLogger()
+
+CI_INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
+CI_INSTALLER_IP = ft_constants.CI_INSTALLER_IP
def configure_tempest_multisite(deployment_dir):
@@ -30,16 +34,16 @@ def configure_tempest_multisite(deployment_dir):
configure_tempest(deployment_dir)
logger.debug("Finding tempest.conf file...")
- tempest_conf_file = deployment_dir + "/tempest.conf"
- if not os.path.isfile(tempest_conf_file):
+ tempest_conf_old = os.path.join(deployment_dir, '/tempest.conf')
+ if not os.path.isfile(tempest_conf_old):
logger.error("Tempest configuration file %s NOT found."
- % tempest_conf_file)
+ % tempest_conf_old)
exit(-1)
# Copy tempest.conf to /home/opnfv/functest/results/tempest/
cur_path = os.path.split(os.path.realpath(__file__))[0]
- shutil.copyfile(tempest_conf_file, cur_path + '/tempest_multisite.conf')
- tempest_conf_file = cur_path + "/tempest_multisite.conf"
+ tempest_conf_file = os.path.join(cur_path, '/tempest_multisite.conf')
+ shutil.copyfile(tempest_conf_old, tempest_conf_file)
logger.debug("Updating selected tempest.conf parameters...")
config = ConfigParser.RawConfigParser()
@@ -49,12 +53,12 @@ def configure_tempest_multisite(deployment_dir):
cmd = "openstack endpoint show kingbird | grep publicurl |\
awk '{print $4}' | awk -F '/' '{print $4}'"
kingbird_api_version = os.popen(cmd).read()
- if os.environ.get("INSTALLER_TYPE") == 'fuel':
+ if CI_INSTALLER_TYPE == 'fuel':
# For MOS based setup, the service is accessible
# via bind host
kingbird_conf_path = "/etc/kingbird/kingbird.conf"
- installer_type = os.getenv('INSTALLER_TYPE', 'Unknown')
- installer_ip = os.getenv('INSTALLER_IP', 'Unknown')
+ installer_type = CI_INSTALLER_TYPE
+ installer_ip = CI_INSTALLER_IP
installer_username = ft_utils.get_functest_config(
"multisite." + installer_type +
"_environment.installer_username")
diff --git a/functest/opnfv_tests/OpenStack/tempest/run_tempest.py b/functest/opnfv_tests/OpenStack/tempest/run_tempest.py
index d2c01c60..cbf92c1f 100755
--- a/functest/opnfv_tests/OpenStack/tempest/run_tempest.py
+++ b/functest/opnfv_tests/OpenStack/tempest/run_tempest.py
@@ -27,6 +27,7 @@ import yaml
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
+import functest.utils.functest_constants as ft_constants
modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing',
'identity', 'image', 'network', 'object_storage', 'orchestration',
@@ -58,69 +59,50 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("run_tempest").getLogger()
-TEST_DB = ft_utils.get_functest_config('results.test_db_url')
-
-MODE = "smoke"
-GLANCE_IMAGE_NAME = \
- ft_utils.get_functest_config('general.openstack.image_name')
-GLANCE_IMAGE_FILENAME = \
- ft_utils.get_functest_config('general.openstack.image_file_name')
-GLANCE_IMAGE_FORMAT = \
- ft_utils.get_functest_config('general.openstack.image_disk_format')
-GLANCE_IMAGE_PATH = \
- ft_utils.get_functest_config('general.directories.dir_functest_data') + \
+GLANCE_IMAGE_NAME = ft_constants.GLANCE_IMAGE_NAME
+GLANCE_IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
+GLANCE_IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
+GLANCE_IMAGE_PATH = ft_constants.FUNCTEST_DATA_DIR + \
"/" + GLANCE_IMAGE_FILENAME
-IMAGE_ID = None
IMAGE_ID_ALT = None
-FLAVOR_NAME = \
- ft_utils.get_functest_config('general.openstack.flavor_name')
-FLAVOR_RAM = ft_utils.get_functest_config('general.openstack.flavor_ram')
-FLAVOR_DISK = ft_utils.get_functest_config('general.openstack.flavor_disk')
-FLAVOR_VCPUS = ft_utils.get_functest_config('general.openstack.flavor_vcpus')
-FLAVOR_ID = None
+FLAVOR_NAME = ft_constants.FLAVOR_NAME
+FLAVOR_RAM = ft_constants.FLAVOR_RAM
+FLAVOR_DISK = ft_constants.FLAVOR_DISK
+FLAVOR_VCPUS = ft_constants.FLAVOR_VCPUS
FLAVOR_ID_ALT = None
-PRIVATE_NET_NAME = \
- ft_utils.get_functest_config('tempest.private_net_name')
-PRIVATE_SUBNET_NAME = \
- ft_utils.get_functest_config('tempest.private_subnet_name')
-PRIVATE_SUBNET_CIDR = \
- ft_utils.get_functest_config('tempest.private_subnet_cidr')
-ROUTER_NAME = \
- ft_utils.get_functest_config('tempest.router_name')
-TENANT_NAME = \
- ft_utils.get_functest_config('tempest.identity.tenant_name')
-TENANT_DESCRIPTION = \
- ft_utils.get_functest_config('tempest.identity.tenant_description')
-USER_NAME = \
- ft_utils.get_functest_config('tempest.identity.user_name')
-USER_PASSWORD = \
- ft_utils.get_functest_config('tempest.identity.user_password')
-SSH_TIMEOUT = \
- ft_utils.get_functest_config('tempest.validation.ssh_timeout')
-USE_CUSTOM_IMAGES = \
- ft_utils.get_functest_config('tempest.use_custom_images')
-USE_CUSTOM_FLAVORS = \
- ft_utils.get_functest_config('tempest.use_custom_flavors')
-
-DEPLOYMENT_MAME = \
- ft_utils.get_functest_config('rally.deployment_name')
-RALLY_INSTALLATION_DIR = \
- ft_utils.get_functest_config('general.directories.dir_rally_inst')
-
-RESULTS_DIR = \
- ft_utils.get_functest_config('general.directories.dir_results')
-TEMPEST_RESULTS_DIR = RESULTS_DIR + '/tempest'
-
-REPO_PATH = ft_utils.FUNCTEST_REPO + '/'
-TEST_LIST_DIR = \
- ft_utils.get_functest_config('general.directories.dir_tempest_cases')
-TEMPEST_CUSTOM = REPO_PATH + TEST_LIST_DIR + 'test_list.txt'
-TEMPEST_BLACKLIST = REPO_PATH + TEST_LIST_DIR + 'blacklist.txt'
-TEMPEST_DEFCORE = REPO_PATH + TEST_LIST_DIR + 'defcore_req.txt'
-TEMPEST_RAW_LIST = TEMPEST_RESULTS_DIR + '/test_raw_list.txt'
-TEMPEST_LIST = TEMPEST_RESULTS_DIR + '/test_list.txt'
+TEMPEST_PRIVATE_NET_NAME = ft_constants.TEMPEST_PRIVATE_NET_NAME
+TEMPEST_PRIVATE_SUBNET_NAME = ft_constants.TEMPEST_PRIVATE_SUBNET_NAME
+TEMPEST_PRIVATE_SUBNET_CIDR = ft_constants.TEMPEST_PRIVATE_SUBNET_CIDR
+TEMPEST_ROUTER_NAME = ft_constants.TEMPEST_ROUTER_NAME
+TEMPEST_TENANT_NAME = ft_constants.TEMPEST_TENANT_NAME
+TEMPEST_TENANT_DESCRIPTION = ft_constants.TEMPEST_TENANT_DESCRIPTION
+TEMPEST_USER_NAME = ft_constants.TEMPEST_USER_NAME
+TEMPEST_USER_PASSWORD = ft_constants.TEMPEST_USER_PASSWORD
+TEMPEST_SSH_TIMEOUT = ft_constants.TEMPEST_SSH_TIMEOUT
+TEMPEST_USE_CUSTOM_IMAGES = ft_constants.TEMPEST_USE_CUSTOM_IMAGES
+TEMPEST_USE_CUSTOM_FLAVORS = ft_constants.TEMPEST_USE_CUSTOM_FLAVORS
+
+RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
+TEMPEST_RESULTS_DIR = os.path.join(RESULTS_DIR, 'tempest')
+
+REPO_PATH = ft_constants.FUNCTEST_REPO_DIR
+TEMPEST_TEST_LIST_DIR = ft_constants.TEMPEST_TEST_LIST_DIR
+TEMPEST_CUSTOM = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
+ 'test_list.txt')
+TEMPEST_BLACKLIST = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
+ 'blacklist.txt')
+TEMPEST_DEFCORE = os.path.join(REPO_PATH, TEMPEST_TEST_LIST_DIR,
+ 'defcore_req.txt')
+TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
+TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
+
+
+class GlobalVariables:
+ IMAGE_ID = None
+ FLAVOR_ID = None
+ MODE = "smoke"
def get_info(file_result):
@@ -150,43 +132,41 @@ def create_tempest_resources():
logger.debug("Creating tenant and user for Tempest suite")
tenant_id = os_utils.create_tenant(keystone_client,
- TENANT_NAME,
- TENANT_DESCRIPTION)
+ TEMPEST_TENANT_NAME,
+ TEMPEST_TENANT_DESCRIPTION)
if not tenant_id:
- logger.error("Error : Failed to create %s tenant" % TENANT_NAME)
+ logger.error("Error : Failed to create %s tenant"
+ % TEMPEST_TENANT_NAME)
- user_id = os_utils.create_user(keystone_client, USER_NAME, USER_PASSWORD,
+ user_id = os_utils.create_user(keystone_client, TEMPEST_USER_NAME,
+ TEMPEST_USER_PASSWORD,
None, tenant_id)
if not user_id:
- logger.error("Error : Failed to create %s user" % USER_NAME)
+ logger.error("Error : Failed to create %s user" % TEMPEST_USER_NAME)
logger.debug("Creating private network for Tempest suite")
- network_dic = os_utils.create_shared_network_full(PRIVATE_NET_NAME,
- PRIVATE_SUBNET_NAME,
- ROUTER_NAME,
- PRIVATE_SUBNET_CIDR)
+ network_dic = \
+ os_utils.create_shared_network_full(TEMPEST_PRIVATE_NET_NAME,
+ TEMPEST_PRIVATE_SUBNET_NAME,
+ TEMPEST_ROUTER_NAME,
+ TEMPEST_PRIVATE_SUBNET_CIDR)
if not network_dic:
exit(1)
- if USE_CUSTOM_IMAGES:
+ if TEMPEST_USE_CUSTOM_IMAGES:
# adding alternative image should be trivial should we need it
logger.debug("Creating image for Tempest suite")
- global IMAGE_ID
- _, IMAGE_ID = os_utils.get_or_create_image(GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH,
- GLANCE_IMAGE_FORMAT)
- if not IMAGE_ID:
+ _, GlobalVariables.IMAGE_ID = os_utils.get_or_create_image(
+ GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH, GLANCE_IMAGE_FORMAT)
+ if not GlobalVariables.IMAGE_ID:
exit(-1)
- if USE_CUSTOM_FLAVORS:
+ if TEMPEST_USE_CUSTOM_FLAVORS:
# adding alternative flavor should be trivial should we need it
logger.debug("Creating flavor for Tempest suite")
- global FLAVOR_ID
- _, FLAVOR_ID = os_utils.get_or_create_flavor(FLAVOR_NAME,
- FLAVOR_RAM,
- FLAVOR_DISK,
- FLAVOR_VCPUS)
- if not FLAVOR_ID:
+ _, GlobalVariables.FLAVOR_ID = os_utils.get_or_create_flavor(
+ FLAVOR_NAME, FLAVOR_RAM, FLAVOR_DISK, FLAVOR_VCPUS)
+ if not GlobalVariables.FLAVOR_ID:
exit(-1)
@@ -213,23 +193,23 @@ def configure_tempest(deployment_dir):
logger.debug("Updating selected tempest.conf parameters...")
config = ConfigParser.RawConfigParser()
config.read(tempest_conf_file)
- config.set('compute', 'fixed_network_name', PRIVATE_NET_NAME)
- if USE_CUSTOM_IMAGES:
- if IMAGE_ID is not None:
- config.set('compute', 'image_ref', IMAGE_ID)
+ config.set('compute', 'fixed_network_name', TEMPEST_PRIVATE_NET_NAME)
+ if TEMPEST_USE_CUSTOM_IMAGES:
+ if GlobalVariables.IMAGE_ID is not None:
+ config.set('compute', 'image_ref', GlobalVariables.IMAGE_ID)
if IMAGE_ID_ALT is not None:
config.set('compute', 'image_ref_alt', IMAGE_ID_ALT)
- if USE_CUSTOM_FLAVORS:
- if FLAVOR_ID is not None:
- config.set('compute', 'flavor_ref', FLAVOR_ID)
+ if TEMPEST_USE_CUSTOM_FLAVORS:
+ if GlobalVariables.FLAVOR_ID is not None:
+ config.set('compute', 'flavor_ref', GlobalVariables.FLAVOR_ID)
if FLAVOR_ID_ALT is not None:
config.set('compute', 'flavor_ref_alt', FLAVOR_ID_ALT)
- config.set('identity', 'tenant_name', TENANT_NAME)
- config.set('identity', 'username', USER_NAME)
- config.set('identity', 'password', USER_PASSWORD)
- config.set('validation', 'ssh_timeout', SSH_TIMEOUT)
+ config.set('identity', 'tenant_name', TEMPEST_TENANT_NAME)
+ config.set('identity', 'username', TEMPEST_USER_NAME)
+ config.set('identity', 'password', TEMPEST_USER_PASSWORD)
+ config.set('validation', 'ssh_timeout', TEMPEST_SSH_TIMEOUT)
- if os.getenv('OS_ENDPOINT_TYPE') is not None:
+ if ft_constants.OS_ENDPOINT_TYPE is not None:
services_list = ['compute', 'volume', 'image', 'network',
'data-processing', 'object-storage', 'orchestration']
sections = config.sections()
@@ -237,7 +217,7 @@ def configure_tempest(deployment_dir):
if service not in sections:
config.add_section(service)
config.set(service, 'endpoint_type',
- os.environ.get("OS_ENDPOINT_TYPE"))
+ ft_constants.OS_ENDPOINT_TYPE)
with open(tempest_conf_file, 'wb') as config_file:
config.write(config_file)
@@ -283,8 +263,8 @@ def apply_tempest_blacklist():
result_file = open(TEMPEST_LIST, 'w')
black_tests = []
try:
- installer_type = os.getenv('INSTALLER_TYPE')
- deploy_scenario = os.getenv('DEPLOY_SCENARIO')
+ installer_type = ft_constants.CI_INSTALLER_TYPE
+ deploy_scenario = ft_constants.CI_SCENARIO
if (bool(installer_type) * bool(deploy_scenario)):
# if INSTALLER_TYPE and DEPLOY_SCENARIO are set we read the file
black_list_file = open(TEMPEST_BLACKLIST)
@@ -325,9 +305,9 @@ def run_tempest(OPTION):
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'),
+ (ft_constants.CI_INSTALLER_TYPE,
+ ft_constants.CI_SCENARIO,
+ ft_constants.CI_NODE,
time.strftime("%a %b %d %H:%M:%S %Z %Y")))
f_stdout = open(TEMPEST_RESULTS_DIR + "/tempest.log", 'w+')
@@ -434,7 +414,6 @@ def run_tempest(OPTION):
def main():
- global MODE
if not (args.mode in modes):
logger.error("Tempest mode not valid. "
@@ -448,19 +427,19 @@ def main():
create_tempest_resources()
if "" == args.conf:
- MODE = ""
+ GlobalVariables.MODE = ""
configure_tempest(deployment_dir)
else:
- MODE = " --tempest-config " + args.conf
+ GlobalVariables.MODE = " --tempest-config " + args.conf
generate_test_list(deployment_dir, args.mode)
apply_tempest_blacklist()
- MODE += " --tests-file " + TEMPEST_LIST
+ GlobalVariables.MODE += " --tests-file " + TEMPEST_LIST
if args.serial:
- MODE += " --concur 1"
+ GlobalVariables.MODE += " --concur 1"
- ret_val = run_tempest(MODE)
+ ret_val = run_tempest(GlobalVariables.MODE)
if ret_val != 0:
sys.exit(-1)
diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py
index ab016262..d003779e 100755
--- a/functest/opnfv_tests/features/copper.py
+++ b/functest/opnfv_tests/features/copper.py
@@ -20,7 +20,7 @@ import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
-
+import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
@@ -28,16 +28,14 @@ parser.add_argument("-r", "--report",
action="store_true")
args = parser.parse_args()
-COPPER_REPO = \
- functest_utils.get_functest_config('general.directories.dir_repo_copper')
-RESULTS_DIR = \
- functest_utils.get_functest_config('general.directories.dir_results')
+COPPER_REPO_DIR = ft_constants.COPPER_REPO_DIR
+RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
logger = ft_logger.Logger("copper").getLogger()
def main():
- cmd = "%s/tests/run.sh %s/tests" % (COPPER_REPO, COPPER_REPO)
+ cmd = "%s/tests/run.sh %s/tests" % (COPPER_REPO_DIR, COPPER_REPO_DIR)
start_time = time.time()
@@ -80,5 +78,6 @@ def main():
sys.exit(0)
+
if __name__ == '__main__':
main()
diff --git a/functest/opnfv_tests/features/doctor.py b/functest/opnfv_tests/features/doctor.py
index 00e5c1d6..dbd803a6 100755
--- a/functest/opnfv_tests/features/doctor.py
+++ b/functest/opnfv_tests/features/doctor.py
@@ -19,7 +19,7 @@ import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
-
+import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
@@ -29,10 +29,8 @@ args = parser.parse_args()
functest_yaml = functest_utils.get_functest_yaml()
-DOCTOR_REPO = \
- functest_utils.get_functest_config('general.directories.dir_repo_doctor')
-RESULTS_DIR = \
- functest_utils.get_functest_config('general.directories.dir_results')
+DOCTOR_REPO_DIR = ft_constants.DOCTOR_REPO_DIR
+RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
logger = ft_logger.Logger("doctor").getLogger()
@@ -45,7 +43,7 @@ def main():
if 'doctor' in functest_yaml and 'image_name' in functest_yaml['doctor']:
os.environ["IMAGE_NAME"] = functest_yaml['doctor']['image_name']
- cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
+ cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO_DIR
log_file = RESULTS_DIR + "/doctor.log"
start_time = time.time()
@@ -86,5 +84,6 @@ def main():
exit(exit_code)
+
if __name__ == '__main__':
main()
diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py
index be3dd549..2deeb4c4 100755
--- a/functest/opnfv_tests/features/domino.py
+++ b/functest/opnfv_tests/features/domino.py
@@ -21,13 +21,12 @@ import time
from functest.core import TestCasesBase
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
+import functest.utils.functest_constants as ft_constants
class DominoCases(TestCasesBase.TestCasesBase):
- DOMINO_REPO = \
- ft_utils.get_functest_config('general.directories.dir_repo_domino')
- RESULTS_DIR = \
- ft_utils.get_functest_config('general.directories.dir_results')
+ DOMINO_REPO = ft_constants.DOMINO_REPO
+ RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
logger = ft_logger.Logger("domino").getLogger()
def __init__(self):
@@ -66,6 +65,7 @@ class DominoCases(TestCasesBase.TestCasesBase):
kwargs = {}
return self.main(**kwargs)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
diff --git a/functest/opnfv_tests/features/multisite.py b/functest/opnfv_tests/features/multisite.py
index 6d492182..15cfe2a4 100755
--- a/functest/opnfv_tests/features/multisite.py
+++ b/functest/opnfv_tests/features/multisite.py
@@ -17,5 +17,6 @@ logger = ft_logger.Logger("multisite").getLogger()
def main():
logger.info("multisite OK")
+
if __name__ == '__main__':
main()
diff --git a/functest/opnfv_tests/features/promise.py b/functest/opnfv_tests/features/promise.py
index e198bde2..0a30e3a1 100755
--- a/functest/opnfv_tests/features/promise.py
+++ b/functest/opnfv_tests/features/promise.py
@@ -21,7 +21,7 @@ import functest.utils.openstack_utils as openstack_utils
import keystoneclient.v2_0.client as ksclient
from neutronclient.v2_0 import client as ntclient
import novaclient.client as nvclient
-
+import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
@@ -32,34 +32,29 @@ parser.add_argument("-r", "--report",
args = parser.parse_args()
-dirs = ft_utils.get_functest_config('general.directories')
-PROMISE_REPO = dirs.get('dir_repo_promise')
-RESULTS_DIR = ft_utils.get_functest_config('general.directories.dir_results')
+PROMISE_REPO_DIR = ft_constants.PROMISE_REPO_DIR
+RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
-TENANT_NAME = ft_utils.get_functest_config('promise.tenant_name')
-TENANT_DESCRIPTION = \
- ft_utils.get_functest_config('promise.tenant_description')
-USER_NAME = ft_utils.get_functest_config('promise.user_name')
-USER_PWD = ft_utils.get_functest_config('promise.user_pwd')
-IMAGE_NAME = ft_utils.get_functest_config('promise.image_name')
-FLAVOR_NAME = ft_utils.get_functest_config('promise.flavor_name')
-FLAVOR_VCPUS = ft_utils.get_functest_config('promise.flavor_vcpus')
-FLAVOR_RAM = ft_utils.get_functest_config('promise.flavor_ram')
-FLAVOR_DISK = ft_utils.get_functest_config('promise.flavor_disk')
+PROMISE_TENANT_NAME = ft_constants.PROMISE_TENANT_NAME
+TENANT_DESCRIPTION = ft_constants.TENANT_DESCRIPTION
+PROMISE_USER_NAME = ft_constants.PROMISE_USER_NAME
+PROMISE_USER_PWD = ft_constants.PROMISE_USER_PWD
+PROMISE_IMAGE_NAME = ft_constants.PROMISE_IMAGE_NAME
+PROMISE_FLAVOR_NAME = ft_constants.PROMISE_FLAVOR_NAME
+PROMISE_FLAVOR_VCPUS = ft_constants.PROMISE_FLAVOR_VCPUS
+PROMISE_FLAVOR_RAM = ft_constants.PROMISE_FLAVOR_RAM
+PROMISE_FLAVOR_DISK = ft_constants.PROMISE_FLAVOR_DISK
-GLANCE_IMAGE_FILENAME = \
- ft_utils.get_functest_config('general.openstack.image_file_name')
-GLANCE_IMAGE_FORMAT = \
- ft_utils.get_functest_config('general.openstack.image_disk_format')
-GLANCE_IMAGE_PATH = \
- ft_utils.get_functest_config('general.directories.dir_functest_data') + \
- "/" + GLANCE_IMAGE_FILENAME
+GLANCE_IMAGE_FILENAME = ft_constants.GLANCE_IMAGE_FILENAME
+GLANCE_IMAGE_FORMAT = ft_constants.GLANCE_IMAGE_FORMAT
+GLANCE_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
+ GLANCE_IMAGE_FILENAME)
-NET_NAME = ft_utils.get_functest_config('promise.network_name')
-SUBNET_NAME = ft_utils.get_functest_config('promise.subnet_name')
-SUBNET_CIDR = ft_utils.get_functest_config('promise.subnet_cidr')
-ROUTER_NAME = ft_utils.get_functest_config('promise.router_name')
+PROMISE_NET_NAME = ft_constants.PROMISE_NET_NAME
+PROMISE_SUBNET_NAME = ft_constants.PROMISE_SUBNET_NAME
+PROMISE_SUBNET_CIDR = ft_constants.PROMISE_SUBNET_CIDR
+PROMISE_ROUTER_NAME = ft_constants.PROMISE_ROUTER_NAME
""" logging configuration """
@@ -81,13 +76,14 @@ def main():
ks_creds['username'])
exit(-1)
- logger.info("Creating tenant '%s'..." % TENANT_NAME)
+ logger.info("Creating tenant '%s'..." % PROMISE_TENANT_NAME)
tenant_id = openstack_utils.create_tenant(
- keystone, TENANT_NAME, TENANT_DESCRIPTION)
+ keystone, PROMISE_TENANT_NAME, TENANT_DESCRIPTION)
if not tenant_id:
- logger.error("Error : Failed to create %s tenant" % TENANT_NAME)
+ logger.error("Error : Failed to create %s tenant"
+ % PROMISE_TENANT_NAME)
exit(-1)
- logger.debug("Tenant '%s' created successfully." % TENANT_NAME)
+ logger.debug("Tenant '%s' created successfully." % PROMISE_TENANT_NAME)
roles_name = ["admin", "Admin"]
role_id = ''
@@ -99,90 +95,91 @@ def main():
logger.error("Error : Failed to get id for %s role" % role_name)
exit(-1)
- logger.info("Adding role '%s' to tenant '%s'..." % (role_id, TENANT_NAME))
+ logger.info("Adding role '%s' to tenant '%s'..."
+ % (role_id, PROMISE_TENANT_NAME))
if not openstack_utils.add_role_user(keystone, user_id,
role_id, tenant_id):
logger.error("Error : Failed to add %s on tenant %s" %
- (ks_creds['username'], TENANT_NAME))
+ (ks_creds['username'], PROMISE_TENANT_NAME))
exit(-1)
logger.debug("Role added successfully.")
- logger.info("Creating user '%s'..." % USER_NAME)
+ logger.info("Creating user '%s'..." % PROMISE_USER_NAME)
user_id = openstack_utils.create_user(
- keystone, USER_NAME, USER_PWD, None, tenant_id)
+ keystone, PROMISE_USER_NAME, PROMISE_USER_PWD, None, tenant_id)
if not user_id:
- logger.error("Error : Failed to create %s user" % USER_NAME)
+ logger.error("Error : Failed to create %s user" % PROMISE_USER_NAME)
exit(-1)
- logger.debug("User '%s' created successfully." % USER_NAME)
+ logger.debug("User '%s' created successfully." % PROMISE_USER_NAME)
logger.info("Updating OpenStack credentials...")
ks_creds.update({
- "username": TENANT_NAME,
- "password": TENANT_NAME,
- "tenant_name": TENANT_NAME,
+ "username": PROMISE_TENANT_NAME,
+ "password": PROMISE_TENANT_NAME,
+ "tenant_name": PROMISE_TENANT_NAME,
})
nt_creds.update({
- "tenant_name": TENANT_NAME,
+ "tenant_name": PROMISE_TENANT_NAME,
})
nv_creds.update({
- "project_id": TENANT_NAME,
+ "project_id": PROMISE_TENANT_NAME,
})
glance = openstack_utils.get_glance_client()
nova = nvclient.Client("2", **nv_creds)
- logger.info("Creating image '%s' from '%s'..." % (IMAGE_NAME,
+ logger.info("Creating image '%s' from '%s'..." % (PROMISE_IMAGE_NAME,
GLANCE_IMAGE_PATH))
image_id = openstack_utils.create_glance_image(glance,
- IMAGE_NAME,
+ PROMISE_IMAGE_NAME,
GLANCE_IMAGE_PATH)
if not image_id:
logger.error("Failed to create the Glance image...")
exit(-1)
- logger.debug("Image '%s' with ID '%s' created successfully." % (IMAGE_NAME,
- image_id))
- flavor_id = openstack_utils.get_flavor_id(nova, FLAVOR_NAME)
+ logger.debug("Image '%s' with ID '%s' created successfully."
+ % (PROMISE_IMAGE_NAME, image_id))
+ flavor_id = openstack_utils.get_flavor_id(nova, PROMISE_FLAVOR_NAME)
if flavor_id == '':
- logger.info("Creating flavor '%s'..." % FLAVOR_NAME)
+ logger.info("Creating flavor '%s'..." % PROMISE_FLAVOR_NAME)
flavor_id = openstack_utils.create_flavor(nova,
- FLAVOR_NAME,
- FLAVOR_RAM,
- FLAVOR_DISK,
- FLAVOR_VCPUS)
+ PROMISE_FLAVOR_NAME,
+ PROMISE_FLAVOR_RAM,
+ PROMISE_FLAVOR_DISK,
+ PROMISE_FLAVOR_VCPUS)
if not flavor_id:
logger.error("Failed to create the Flavor...")
exit(-1)
logger.debug("Flavor '%s' with ID '%s' created successfully." %
- (FLAVOR_NAME, flavor_id))
+ (PROMISE_FLAVOR_NAME, flavor_id))
else:
logger.debug("Using existing flavor '%s' with ID '%s'..."
- % (FLAVOR_NAME, flavor_id))
+ % (PROMISE_FLAVOR_NAME, flavor_id))
neutron = ntclient.Client(**nt_creds)
network_dic = openstack_utils.create_network_full(neutron,
- NET_NAME,
- SUBNET_NAME,
- ROUTER_NAME,
- SUBNET_CIDR)
+ PROMISE_NET_NAME,
+ PROMISE_SUBNET_NAME,
+ PROMISE_ROUTER_NAME,
+ PROMISE_SUBNET_CIDR)
if not network_dic:
logger.error("Failed to create the private network...")
exit(-1)
logger.info("Exporting environment variables...")
os.environ["NODE_ENV"] = "functest"
- os.environ["OS_TENANT_NAME"] = TENANT_NAME
- os.environ["OS_USERNAME"] = USER_NAME
- os.environ["OS_PASSWORD"] = USER_PWD
+ os.environ["OS_PASSWORD"] = PROMISE_USER_PWD
os.environ["OS_TEST_IMAGE"] = image_id
os.environ["OS_TEST_FLAVOR"] = flavor_id
os.environ["OS_TEST_NETWORK"] = network_dic["net_id"]
+ os.environ["OS_TENANT_NAME"] = PROMISE_TENANT_NAME
+ os.environ["OS_USERNAME"] = PROMISE_USER_NAME
- os.chdir(PROMISE_REPO + '/source/')
- results_file_name = RESULTS_DIR + '/' + 'promise-results.json'
+ os.chdir(PROMISE_REPO_DIR + '/source/')
+ results_file_name = os.path.join(RESULTS_DIR, 'promise-results.json')
results_file = open(results_file_name, 'w+')
cmd = 'npm run -s test -- --reporter json'
diff --git a/functest/opnfv_tests/security_scan/connect.py b/functest/opnfv_tests/security_scan/connect.py
index 18ca96d8..3d5456c5 100644
--- a/functest/opnfv_tests/security_scan/connect.py
+++ b/functest/opnfv_tests/security_scan/connect.py
@@ -15,9 +15,10 @@ import socket
import paramiko
import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_constants as ft_constants
# add installer IP from env
-INSTALLER_IP = os.getenv('INSTALLER_IP')
+INSTALLER_IP = ft_constants.CI_INSTALLER_IP
# Set up loggers
logger = ft_logger.Logger("security_scan").getLogger()
diff --git a/functest/opnfv_tests/security_scan/scripts/internet_check.py b/functest/opnfv_tests/security_scan/scripts/internet_check.py
index 1bed50a7..d417d174 100644
--- a/functest/opnfv_tests/security_scan/scripts/internet_check.py
+++ b/functest/opnfv_tests/security_scan/scripts/internet_check.py
@@ -22,4 +22,6 @@ def is_connected():
return True
except:
return False
+
+
print is_connected()
diff --git a/functest/opnfv_tests/security_scan/security_scan.py b/functest/opnfv_tests/security_scan/security_scan.py
index 4e0407fb..f0673924 100755
--- a/functest/opnfv_tests/security_scan/security_scan.py
+++ b/functest/opnfv_tests/security_scan/security_scan.py
@@ -24,23 +24,23 @@ from keystoneclient.auth.identity import v2
from novaclient import client
import connect
-import functest.utils.functest_utils as ft_utils
+import functest.utils.functest_constants as ft_constants
__version__ = 0.1
__author__ = 'Luke Hinds (lhinds@redhat.com)'
__url__ = 'https://wiki.opnfv.org/display/functest/Functest+Security'
# Global vars
-INSTALLER_IP = os.getenv('INSTALLER_IP')
+INSTALLER_IP = ft_constants.CI_INSTALLER_IP
oscapbin = 'sudo /bin/oscap'
-functest_dir = '%s/opnfv_tests/security_scan/' % ft_utils.FUNCTEST_REPO
+functest_dir = '%s/security_scan/' % ft_constants.FUNCTEST_TEST_DIR
# Apex Spefic var needed to query Undercloud
-if os.getenv('OS_AUTH_URL') is None:
+if ft_constants.OS_AUTH_URL is None:
connect.logger.error(" Enviroment variable OS_AUTH_URL is not set")
sys.exit(0)
else:
- OS_AUTH_URL = os.getenv('OS_AUTH_URL')
+ OS_AUTH_URL = ft_constants.OS_AUTH_URL
# args
parser = argparse.ArgumentParser(description='OPNFV OpenSCAP Scanner')
@@ -71,6 +71,10 @@ sess = session.Session(auth=auth)
nova = client.Client(2, session=sess)
+class GlobalVariables:
+ tmpdir = ""
+
+
def run_tests(host, nodetype):
user = cfgparse.get(nodetype, 'user')
port = cfgparse.get(nodetype, 'port')
@@ -133,13 +137,12 @@ def internet_check(host, nodetype):
def createfiles(host, port, user, localkey):
import connect
- global tmpdir
localpath = functest_dir + 'scripts/createfiles.py'
remotepath = '/tmp/createfiles.py'
com = 'python /tmp/createfiles.py'
connect = connect.ConnectionManager(host, port, user, localkey,
localpath, remotepath, com)
- tmpdir = connect.remotescript()
+ GlobalVariables.tmpdir = connect.remotescript()
def install_pkg(host, port, user, localkey):
@@ -160,18 +163,20 @@ def run_scanner(host, port, user, localkey, nodetype):
if scantype == 'xccdf':
cpe = cfgparse.get(nodetype, 'cpe')
com = '{0} xccdf eval --profile {1} --results {2}/{3}' \
- ' --report {2}/{4} --cpe {5} {6}'.format(oscapbin,
- profile,
- tmpdir.rstrip(),
- results,
- report,
- cpe,
- secpolicy)
+ ' --report {2}/{4}' \
+ ' --cpe {5} {6}'.format(oscapbin,
+ profile,
+ GlobalVariables.tmpdir.rstrip(),
+ results,
+ report,
+ cpe,
+ secpolicy)
connect = connect.ConnectionManager(host, port, user, localkey, com)
connect.remotecmd()
elif scantype == 'oval':
com = '{0} oval eval --results {1}/{2} '
- '--report {1}/{3} {4}'.format(oscapbin, tmpdir.rstrip(),
+ '--report {1}/{3} {4}'.format(oscapbin,
+ GlobalVariables.tmpdir.rstrip(),
results, report, secpolicy)
connect = connect.ConnectionManager(host, port, user, localkey, com)
connect.remotecmd()
@@ -191,7 +196,7 @@ def post_tasks(host, port, user, localkey, nodetype):
os.makedirs(dl_folder, 0755)
report = cfgparse.get(nodetype, 'report')
results = cfgparse.get(nodetype, 'results')
- reportfile = '{0}/{1}'.format(tmpdir.rstrip(), report)
+ reportfile = '{0}/{1}'.format(GlobalVariables.tmpdir.rstrip(), report)
connect = connect.ConnectionManager(host, port, user, localkey, dl_folder,
reportfile, report, results)
connect.download_reports()
@@ -206,7 +211,7 @@ def removepkg(host, port, user, localkey, nodetype):
def cleandir(host, port, user, localkey, nodetype):
import connect
- com = 'sudo rm -r {0}'.format(tmpdir.rstrip())
+ com = 'sudo rm -r {0}'.format(GlobalVariables.tmpdir.rstrip())
connect = connect.ConnectionManager(host, port, user, localkey, com)
connect.remotecmd()
diff --git a/functest/opnfv_tests/vnf/vIMS/vIMS.py b/functest/opnfv_tests/vnf/vIMS/vIMS.py
index 50aa715f..4cc8ce30 100755
--- a/functest/opnfv_tests/vnf/vIMS/vIMS.py
+++ b/functest/opnfv_tests/vnf/vIMS/vIMS.py
@@ -29,6 +29,7 @@ import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
from clearwater import clearwater
from orchestrator import orchestrator
+import functest.utils.functest_constants as ft_constants
pp = pprint.PrettyPrinter(indent=4)
@@ -48,39 +49,21 @@ logger = ft_logger.Logger("vIMS").getLogger()
# Cloudify parameters
-VIMS_DIR = ft_utils.FUNCTEST_REPO + '/' + \
- ft_utils.get_functest_config('general.directories.dir_vIMS')
-
-VIMS_DATA_DIR = \
- ft_utils.get_functest_config('general.directories.dir_vIMS_data') + \
- '/'
-VIMS_TEST_DIR = \
- ft_utils.get_functest_config('general.directories.dir_repo_vims_test') + \
- '/'
-DB_URL = \
- ft_utils.get_functest_config('results.test_db_url')
-
-TENANT_NAME = \
- ft_utils.get_functest_config('vIMS.general.tenant_name')
-TENANT_DESCRIPTION = \
- ft_utils.get_functest_config('vIMS.general.tenant_description')
-IMAGES = \
- ft_utils.get_functest_config('vIMS.general.images')
-
-CFY_MANAGER_BLUEPRINT = \
- ft_utils.get_functest_config('vIMS.cloudify.blueprint')
-CFY_MANAGER_REQUIERMENTS = \
- ft_utils.get_functest_config('vIMS.cloudify.requierments')
-CFY_INPUTS = ft_utils.get_functest_config('vIMS.cloudify.inputs')
-
-CW_BLUEPRINT = \
- ft_utils.get_functest_config('vIMS.clearwater.blueprint')
-CW_DEPLOYMENT_NAME = \
- ft_utils.get_functest_config('vIMS.clearwater.deployment-name')
-CW_INPUTS = \
- ft_utils.get_functest_config('vIMS.clearwater.inputs')
-CW_REQUIERMENTS = \
- ft_utils.get_functest_config('vIMS.clearwater.requierments')
+VIMS_DIR = os.path.join(ft_constants.FUNCTEST_TEST_DIR, 'vnf/vIMS/')
+VIMS_DATA_DIR = ft_constants.VIMS_DATA_DIR
+VIMS_TEST_DIR = ft_constants.VIMS_TEST_DIR
+VIMS_TENANT_NAME = ft_constants.VIMS_TENANT_NAME
+VIMS_TENANT_DESCRIPTION = ft_constants.VIMS_TENANT_DESCRIPTION
+VIMS_IMAGES = ft_constants.VIMS_IMAGES
+
+CFY_MANAGER_BLUEPRINT = ft_constants.CFY_MANAGER_BLUEPRINT
+CFY_MANAGER_REQUIERMENTS = ft_constants.CFY_MANAGER_REQUIERMENTS
+CFY_INPUTS = ft_constants.CFY_INPUTS
+
+CW_BLUEPRINT = ft_constants.CW_BLUEPRINT
+CW_DEPLOYMENT_NAME = ft_constants.CW_DEPLOYMENT_NAME
+CW_INPUTS = ft_constants.CW_INPUTS
+CW_REQUIERMENTS = ft_constants.CW_REQUIERMENTS
CFY_DEPLOYMENT_DURATION = 0
CW_DEPLOYMENT_DURATION = 0
@@ -92,7 +75,7 @@ RESULTS = {'orchestrator': {'duration': 0, 'result': ''},
def download_and_add_image_on_glance(glance, image_name, image_url):
- dest_path = VIMS_DATA_DIR + "tmp/"
+ dest_path = os.path.join(VIMS_DATA_DIR, "tmp/")
if not os.path.exists(dest_path):
os.makedirs(dest_path)
file_name = image_url.rsplit('/')[-1]
@@ -216,9 +199,10 @@ def test_clearwater():
logger.debug(result)
vims_test_result = ""
+ tempFile = os.path.join(VIMS_TEST_DIR, "temp.json")
try:
logger.debug("Trying to load test results")
- with open(VIMS_TEST_DIR + "temp.json") as f:
+ with open(tempFile) as f:
vims_test_result = json.load(f)
f.close()
except:
@@ -246,7 +230,7 @@ def test_clearwater():
RESULTS)
try:
- os.remove(VIMS_TEST_DIR + "temp.json")
+ os.remove(tempFile)
except:
logger.error("Deleting file failed")
@@ -271,10 +255,10 @@ def main():
ks_creds['username'])
tenant_id = os_utils.create_tenant(
- keystone, TENANT_NAME, TENANT_DESCRIPTION)
+ keystone, VIMS_TENANT_NAME, VIMS_TENANT_DESCRIPTION)
if not tenant_id:
step_failure("init", "Error : Failed to create " +
- TENANT_NAME + " tenant")
+ VIMS_TENANT_NAME + " tenant")
roles_name = ["admin", "Admin"]
role_id = ''
@@ -290,31 +274,31 @@ def main():
ks_creds['username'])
user_id = os_utils.create_user(
- keystone, TENANT_NAME, TENANT_NAME, None, tenant_id)
+ keystone, VIMS_TENANT_NAME, VIMS_TENANT_NAME, None, tenant_id)
if not user_id:
- logger.error("Error : Failed to create %s user" % TENANT_NAME)
+ logger.error("Error : Failed to create %s user" % VIMS_TENANT_NAME)
logger.info("Update OpenStack creds informations")
ks_creds.update({
- "username": TENANT_NAME,
- "password": TENANT_NAME,
- "tenant_name": TENANT_NAME,
+ "username": VIMS_TENANT_NAME,
+ "password": VIMS_TENANT_NAME,
+ "tenant_name": VIMS_TENANT_NAME,
})
nt_creds.update({
- "tenant_name": TENANT_NAME,
+ "tenant_name": VIMS_TENANT_NAME,
})
nv_creds.update({
- "project_id": TENANT_NAME,
+ "project_id": VIMS_TENANT_NAME,
})
logger.info("Upload some OS images if it doesn't exist")
glance = os_utils.get_glance_client()
- for img in IMAGES.keys():
- image_name = IMAGES[img]['image_name']
- image_url = IMAGES[img]['image_url']
+ for img in VIMS_IMAGES.keys():
+ image_name = VIMS_IMAGES[img]['image_name']
+ image_url = VIMS_IMAGES[img]['image_url']
image_id = os_utils.get_image_id(glance, image_name)
@@ -337,7 +321,8 @@ def main():
if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100):
step_failure(
"init",
- "Failed to update security group quota for tenant " + TENANT_NAME)
+ "Failed to update security group quota for tenant " +
+ VIMS_TENANT_NAME)
# ############### CLOUDIFY INITIALISATION ################
public_auth_url = keystone.service_catalog.url_for(
diff --git a/functest/opnfv_tests/vnf/vRNC/parser.py b/functest/opnfv_tests/vnf/vRNC/parser.py
index 0381fd64..33d4d50c 100755
--- a/functest/opnfv_tests/vnf/vRNC/parser.py
+++ b/functest/opnfv_tests/vnf/vRNC/parser.py
@@ -19,7 +19,7 @@ import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
-
+import functest.utils.functest_constants as ft_constants
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--report",
@@ -27,10 +27,8 @@ parser.add_argument("-r", "--report",
action="store_true")
args = parser.parse_args()
-PARSER_REPO = \
- functest_utils.get_functest_config('general.directories.dir_repo_parser')
-RESULTS_DIR = \
- functest_utils.get_functest_config('general.directories.dir_results')
+PARSER_REPO = ft_constants.PARSER_REPO
+RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
logger = ft_logger.Logger("parser").getLogger()
@@ -67,5 +65,6 @@ def main():
details)
exit(ret)
+
if __name__ == '__main__':
main()