aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.sh10
-rw-r--r--docker/core/Dockerfile2
-rw-r--r--docker/parser/testcases.yaml2
-rw-r--r--docs/release/release-notes/functest-release.rst2
-rw-r--r--functest/ci/config_functest.yaml10
-rw-r--r--functest/core/feature.py11
-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.py6
-rw-r--r--functest/tests/unit/core/test_feature.py50
12 files changed, 66 insertions, 53 deletions
diff --git a/build.sh b/build.sh
index f9a94652e..99a9b466f 100644
--- a/build.sh
+++ b/build.sh
@@ -20,19 +20,19 @@ find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest-
for dir in ${amd64_dirs}; do
(cd "${dir}" && docker build "${build_opts[@]}" -t "${repo}/functest-${dir##**/}:amd64-latest" .)
docker push "${repo}/functest-${dir##**/}:amd64-latest"
- [ "${dir}" != "docker/core" ] && docker rmi "${repo}/functest-${dir##**/}:amd64-latest" || true
+ [ "${dir}" != "docker/core" ] && (docker rmi "${repo}/functest-${dir##**/}:amd64-latest" || true)
done
-docker rmi "${repo}/functest-core:amd64-latest" alpine:3.6 || true
+[ ! -z "${amd64_dirs}" ] && (docker rmi "${repo}/functest-core:amd64-latest" alpine:3.7 || true)
find . -name Dockerfile -exec git checkout {} +
-find . -name Dockerfile -exec sed -i -e "s|alpine:3.6|multiarch/alpine:arm64-v3.6|g" {} +
+find . -name Dockerfile -exec sed -i -e "s|alpine:3.7|multiarch/alpine:arm64-v3.7|g" {} +
find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest-core:arm64-latest|g" {} +
for dir in ${arm64_dirs}; do
(cd "${dir}" && docker build "${build_opts[@]}" -t "${repo}/functest-${dir##**/}:arm64-latest" .)
docker push "${repo}/functest-${dir##**/}:arm64-latest"
- [ "${dir}" != "docker/core" ] && docker rmi "${repo}/functest-${dir##**/}:arm64-latest" || true
+ [ "${dir}" != "docker/core" ] && (docker rmi "${repo}/functest-${dir##**/}:arm64-latest" || true)
done
-docker rmi "${repo}/functest-core:arm64-latest" multiarch/alpine:arm64-v3.6 || true
+[ ! -z "${arm64_dirs}" ] && (docker rmi "${repo}/functest-core:arm64-latest" multiarch/alpine:arm64-v3.6 || true)
find . -name Dockerfile -exec git checkout {} +
exit $?
diff --git a/docker/core/Dockerfile b/docker/core/Dockerfile
index 540746649..bc47e39b0 100644
--- a/docker/core/Dockerfile
+++ b/docker/core/Dockerfile
@@ -1,4 +1,4 @@
-FROM alpine:3.6
+FROM alpine:3.7
ARG BRANCH=master
ARG OPENSTACK_TAG=stable/pike
diff --git a/docker/parser/testcases.yaml b/docker/parser/testcases.yaml
index 556c94540..d069f3417 100644
--- a/docker/parser/testcases.yaml
+++ b/docker/parser/testcases.yaml
@@ -22,4 +22,4 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /src/nfv-parser/tests && ./functest_run.sh'
+ cmd: '/src/nfv-parser/tests/functest_run.sh'
diff --git a/docs/release/release-notes/functest-release.rst b/docs/release/release-notes/functest-release.rst
index bbf3021a2..78ec8f227 100644
--- a/docs/release/release-notes/functest-release.rst
+++ b/docs/release/release-notes/functest-release.rst
@@ -120,7 +120,7 @@ Documents
Version change
==============
-Functest now delivers light-weigth Docker images based on Alpine 3.6. The test cases are grouped into several categories
+Functest now delivers light-weigth Docker images based on Alpine 3.7. The test cases are grouped into several categories
or tiers and must be run from the corresponding container. For example, to run the test case healthcheck, the image
opnfv/functest-healthcheck shall be used. The tiers and the tests within them are explained in detail in the User Guide.
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 608d5470e..cf6b13287 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:
diff --git a/functest/core/feature.py b/functest/core/feature.py
index 2dc3ccbd6..3200dad85 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/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 1b8d05375..837c2eae7 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 537315e74..ded149d0c 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 fb20e4fdd..3e7c0a39f 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 023f1bbd0..6dc8288bf 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 fff99a320..116b1bf0c 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -291,10 +291,8 @@ def configure_tempest_update_params(tempest_conf_file, image_id=None,
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)
+ 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/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 553a5dfa4..8c73bb5d5 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__":