aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf
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/vnf
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/vnf')
-rwxr-xr-xfunctest/opnfv_tests/vnf/vIMS/vIMS.py83
-rwxr-xr-xfunctest/opnfv_tests/vnf/vRNC/parser.py9
2 files changed, 38 insertions, 54 deletions
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()