aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/openstack')
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py190
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py20
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/tempest_conf.py35
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py6
-rw-r--r--functest/opnfv_tests/openstack/snaps/connection_check.py6
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py6
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py6
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py4
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py20
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_utils.py25
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py1
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py67
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_ssh.py8
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_userdata.py4
14 files changed, 180 insertions, 218 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 103c3a7e..59a67095 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -21,6 +21,7 @@ import time
import uuid
import pkg_resources
+import prettytable
import yaml
from functest.core import testcase
@@ -35,7 +36,6 @@ from snaps.config.network import NetworkConfig, SubnetConfig
from snaps.config.router import RouterConfig
from snaps.openstack.create_flavor import OpenStackFlavor
-from snaps.openstack.tests import openstack_tests
from snaps.openstack.utils import deploy_utils
LOGGER = logging.getLogger(__name__)
@@ -91,20 +91,8 @@ class RallyBase(testcase.TestCase):
def __init__(self, **kwargs):
"""Initialize RallyBase object."""
super(RallyBase, self).__init__(**kwargs)
- if 'os_creds' in kwargs:
- self.os_creds = kwargs['os_creds']
- else:
- creds_override = None
- if hasattr(CONST, 'snaps_os_creds_override'):
- creds_override = CONST.__getattribute__(
- 'snaps_os_creds_override')
-
- self.os_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'),
- overrides=creds_override)
-
+ self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
self.guid = '-' + str(uuid.uuid4())
-
self.creators = []
self.mode = ''
self.summary = []
@@ -354,8 +342,9 @@ class RallyBase(testcase.TestCase):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- output = self._get_output(proc, test_name)
+ output = self.get_cmd_output(proc)
task_id = self.get_task_id(output)
+
LOGGER.debug('task_id : %s', task_id)
if task_id is None:
@@ -375,93 +364,62 @@ class RallyBase(testcase.TestCase):
self.RESULTS_DIR)
os.makedirs(self.RESULTS_DIR)
- # write html report file
- report_html_name = 'opnfv-{}.html'.format(test_name)
- report_html_dir = os.path.join(self.RESULTS_DIR, report_html_name)
- cmd = (["rally", "task", "report", task_id, "--out", report_html_dir])
-
+ # get and save rally operation JSON result
+ cmd = (["rally", "task", "detailed", task_id])
LOGGER.debug('running command: %s', cmd)
- subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ json_detailed = self.get_cmd_output(proc)
+ LOGGER.info('%s', json_detailed)
- # get and save rally operation JSON result
cmd = (["rally", "task", "results", task_id])
LOGGER.debug('running command: %s', cmd)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
json_results = self.get_cmd_output(proc)
+ self._append_summary(json_results, test_name)
report_json_name = 'opnfv-{}.json'.format(test_name)
report_json_dir = os.path.join(self.RESULTS_DIR, report_json_name)
with open(report_json_dir, 'w') as r_file:
LOGGER.debug('saving json file')
r_file.write(json_results)
+ # write html report file
+ report_html_name = 'opnfv-{}.html'.format(test_name)
+ report_html_dir = os.path.join(self.RESULTS_DIR, report_html_name)
+ cmd = (["rally", "task", "report", task_id, "--out", report_html_dir])
+ LOGGER.debug('running command: %s', cmd)
+ subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
# parse JSON operation result
if self.task_succeed(json_results):
LOGGER.info('Test scenario: "{}" OK.'.format(test_name) + "\n")
else:
LOGGER.info('Test scenario: "{}" Failed.'.format(test_name) + "\n")
- def _get_output(self, proc, test_name):
- result = ""
+ def _append_summary(self, json_raw, test_name):
nb_tests = 0
+ nb_success = 0
overall_duration = 0.0
- success = 0.0
- nb_totals = 0
- for line in proc.stdout:
- if ("Load duration" in line or
- "started" in line or
- "finished" in line or
- " Preparing" in line or
- "+-" in line or
- "|" in line):
- result += line
- elif "test scenario" in line:
- result += "\n" + line
- elif "Full duration" in line:
- result += line + "\n\n"
-
- # parse output for summary report
- if ("| " in line and
- "| action" not in line and
- "| Starting" not in line and
- "| Completed" not in line and
- "| ITER" not in line and
- "| " not in line and
- "| total" not in line):
- nb_tests += 1
- elif "| total" in line:
- percentage = ((line.split('|')[8]).strip(' ')).strip('%')
- try:
- success += float(percentage)
- except ValueError:
- LOGGER.info('Percentage error: %s, %s',
- percentage, line)
- nb_totals += 1
- elif "Full duration" in line:
- duration = line.split(': ')[1]
- try:
- overall_duration += float(duration)
- except ValueError:
- LOGGER.info('Duration error: %s, %s', duration, line)
-
- overall_duration = "{:10.2f}".format(overall_duration)
- if nb_totals == 0:
- success_avg = 0
- else:
- success_avg = "{:0.2f}".format(success / nb_totals)
+ rally_report = json.loads(json_raw)
+ for report in rally_report:
+ if report.get('full_duration'):
+ overall_duration += report.get('full_duration')
+
+ if report.get('result'):
+ for result in report.get('result'):
+ nb_tests += 1
+ if not result.get('error'):
+ nb_success += 1
scenario_summary = {'test_name': test_name,
'overall_duration': overall_duration,
'nb_tests': nb_tests,
- 'success': success_avg}
+ 'nb_success': nb_success}
self.summary.append(scenario_summary)
- LOGGER.debug("\n" + result)
-
- return result
-
def _prepare_env(self):
LOGGER.debug('Validating the test name...')
if self.test_name not in self.TESTS:
@@ -559,75 +517,57 @@ class RallyBase(testcase.TestCase):
self._run_task(self.test_name)
def _generate_report(self):
- report = (
- "\n"
- " "
- "\n"
- " Rally Summary Report\n"
- "\n"
- "+===================+============+===============+===========+"
- "\n"
- "| Module | Duration | nb. Test Run | Success |"
- "\n"
- "+===================+============+===============+===========+"
- "\n")
+ total_duration = 0.0
+ total_nb_tests = 0
+ total_nb_success = 0
payload = []
+ res_table = prettytable.PrettyTable(
+ padding_width=2,
+ field_names=['Module', 'Duration', 'nb. Test Run', 'Success'])
+ res_table.align['Module'] = "l"
+ res_table.align['Duration'] = "r"
+ res_table.align['Success'] = "r"
+
# for each scenario we draw a row for the table
- total_duration = 0.0
- total_nb_tests = 0
- total_success = 0.0
for item in self.summary:
- name = "{0:<17}".format(item['test_name'])
- duration = float(item['overall_duration'])
- total_duration += duration
- duration = time.strftime("%M:%S", time.gmtime(duration))
- duration = "{0:<10}".format(duration)
- nb_tests = "{0:<13}".format(item['nb_tests'])
- total_nb_tests += int(item['nb_tests'])
- success = "{0:<10}".format(str(item['success']) + '%')
- total_success += float(item['success'])
- report += ("" +
- "| " + name + " | " + duration + " | " +
- nb_tests + " | " + success + "|\n" +
- "+-------------------+------------"
- "+---------------+-----------+\n")
- payload.append({'module': name,
+ total_duration += item['overall_duration']
+ total_nb_tests += item['nb_tests']
+ total_nb_success += item['nb_success']
+ try:
+ success_avg = 100 * item['nb_success'] / item['nb_tests']
+ except ZeroDivisionError:
+ success_avg = 0
+ success_str = str("{:0.2f}".format(success_avg)) + '%'
+ duration_str = time.strftime("%M:%S",
+ time.gmtime(item['overall_duration']))
+ res_table.add_row([item['test_name'], duration_str,
+ item['nb_tests'], success_str])
+ payload.append({'module': item['test_name'],
'details': {'duration': item['overall_duration'],
'nb tests': item['nb_tests'],
- 'success': item['success']}})
+ 'success': success_str}})
total_duration_str = time.strftime("%H:%M:%S",
time.gmtime(total_duration))
- total_duration_str2 = "{0:<10}".format(total_duration_str)
- total_nb_tests_str = "{0:<13}".format(total_nb_tests)
-
try:
- self.result = total_success / len(self.summary)
+ self.result = 100 * total_nb_success / total_nb_tests
except ZeroDivisionError:
self.result = 100
-
success_rate = "{:0.2f}".format(self.result)
- success_rate_str = "{0:<10}".format(str(success_rate) + '%')
- report += ("+===================+============"
- "+===============+===========+")
- report += "\n"
- report += ("| TOTAL: | " + total_duration_str2 + " | " +
- total_nb_tests_str + " | " + success_rate_str + "|\n")
- report += ("+===================+============"
- "+===============+===========+")
- report += "\n"
-
- LOGGER.info("\n" + report)
+ success_rate_str = str(success_rate) + '%'
+ res_table.add_row(["", "", "", ""])
+ res_table.add_row(["TOTAL:", total_duration_str, total_nb_tests,
+ success_rate_str])
+
+ LOGGER.info("Rally Summary Report:\n\n%s\n", res_table.get_string())
+ LOGGER.info("Rally '%s' success_rate is %s%%",
+ self.case_name, success_rate)
payload.append({'summary': {'duration': total_duration,
'nb tests': total_nb_tests,
'nb success': success_rate}})
-
self.details = payload
- LOGGER.info("Rally '%s' success_rate is %s%%",
- self.case_name, success_rate)
-
def _clean_up(self):
for creator in reversed(self.creators):
try:
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index fe32da66..4e8f58b6 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -38,6 +38,7 @@ LOGGER = logging.getLogger(__name__)
class RefstackClient(testcase.TestCase):
"""RefstackClient testcase implementation class."""
+ # pylint: disable=too-many-instance-attributes
def __init__(self, **kwargs):
"""Initialize RefstackClient testcase object."""
@@ -62,6 +63,7 @@ class RefstackClient(testcase.TestCase):
self.insecure = '-k'
def generate_conf(self):
+ """ Generate tempest.conf file to run tempest"""
if not os.path.exists(conf_utils.REFSTACK_RESULTS_DIR):
os.makedirs(conf_utils.REFSTACK_RESULTS_DIR)
@@ -86,11 +88,11 @@ class RefstackClient(testcase.TestCase):
"environment.log"), 'w+') as f_env:
f_env.write(
("Refstack environment:\n"
- " SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n").format(
- CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('NODE_NAME'),
- time.strftime("%a %b %d %H:%M:%S %Z %Y")))
+ " SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n")
+ .format(CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('NODE_NAME'),
+ time.strftime("%a %b %d %H:%M:%S %Z %Y")))
with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
"refstack.log"), 'w+') as f_stdout:
@@ -147,7 +149,7 @@ class RefstackClient(testcase.TestCase):
"success": success_testcases,
"errors": failed_testcases,
"skipped": skipped_testcases}
- except Exception:
+ except Exception: # pylint: disable=broad-except
self.result = 0
LOGGER.info("Testcase %s success_rate is %s%%",
@@ -170,7 +172,7 @@ class RefstackClient(testcase.TestCase):
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
- except Exception:
+ except Exception: # pylint: disable=broad-except
LOGGER.exception("Error with run")
res = testcase.TestCase.EX_RUN_ERROR
finally:
@@ -207,7 +209,7 @@ class RefstackClient(testcase.TestCase):
self._prep_test()
self.run_defcore(self.confpath, self.testlist)
res = testcase.TestCase.EX_OK
- except Exception as exc:
+ except Exception as exc: # pylint: disable=broad-except
LOGGER.error('Error with run: %s', exc)
res = testcase.TestCase.EX_RUN_ERROR
@@ -257,5 +259,5 @@ def main():
result = refstackclient.main(**args)
if result != testcase.TestCase.EX_OK:
return result
- except Exception:
+ except Exception: # pylint: disable=broad-except
return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index db745227..5764f366 100644
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -5,6 +5,9 @@
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
+
+""" Used to generate tempest.conf """
+
import logging
import pkg_resources
@@ -14,24 +17,23 @@ from functest.utils.constants import CONST
from functest.opnfv_tests.openstack.tempest.tempest \
import TempestResourcesManager
-""" logging configuration """
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
class TempestConf(object):
+ """ TempestConf class"""
def __init__(self, **kwargs):
- self.VERIFIER_ID = conf_utils.get_verifier_id()
- self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
- self.VERIFIER_ID)
- self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
- self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
- self.VERIFIER_ID, self.DEPLOYMENT_ID)
+ self.verifier_id = conf_utils.get_verifier_id()
+ self.deployment_id = conf_utils.get_verifier_deployment_id()
+ self.deployment_dir = conf_utils.get_verifier_deployment_dir(
+ self.verifier_id, self.deployment_id)
self.confpath = pkg_resources.resource_filename(
'functest',
'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
self.resources = TempestResourcesManager(**kwargs)
def generate_tempestconf(self):
+ """ Generate tempest.conf file"""
try:
openstack_utils.source_credentials(
CONST.__getattribute__('openstack_creds'))
@@ -39,29 +41,32 @@ class TempestConf(object):
use_custom_images=True,
use_custom_flavors=True)
conf_utils.configure_tempest_defcore(
- self.DEPLOYMENT_DIR,
+ self.deployment_dir,
image_id=resources.get("image_id"),
flavor_id=resources.get("flavor_id"),
image_id_alt=resources.get("image_id_alt"),
flavor_id_alt=resources.get("flavor_id_alt"),
tenant_id=resources.get("project_id"))
- except Exception as e:
- logger.error("error with generating refstack client "
- "reference tempest conf file: %s", e)
+ except Exception as err: # pylint: disable=broad-except
+ LOGGER.error("error with generating refstack client "
+ "reference tempest conf file: %s", err)
def main(self):
+ """ The main function called by entry point"""
try:
self.generate_tempestconf()
- logger.info("a reference tempest conf file generated "
+ LOGGER.info("a reference tempest conf file generated "
"at %s", self.confpath)
- except Exception as e:
- logger.error('Error with run: %s', e)
+ except Exception as err: # pylint: disable=broad-except
+ LOGGER.error('Error with run: %s', err)
def clean(self):
+ """Clean up the resources"""
self.resources.cleanup()
def main():
+ """Entry point"""
logging.basicConfig()
tempestconf = TempestConf()
tempestconf.main()
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index e708b4de..e8b9c322 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -6,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import unittest
from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
@@ -38,4 +42,4 @@ class ApiCheck(SnapsTestRunner):
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
image_metadata=self.image_metadata)
- return super(self.__class__, self).run()
+ return super(ApiCheck, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py
index 1fc49349..f8bf8852 100644
--- a/functest/opnfv_tests/openstack/snaps/connection_check.py
+++ b/functest/opnfv_tests/openstack/snaps/connection_check.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -6,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import unittest
from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
@@ -37,4 +41,4 @@ class ConnectionCheck(SnapsTestRunner):
os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone)
- return super(self.__class__, self).run()
+ return super(ConnectionCheck, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 837c2eae..db882c38 100644
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ b/functest/opnfv_tests/openstack/snaps/health_check.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -6,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import unittest
from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
@@ -42,4 +46,4 @@ class HealthCheck(SnapsTestRunner):
flavor_metadata=self.flavor_metadata,
image_metadata=self.image_metadata,
netconf_override=self.netconf_override))
- return super(self.__class__, self).run()
+ return super(HealthCheck, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index ded149d0..ef6e5dc9 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -6,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import unittest
from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
@@ -41,4 +45,4 @@ class SnapsSmoke(SnapsTestRunner):
image_metadata=self.image_metadata,
use_floating_ips=self.use_fip,
netconf_override=self.netconf_override)
- return super(self.__class__, self).run()
+ return super(SnapsSmoke, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py b/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
index 3e7c0a39..c3d8c2d8 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
@@ -8,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import logging
from snaps.openstack.tests.create_flavor_tests import (
@@ -119,6 +121,7 @@ def add_openstack_client_tests(suite, os_creds, ext_net_name,
def add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone=True,
image_metadata=None, log_level=logging.INFO):
+ # pylint: disable=too-many-arguments
"""
Adds tests written to exercise all existing OpenStack APIs
:param suite: the unittest.TestSuite object to which to add the tests
@@ -232,6 +235,7 @@ def add_openstack_integration_tests(suite, os_creds, ext_net_name,
image_metadata=None, use_floating_ips=True,
netconf_override=None,
log_level=logging.INFO):
+ # pylint: disable=too-many-arguments
"""
Adds tests written to exercise all long-running OpenStack integration tests
meaning they will be creating VM instances and potentially performing some
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
index 6dc8288b..a2dadb75 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -6,6 +8,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import logging
from functest.core import unit
@@ -13,28 +17,18 @@ from functest.opnfv_tests.openstack.snaps import snaps_utils
from functest.utils.constants import CONST
from snaps.openstack import create_flavor
-from snaps.openstack.tests import openstack_tests
class SnapsTestRunner(unit.Suite):
+ # pylint: disable=too-many-instance-attributes
"""
This test executes the SNAPS Python Tests
"""
+
def __init__(self, **kwargs):
super(SnapsTestRunner, self).__init__(**kwargs)
self.logger = logging.getLogger(__name__)
-
- if 'os_creds' in kwargs:
- self.os_creds = kwargs['os_creds']
- else:
- creds_override = None
- if hasattr(CONST, 'snaps_os_creds_override'):
- creds_override = CONST.__getattribute__(
- 'snaps_os_creds_override')
- self.os_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'),
- proxy_settings_str=None, ssh_proxy_cmd=None,
- overrides=creds_override)
+ self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
if 'ext_net_name' in kwargs:
self.ext_net_name = kwargs['ext_net_name']
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
index 284e88b5..6b0ee497 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2015 All rights reserved
# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -5,8 +7,11 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
from functest.utils.constants import CONST
+from snaps.openstack.tests import openstack_tests
from snaps.openstack.utils import neutron_utils, nova_utils
@@ -19,7 +24,7 @@ def get_ext_net_name(os_creds):
"""
neutron = neutron_utils.neutron_client(os_creds)
ext_nets = neutron_utils.get_external_networks(neutron)
- if (hasattr(CONST, 'EXTERNAL_NETWORK')):
+ if hasattr(CONST, 'EXTERNAL_NETWORK'):
extnet_config = CONST.__getattribute__('EXTERNAL_NETWORK')
for ext_net in ext_nets:
if ext_net.name == extnet_config:
@@ -36,3 +41,21 @@ def get_active_compute_cnt(os_creds):
nova = nova_utils.nova_client(os_creds)
computes = nova_utils.get_availability_zone_hosts(nova, zone_name='nova')
return len(computes)
+
+
+def get_credentials(proxy_settings_str=None, ssh_proxy_cmd=None):
+ """
+ Returns snaps OSCreds object instance
+ :param: proxy_settings_str: proxy settings string <host>:<port>
+ :param: ssh_proxy_cmd: the SSH proxy command for the environment
+ :return: an instance of snaps OSCreds object
+ """
+ creds_override = None
+ if hasattr(CONST, 'snaps_os_creds_override'):
+ creds_override = CONST.__getattribute__(
+ 'snaps_os_creds_override')
+ os_creds = openstack_tests.get_credentials(
+ os_env_file=CONST.__getattribute__('openstack_creds'),
+ proxy_settings_str=proxy_settings_str, ssh_proxy_cmd=ssh_proxy_cmd,
+ overrides=creds_override)
+ return os_creds
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 5481b13b..4361784b 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -389,6 +389,7 @@ class TempestResourcesManager(object):
subnet_settings=[SubnetConfig(
name=CONST.__getattribute__(
'tempest_private_subnet_name') + self.guid,
+ project_name=project_name,
cidr=CONST.__getattribute__('tempest_private_subnet_cidr'))
]))
if network_creator is None or network_creator.get_network() is None:
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index df9774ec..7170101f 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
# This program and the accompanying materials
@@ -37,21 +39,8 @@ class VPingBase(testcase.TestCase):
def __init__(self, **kwargs):
super(VPingBase, self).__init__(**kwargs)
-
self.logger = logging.getLogger(__name__)
-
- if 'os_creds' in kwargs:
- self.os_creds = kwargs['os_creds']
- else:
- creds_override = None
- if hasattr(CONST, 'snaps_os_creds_override'):
- creds_override = CONST.__getattribute__(
- 'snaps_os_creds_override')
-
- self.os_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'),
- overrides=creds_override)
-
+ self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
self.creators = list()
self.image_creator = None
self.network_creator = None
@@ -62,27 +51,24 @@ class VPingBase(testcase.TestCase):
# Shared metadata
self.guid = '-' + str(uuid.uuid4())
- self.router_name = CONST.__getattribute__(
- 'vping_router_name') + self.guid
- self.vm1_name = CONST.__getattribute__('vping_vm_name_1') + self.guid
- self.vm2_name = CONST.__getattribute__('vping_vm_name_2') + self.guid
-
- self.vm_boot_timeout = CONST.__getattribute__('vping_vm_boot_timeout')
- self.vm_delete_timeout = CONST.__getattribute__(
- 'vping_vm_delete_timeout')
- self.vm_ssh_connect_timeout = CONST.__getattribute__(
- 'vping_vm_ssh_connect_timeout')
- self.ping_timeout = CONST.__getattribute__('vping_ping_timeout')
+ self.router_name = getattr(CONST, 'vping_router_name') + self.guid
+ self.vm1_name = getattr(CONST, 'vping_vm_name_1') + self.guid
+ self.vm2_name = getattr(CONST, 'vping_vm_name_2') + self.guid
+
+ self.vm_boot_timeout = getattr(CONST, 'vping_vm_boot_timeout')
+ self.vm_delete_timeout = getattr(CONST, 'vping_vm_delete_timeout')
+ self.vm_ssh_connect_timeout = getattr(
+ CONST, 'vping_vm_ssh_connect_timeout')
+ self.ping_timeout = getattr(CONST, 'vping_ping_timeout')
self.flavor_name = 'vping-flavor' + self.guid
# Move this configuration option up for all tests to leverage
if hasattr(CONST, 'snaps_images_cirros'):
- self.cirros_image_config = CONST.__getattribute__(
- 'snaps_images_cirros')
+ self.cirros_image_config = getattr(CONST, 'snaps_images_cirros')
else:
self.cirros_image_config = None
- def run(self):
+ def run(self, **kwargs): # pylint: disable=too-many-locals
"""
Begins the test execution which should originate from the subclass
"""
@@ -95,7 +81,7 @@ class VPingBase(testcase.TestCase):
'%Y-%m-%d %H:%M:%S'))
image_base_name = '{}-{}'.format(
- CONST.__getattribute__('vping_image_name'),
+ getattr(CONST, 'vping_image_name'),
str(self.guid))
os_image_settings = openstack_tests.cirros_image_settings(
image_base_name, image_metadata=self.cirros_image_config)
@@ -105,26 +91,21 @@ class VPingBase(testcase.TestCase):
self.os_creds, os_image_settings)
self.creators.append(self.image_creator)
- private_net_name = CONST.__getattribute__(
- 'vping_private_net_name') + self.guid
- private_subnet_name = CONST.__getattribute__(
- 'vping_private_subnet_name') + self.guid
- private_subnet_cidr = CONST.__getattribute__(
- 'vping_private_subnet_cidr')
+ private_net_name = getattr(CONST, 'vping_private_net_name') + self.guid
+ private_subnet_name = getattr(
+ CONST, 'vping_private_subnet_name') + self.guid
+ private_subnet_cidr = getattr(CONST, 'vping_private_subnet_cidr')
vping_network_type = None
vping_physical_network = None
vping_segmentation_id = None
if hasattr(CONST, 'vping_network_type'):
- vping_network_type = CONST.__getattribute__(
- 'vping_network_type')
+ vping_network_type = getattr(CONST, 'vping_network_type')
if hasattr(CONST, 'vping_physical_network'):
- vping_physical_network = CONST.__getattribute__(
- 'vping_physical_network')
+ vping_physical_network = getattr(CONST, 'vping_physical_network')
if hasattr(CONST, 'vping_segmentation_id'):
- vping_segmentation_id = CONST.__getattribute__(
- 'vping_segmentation_id')
+ vping_segmentation_id = getattr(CONST, 'vping_segmentation_id')
self.logger.info(
"Creating network with name: '%s'", private_net_name)
@@ -154,7 +135,7 @@ class VPingBase(testcase.TestCase):
self.logger.info(
"Creating flavor with name: '%s'", self.flavor_name)
- scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
+ scenario = getattr(CONST, 'DEPLOY_SCENARIO')
flavor_metadata = None
flavor_ram = 512
if 'ovs' in scenario or 'fdio' in scenario:
@@ -197,7 +178,7 @@ class VPingBase(testcase.TestCase):
Cleanup all OpenStack objects. Should be called on completion
:return:
"""
- if CONST.__getattribute__('vping_cleanup_objects') == 'True':
+ if getattr(CONST, 'vping_cleanup_objects') == 'True':
for creator in reversed(self.creators):
try:
creator.clean()
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index 7df767ed..57e177e5 100644
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-#
+
# Copyright (c) 2015 All rights reserved
# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -7,12 +7,8 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-
"""vPingSSH testcase."""
-# This 1st import is here simply for pep8 as the 'os' package import appears
-# to be required for mock and the unit tests will fail without it
-import os # noqa # pylint: disable=unused-import
import time
from scp import SCPClient
@@ -53,7 +49,7 @@ class VPingSSH(vping_base.VPingBase):
self.sg_desc = CONST.__getattribute__('vping_sg_desc')
@energy.enable_recording
- def run(self):
+ def run(self, **kwargs):
"""
Excecute VPingSSH testcase.
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index ceba0917..76cdcf83 100644
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-#
+
# Copyright (c) 2015 All rights reserved
# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -29,7 +29,7 @@ class VPingUserdata(vping_base.VPingBase):
kwargs["case_name"] = "vping_userdata"
super(VPingUserdata, self).__init__(**kwargs)
- def run(self):
+ def run(self, **kwargs):
"""
Sets up the OpenStack VM instance objects then executes the ping and
validates.