aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/OpenStack
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/OpenStack')
-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
4 files changed, 198 insertions, 225 deletions
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)