aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
Diffstat (limited to 'functest')
-rw-r--r--functest/ci/config_functest.yaml16
-rw-r--r--functest/core/feature.py11
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py18
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py3
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py3
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py15
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py5
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py13
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py18
-rw-r--r--functest/opnfv_tests/vnf/epc/juju_epc.py23
-rw-r--r--functest/tests/unit/core/test_feature.py50
11 files changed, 118 insertions, 57 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index a40d80f2..cf6b1328 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -3,14 +3,9 @@ general:
dir:
home: /home/opnfv
repos: /home/opnfv/repos
- dir_repo_rally: /home/opnfv/repos/rally
repo_tempest: /src/tempest
- dir_repo_releng: /home/opnfv/repos/releng
repo_vims_test: /src/vims-test
- repo_barometer: /home/opnfv/repos/barometer
repo_odl_test: /src/odl_test
- repo_fds: /src/fds
- repo_securityscan: /home/opnfv/repos/securityscanning
functest: /home/opnfv/functest
results: /home/opnfv/functest/results
functest_conf: /home/opnfv/functest/conf
@@ -62,6 +57,11 @@ snaps:
centos:
disk_file:
/home/opnfv/functest/images/CentOS-7-x86_64-GenericCloud.qcow2
+ # netconf_override:
+ # network_type: vlan
+ # physical_network: physnet2
+ # segmentation_id: 2366
+
# All of these values are optional and will override the values retrieved
# by the RC file
# os_creds_override:
@@ -122,6 +122,9 @@ tempest:
ssh_timeout: 130
object_storage:
operator_role: SwiftOperator
+ # network_type: vlan
+ # physical_network: physnet2
+ # segmentation_id: 2366
private_net_name: tempest-net
private_subnet_name: tempest-subnet
private_subnet_cidr: 192.168.150.0/24
@@ -132,6 +135,9 @@ tempest:
rally:
deployment_name: opnfv-rally
network_name: rally-net
+ # network_type: vlan
+ # physical_network: physnet2
+ # segmentation_id: 2366
subnet_name: rally-subnet
subnet_cidr: 192.168.140.0/24
router_name: rally-router
diff --git a/functest/core/feature.py b/functest/core/feature.py
index 2dc3ccbd..3200dad8 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -14,10 +14,10 @@ helpers to run any python method or any bash command.
"""
import logging
+import subprocess
import time
import functest.core.testcase as base
-import functest.utils.functest_utils as ft_utils
from functest.utils.constants import CONST
__author__ = ("Serena Feng <feng.xiaowei@zte.com.cn>, "
@@ -123,9 +123,12 @@ class BashFeature(Feature):
ret = -1
try:
cmd = kwargs["cmd"]
- ret = ft_utils.execute_command(cmd, output_file=self.result_file)
+ with open(self.result_file, 'w+') as f_stdout:
+ proc = subprocess.Popen(cmd.split(), stdout=f_stdout,
+ stderr=subprocess.STDOUT)
+ ret = proc.wait()
+ if ret != 0:
+ self.__logger.error("Execute command: %s failed", cmd)
except KeyError:
self.__logger.error("Please give cmd as arg. kwargs: %s", kwargs)
- except Exception: # pylint: disable=broad-except
- self.__logger.exception("Execute cmd: %s failed", cmd)
return ret
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index c16e6d13..eefd3eb4 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -492,10 +492,28 @@ class RallyBase(testcase.TestCase):
self.creators.append(image_creator)
LOGGER.debug("Creating network '%s'...", network_name)
+
+ rally_network_type = None
+ rally_physical_network = None
+ rally_segmentation_id = None
+
+ if hasattr(CONST, 'rally_network_type'):
+ rally_network_type = CONST.__getattribute__(
+ 'rally_network_type')
+ if hasattr(CONST, 'rally_physical_network'):
+ rally_physical_network = CONST.__getattribute__(
+ 'rally_physical_network')
+ if hasattr(CONST, 'rally_segmentation_id'):
+ rally_segmentation_id = CONST.__getattribute__(
+ 'rally_segmentation_id')
+
network_creator = deploy_utils.create_network(
self.os_creds, NetworkConfig(
name=network_name,
shared=True,
+ network_type=rally_network_type,
+ physical_network=rally_physical_network,
+ segmentation_id=rally_segmentation_id,
subnet_settings=[SubnetConfig(
name=subnet_name,
cidr=self.RALLY_PRIVATE_SUBNET_CIDR)
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 1b8d0537..837c2eae 100644
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ b/functest/opnfv_tests/openstack/snaps/health_check.py
@@ -40,5 +40,6 @@ class HealthCheck(SnapsTestRunner):
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
- image_metadata=self.image_metadata))
+ image_metadata=self.image_metadata,
+ netconf_override=self.netconf_override))
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index 537315e7..ded149d0 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -39,5 +39,6 @@ class SnapsSmoke(SnapsTestRunner):
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
image_metadata=self.image_metadata,
- use_floating_ips=self.use_fip)
+ use_floating_ips=self.use_fip,
+ netconf_override=self.netconf_override)
return super(self.__class__, 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 fb20e4fd..3e7c0a39 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
@@ -230,6 +230,7 @@ def add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone=True,
def add_openstack_integration_tests(suite, os_creds, ext_net_name,
use_keystone=True, flavor_metadata=None,
image_metadata=None, use_floating_ips=True,
+ netconf_override=None,
log_level=logging.INFO):
"""
Adds tests written to exercise all long-running OpenStack integration tests
@@ -251,6 +252,8 @@ def add_openstack_integration_tests(suite, os_creds, ext_net_name,
(i.e. {'hw:mem_page_size': 'large'})
:param use_floating_ips: when true, all tests requiring Floating IPs will
be added to the suite
+ :param netconf_override: dict() containing the reconfigured network_type,
+ physical_network and segmentation_id
:param log_level: the logging level
:return: None as the tests will be adding to the 'suite' parameter object
"""
@@ -355,32 +358,32 @@ def add_openstack_integration_tests(suite, os_creds, ext_net_name,
CreateInstanceSimpleTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstancePortManipulationTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
InstanceSecurityGroupTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceOnComputeHost, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceFromThreePartImage, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateInstanceVolumeTests, os_creds=os_creds,
ext_net_name=ext_net_name, use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
+ netconf_override=netconf_override, log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
CreateStackSuccessTests, os_creds=os_creds, ext_net_name=ext_net_name,
use_keystone=use_keystone,
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
index 023f1bbd..6dc8288b 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
@@ -41,6 +41,11 @@ class SnapsTestRunner(unit.Suite):
else:
self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
+ self.netconf_override = None
+ if hasattr(CONST, 'snaps_network_config'):
+ self.netconf_override = CONST.__getattribute__(
+ 'snaps_network_config')
+
self.use_fip = (
CONST.__getattribute__('snaps_use_floating_ips') == 'True')
self.use_keystone = (
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index fff99a32..8ad005cb 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -286,15 +286,14 @@ def configure_tempest_update_params(tempest_conf_file, image_id=None,
config.set('object-storage', 'operator_role',
CONST.__getattribute__('tempest_object_storage_operator_role'))
+ if (identity_api_version == '3'):
+ config.set('identity', 'v3_endpoint_type',
+ CONST.__getattribute__('OS_ENDPOINT_TYPE'))
+ config.set('identity-feature-enabled', 'api_v2', False)
+ config.set('identity-feature-enabled', 'api_v2_admin', False)
+
if CONST.__getattribute__('OS_ENDPOINT_TYPE') is not None:
sections = config.sections()
- if (identity_api_version == '3'):
- config.set('identity', 'v3_endpoint_type',
- CONST.__getattribute__('OS_ENDPOINT_TYPE'))
- if 'identity-feature-enabled' not in sections:
- config.add_section('identity-feature-enabled')
- config.set('identity-feature-enabled', 'api_v2', False)
- config.set('identity-feature-enabled', 'api_v2_admin', False)
services_list = ['compute',
'volume',
'image',
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 58882b99..5481b13b 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -363,11 +363,29 @@ class TempestResourcesManager(object):
user_id = None
logger.debug("Creating private network for Tempest suite")
+
+ tempest_network_type = None
+ tempest_physical_network = None
+ tempest_segmentation_id = None
+
+ if hasattr(CONST, 'tempest_network_type'):
+ tempest_network_type = CONST.__getattribute__(
+ 'tempest_network_type')
+ if hasattr(CONST, 'tempest_physical_network'):
+ tempest_physical_network = CONST.__getattribute__(
+ 'tempest_physical_network')
+ if hasattr(CONST, 'tempest_segmentation_id'):
+ tempest_segmentation_id = CONST.__getattribute__(
+ 'tempest_segmentation_id')
+
network_creator = deploy_utils.create_network(
self.os_creds, NetworkConfig(
name=CONST.__getattribute__(
'tempest_private_net_name') + self.guid,
project_name=project_name,
+ network_type=tempest_network_type,
+ physical_network=tempest_physical_network,
+ segmentation_id=tempest_segmentation_id,
subnet_settings=[SubnetConfig(
name=CONST.__getattribute__(
'tempest_private_subnet_name') + self.guid,
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py
index be0f3ab2..3146b935 100644
--- a/functest/opnfv_tests/vnf/epc/juju_epc.py
+++ b/functest/opnfv_tests/vnf/epc/juju_epc.py
@@ -43,6 +43,8 @@ class JujuEpc(vnf.VnfOnBoarding):
__logger = logging.getLogger(__name__)
+ default_region_name = "RegionOne"
+
def __init__(self, **kwargs):
if "case_name" not in kwargs:
kwargs["case_name"] = "juju_epc"
@@ -133,7 +135,9 @@ class JujuEpc(vnf.VnfOnBoarding):
'url': self.public_auth_url,
'pass': self.tenant_name,
'tenant_n': self.tenant_name,
- 'user_n': self.tenant_name
+ 'user_n': self.tenant_name,
+ 'region': os.environ.get(
+ "OS_REGION_NAME", self.default_region_name)
}
self.__logger.info("Cloud DATA: %s", cloud_data)
self.filename = os.path.join(self.case_dir, 'abot-epc.yaml')
@@ -143,8 +147,7 @@ class JujuEpc(vnf.VnfOnBoarding):
if self.snaps_creds.identity_api_version == 3:
append_config(self.filename, '{}'.format(
os_utils.get_credentials()['project_domain_name']),
- '{}'.format(os_utils.get_credentials()
- ['user_domain_name']))
+ '{}'.format(os_utils.get_credentials()['user_domain_name']))
self.__logger.info("Upload some OS images if it doesn't exist")
for image_name, image_file in self.images.iteritems():
@@ -231,17 +234,19 @@ class JujuEpc(vnf.VnfOnBoarding):
for image_name in self.images.keys():
self.__logger.info("Generating Metadata for %s", image_name)
image_id = os_utils.get_image_id(self.glance_client, image_name)
- os.system('juju metadata generate-image -d ~ -i {} -s {} -r '
- 'RegionOne -u {}'.format(image_id,
- image_name,
- self.public_auth_url))
+ os.system(
+ 'juju metadata generate-image -d ~ -i {} -s {} -r '
+ '{} -u {}'.format(
+ image_id, image_name,
+ os.environ.get("OS_REGION_NAME", self.default_region_name),
+ self.public_auth_url))
net_id = os_utils.get_network_id(self.neutron_client, private_net_name)
self.__logger.info("Credential information : %s", net_id)
juju_bootstrap_command = ('juju bootstrap abot-epc abot-controller '
'--config network={} --metadata-source ~ '
'--config ssl-hostname-verification=false '
'--constraints mem=2G --bootstrap-series '
- 'trusty '
+ 'xenial '
'--config use-floating-ip=true --debug'.
format(net_id))
os.system(juju_bootstrap_command)
@@ -487,7 +492,7 @@ CLOUD_TEMPLATE = """clouds:
auth-types: [userpass]
endpoint: {url}
regions:
- RegionOne:
+ {region}:
endpoint: {url}
credentials:
abot-epc:
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 553a5dfa..8c73bb5d 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -23,7 +23,7 @@ class FeatureTestingBase(unittest.TestCase):
_case_name = "foo"
_project_name = "bar"
_repo = "dir_repo_bar"
- _cmd = "cd /home/opnfv/repos/bar/tests && bash run.sh && cd -"
+ _cmd = "run_bar_tests.py"
_output_file = '/home/opnfv/functest/results/foo.log'
feature = None
@@ -78,31 +78,33 @@ class BashFeatureTesting(FeatureTestingBase):
self.feature = feature.BashFeature(
project_name=self._project_name, case_name=self._case_name)
- @mock.patch("functest.utils.functest_utils.execute_command")
- def test_run_no_cmd(self, mock_method=None):
- self.assertEqual(self.feature.run(), testcase.TestCase.EX_RUN_ERROR)
- mock_method.assert_not_called()
+ @mock.patch('subprocess.Popen')
+ def test_run_no_cmd(self, mock_subproc):
+ self.assertEqual(
+ self.feature.run(), testcase.TestCase.EX_RUN_ERROR)
+ mock_subproc.assert_not_called()
- @mock.patch("functest.utils.functest_utils.execute_command",
- return_value=1)
- def test_run_ko(self, mock_method=None):
- self._test_run(testcase.TestCase.EX_RUN_ERROR)
- mock_method.assert_called_once_with(
- self._cmd, output_file=self._output_file)
+ @mock.patch('subprocess.Popen')
+ def test_run_ko(self, mock_subproc):
+ with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen:
+ mock_obj = mock.Mock()
+ attrs = {'wait.return_value': 1}
+ mock_obj.configure_mock(**attrs)
- @mock.patch("functest.utils.functest_utils.execute_command",
- side_effect=Exception)
- def test_run_exc(self, mock_method=None):
- self._test_run(testcase.TestCase.EX_RUN_ERROR)
- mock_method.assert_called_once_with(
- self._cmd, output_file=self._output_file)
-
- @mock.patch("functest.utils.functest_utils.execute_command",
- return_value=0)
- def test_run(self, mock_method):
- self._test_run(testcase.TestCase.EX_OK)
- mock_method.assert_called_once_with(
- self._cmd, output_file=self._output_file)
+ mock_subproc.return_value = mock_obj
+ self._test_run(testcase.TestCase.EX_RUN_ERROR)
+ mopen.assert_called_once_with(self._output_file, "w+")
+
+ @mock.patch('subprocess.Popen')
+ def test_run(self, mock_subproc):
+ with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen:
+ mock_obj = mock.Mock()
+ attrs = {'wait.return_value': 0}
+ mock_obj.configure_mock(**attrs)
+
+ mock_subproc.return_value = mock_obj
+ self._test_run(testcase.TestCase.EX_OK)
+ mopen.assert_called_once_with(self._output_file, "w+")
if __name__ == "__main__":