diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-09-05 14:37:54 +0200 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2016-09-05 17:20:14 +0200 |
commit | 861ad3fe18c6ee672c8c82d5d8ad39c6131fdf85 (patch) | |
tree | 3166f4a33ecb369ed7ca16ea5587c75d5a987df6 /testcases/features | |
parent | 17b720a1addfa444a6248baa9706bf20d012051b (diff) |
[Promise test case] Use proper way to get parameters from yaml
Since there is a function in functest_utils to get
a value from the config_functest.yaml directly, there
is no need to load again that file. Better to use common
functions that are designed for that.
Also, Replace location of the results json file to
the results directory. It will be also pushed to artifacts
repository.
Change-Id: Ic6422ed78ccd0f8b40b519342a7dcf38c502924e
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/features')
-rwxr-xr-x | testcases/features/promise.py | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/testcases/features/promise.py b/testcases/features/promise.py index 47e360ca..a7899fec 100755 --- a/testcases/features/promise.py +++ b/testcases/features/promise.py @@ -9,18 +9,19 @@ # # Maintainer : jose.lausuch@ericsson.com # +import argparse import json import os import subprocess import time -import argparse import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as functest_utils +import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as openstack_utils import keystoneclient.v2_0.client as ksclient -import novaclient.client as nvclient from neutronclient.v2_0 import client as ntclient +import novaclient.client as nvclient + parser = argparse.ArgumentParser() @@ -30,35 +31,35 @@ parser.add_argument("-r", "--report", action="store_true") args = parser.parse_args() -functest_yaml = functest_utils.get_functest_yaml() -dirs = functest_yaml.get('general').get('directories') +dirs = ft_utils.get_parameter_from_yaml('general.directories') PROMISE_REPO = dirs.get('dir_repo_promise') -TEST_DB = functest_yaml.get('results').get('test_db_url') - -TENANT_NAME = functest_yaml.get('promise').get('general').get('tenant_name') -TENANT_DESCRIPTION = functest_yaml.get('promise').get( - 'general').get('tenant_description') -USER_NAME = functest_yaml.get('promise').get('general').get('user_name') -USER_PWD = functest_yaml.get('promise').get('general').get('user_pwd') -IMAGE_NAME = functest_yaml.get('promise').get('general').get('image_name') -FLAVOR_NAME = functest_yaml.get('promise').get('general').get('flavor_name') -FLAVOR_VCPUS = functest_yaml.get('promise').get('general').get('flavor_vcpus') -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 - -NET_NAME = functest_yaml.get('promise').get('general').get('network_name') -SUBNET_NAME = functest_yaml.get('promise').get('general').get('subnet_name') -SUBNET_CIDR = functest_yaml.get('promise').get('general').get('subnet_cidr') -ROUTER_NAME = functest_yaml.get('promise').get('general').get('router_name') +RESULTS_DIR = ft_utils.get_parameter_from_yaml( + 'general.directories.dir_results') + +TENANT_NAME = ft_utils.get_parameter_from_yaml('promise.tenant_name') +TENANT_DESCRIPTION = ft_utils.get_parameter_from_yaml( + 'promise.tenant_description') +USER_NAME = ft_utils.get_parameter_from_yaml('promise.user_name') +USER_PWD = ft_utils.get_parameter_from_yaml('promise.user_pwd') +IMAGE_NAME = ft_utils.get_parameter_from_yaml('promise.image_name') +FLAVOR_NAME = ft_utils.get_parameter_from_yaml('promise.flavor_name') +FLAVOR_VCPUS = ft_utils.get_parameter_from_yaml('promise.flavor_vcpus') +FLAVOR_RAM = ft_utils.get_parameter_from_yaml('promise.flavor_ram') +FLAVOR_DISK = ft_utils.get_parameter_from_yaml('promise.flavor_disk') + + +GLANCE_IMAGE_FILENAME = ft_utils.get_parameter_from_yaml( + 'general.openstack.image_file_name') +GLANCE_IMAGE_FORMAT = ft_utils.get_parameter_from_yaml( + 'general.openstack.image_disk_format') +GLANCE_IMAGE_PATH = ft_utils.get_parameter_from_yaml( + 'general.directories.dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME + +NET_NAME = ft_utils.get_parameter_from_yaml('promise.network_name') +SUBNET_NAME = ft_utils.get_parameter_from_yaml('promise.subnet_name') +SUBNET_CIDR = ft_utils.get_parameter_from_yaml('promise.subnet_cidr') +ROUTER_NAME = ft_utils.get_parameter_from_yaml('promise.router_name') """ logging configuration """ @@ -182,7 +183,7 @@ def main(): os.chdir(PROMISE_REPO) results_file_name = 'promise-results.json' - results_file = open(results_file_name, 'w+') + results_file = open(RESULTS_DIR + '/' + results_file_name, 'w+') cmd = 'npm run -s test -- --reporter json' logger.info("Running command: %s" % cmd) @@ -240,12 +241,12 @@ def main(): status = "PASS" exit_code = 0 - functest_utils.push_results_to_db("promise", - "promise", - start_time, - stop_time, - status, - json_results) + ft_utils.push_results_to_db("promise", + "promise", + start_time, + stop_time, + status, + json_results) exit(exit_code) |