summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/Dockerfile3
-rw-r--r--docker/Dockerfile.aarch642
-rwxr-xr-xfunctest/ci/config_functest.yaml2
-rwxr-xr-xfunctest/ci/testcases.yaml113
-rw-r--r--functest/opnfv_tests/features/barometer.py5
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py24
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py9
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py16
-rw-r--r--functest/tests/unit/odl/test_odl.py26
-rw-r--r--functest/tests/unit/opnfv_tests/openstack/tempest/__init__.py0
-rw-r--r--functest/tests/unit/opnfv_tests/openstack/tempest/test_conf_utils.py92
-rw-r--r--functest/tests/unit/opnfv_tests/openstack/tempest/test_tempest.py279
-rw-r--r--functest/tests/unit/utils/test_openstack_clean.py57
-rwxr-xr-xfunctest/utils/openstack_clean.py7
-rwxr-xr-xrun_unit_tests.sh6
15 files changed, 546 insertions, 95 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 81c3c540b..bb54943df 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,7 +14,7 @@ LABEL version="0.1" description="OPNFV Functest Docker container"
# Environment variables
ARG BRANCH=master
ARG RALLY_TAG=0.8.1
-ARG TEMPEST_TAG=14.0.0
+ARG TEMPEST_TAG=15.0.0
ARG ODL_TAG=release/beryllium-sr4
ARG OPENSTACK_TAG=stable/mitaka
ARG KINGBIRD_TAG=0.2.2
@@ -86,6 +86,7 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPO
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/ovno ${REPOS_DIR}/ovno
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/netready ${REPOS_DIR}/netready
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds ${REPOS_DIR}/fds
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/barometer ${REPOS_DIR}/barometer
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/snaps ${REPOS_DIR}/snaps
diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64
index 82add067b..4281dbdcf 100644
--- a/docker/Dockerfile.aarch64
+++ b/docker/Dockerfile.aarch64
@@ -14,7 +14,7 @@ LABEL version="0.1" description="OPNFV Functest Aarch64 Docker container"
# Environment variables
ARG BRANCH=master
ARG RALLY_TAG=0.8.1
-ARG TEMPEST_TAG=14.0.0
+ARG TEMPEST_TAG=15.0.0
ARG ODL_TAG=release/beryllium-sr4
ARG OPENSTACK_TAG=stable/mitaka
ARG KINGBIRD_TAG=0.2.2
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 3d5763184..b358a3323 100755
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -28,6 +28,7 @@ general:
repo_parser: /home/opnfv/repos/parser
repo_domino: /home/opnfv/repos/domino
repo_snaps: /home/opnfv/repos/snaps
+ repo_fds: /home/opnfv/repos/fds
repo_securityscan: /home/opnfv/repos/securityscanning
repo_vrouter: /home/opnfv/repos/vnfs/vrouter
functest: /home/opnfv/functest
@@ -38,6 +39,7 @@ general:
functest_data: /home/opnfv/functest/data
ims_data: /home/opnfv/functest/data/ims/
rally_inst: /home/opnfv/.rally
+ repo_kingbird: /home/opnfv/repos/kingbird
openstack:
creds: /home/opnfv/functest/conf/openstack.creds
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index 1a1d0f4b9..41541223e 100755
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -8,22 +8,6 @@ tiers:
operations in the VIM.
testcases:
-
- name: snaps_health_check
- criteria: 'status == "PASS"'
- blocking: true
- clean_flag: false
- description: >-
- This test case creates executes the SimpleHealthCheck
- Python test class which creates an, image, flavor, network,
- and Cirros VM instance and observes the console output to
- validate the single port obtains the correct IP address.
- dependencies:
- installer: ''
- scenario: '^((?!lxd).)*$'
- run:
- module: 'functest.opnfv_tests.openstack.snaps.health_check'
- class: 'HealthCheck'
- -
name: connection_check
criteria: 'status == "PASS"'
blocking: true
@@ -60,6 +44,22 @@ tiers:
run:
module: 'functest.opnfv_tests.openstack.snaps.api_check'
class: 'ApiCheck'
+ -
+ name: snaps_health_check
+ criteria: 'status == "PASS"'
+ blocking: true
+ clean_flag: false
+ description: >-
+ This test case creates executes the SimpleHealthCheck
+ Python test class which creates an, image, flavor, network,
+ and Cirros VM instance and observes the console output to
+ validate the single port obtains the correct IP address.
+ dependencies:
+ installer: ''
+ scenario: '^((?!lxd).)*$'
+ run:
+ module: 'functest.opnfv_tests.openstack.snaps.health_check'
+ class: 'HealthCheck'
-
name: smoke
order: 1
@@ -161,8 +161,8 @@ tiers:
some test suites from upstream using Robot as the
test framework.
dependencies:
- installer: ''
- scenario: 'netvirt'
+ installer: 'apex'
+ scenario: 'os-odl_l3-nofeature'
run:
module: 'functest.opnfv_tests.sdn.odl.odl'
class: 'ODLTests'
@@ -173,6 +173,25 @@ tiers:
- /home/opnfv/repos/odl_test/csit/suites/openstack/connectivity
-
+ name: fds
+ criteria: 'success_rate == 100%'
+ blocking: false
+ clean_flag: false
+ description: >-
+ Test Suite for the OpenDaylight SDN Controller when GBP features are
+ installed. It integrates some test suites from upstream using
+ Robot as the test framework.
+ dependencies:
+ installer: 'apex'
+ scenario: 'odl_l2-fdio'
+ run:
+ module: 'functest.opnfv_tests.sdn.odl.odl'
+ class: 'ODLTests'
+ args:
+ suites:
+ - /home/opnfv/repos/fds/testing/robot
+
+ -
name: onos
criteria: 'status == "PASS"'
blocking: true
@@ -204,7 +223,7 @@ tiers:
dependencies:
installer: '^((?!netvirt).)*$'
- scenario: ''
+ scenario: '^((?!lxd).)*$'
run:
module: 'functest.opnfv_tests.openstack.snaps.smoke'
class: 'SnapsSmoke'
@@ -239,7 +258,7 @@ tiers:
description: >-
Test suite from Doctor project.
dependencies:
- installer: '(apex)|(fuel)|(joid)'
+ installer: '(apex)|(fuel)'
scenario: '^((?!fdio).)*$'
run:
module: 'functest.opnfv_tests.features.doctor'
@@ -351,19 +370,6 @@ tiers:
module: 'functest.opnfv_tests.features.domino'
class: 'Domino'
-
- name: orchestra
- criteria: 'ret == 0'
- blocking: false
- clean_flag: true
- description: >-
- Test OpenBaton (Orchestra) stack
- dependencies:
- installer: 'joid'
- scenario: 'unknown'
- run:
- module: 'functest.opnfv_tests.features.orchestrator.orchestra'
- class: 'OpenbatonOrchestrator'
- -
name: netready
criteria: 'status == "PASS"'
blocking: false
@@ -481,34 +487,19 @@ tiers:
run:
module: 'functest.opnfv_tests.vnf.ims.cloudify_ims'
class: 'ImsVnf'
- -
- name: aaa
- criteria: 'ret == 0'
- blocking: false
- clean_flag: true
- description: >-
- Test suite from Parser project.
- dependencies:
- installer: ''
- scenario: ''
- run:
- module: 'functest.opnfv_tests.vnf.aaa.aaa'
- class: 'AaaVnf'
-
- -
- name: juju_epc
- criteria: 'ret == 0'
- blocking: false
- clean_flag: true
- description: >-
- Test suite from OAI project, vEPC deployed with Juju.
- dependencies:
- installer: 'unknown'
- scenario: 'unknown'
- run:
- module: 'functest.opnfv_tests.vnf.epc.epc'
- class: 'EpcVnf'
-
+# -
+# name: aaa
+# criteria: 'ret == 0'
+# blocking: false
+# clean_flag: true
+# description: >-
+# Test suite from Parser project.
+# dependencies:
+# installer: ''
+# scenario: ''
+# run:
+# module: 'functest.opnfv_tests.vnf.aaa.aaa'
+# class: 'AaaVnf'
-
name: orchestra_ims
criteria: 'ret == 0'
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py
index aec2bce5d..32067284b 100644
--- a/functest/opnfv_tests/features/barometer.py
+++ b/functest/opnfv_tests/features/barometer.py
@@ -6,11 +6,9 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
+from baro_tests import collectd
import functest.core.feature_base as base
-import functest.utils.functest_logger as ft_logger
-
-from baro_tests import collectd
class BarometerCollectd(base.FeatureBase):
@@ -22,7 +20,6 @@ class BarometerCollectd(base.FeatureBase):
super(BarometerCollectd, self).__init__(project='barometer',
case='barometercollectd',
repo='dir_repo_barometer')
- self.logger = ft_logger.Logger("BarometerCollectd").getLogger()
def execute(self):
return collectd.main(self.logger)
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 893fff8c2..2c113367b 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -106,6 +106,17 @@ def get_verifier_deployment_dir(verifier_id, deployment_id):
'for-deployment-{}'.format(deployment_id))
+def get_repo_tag(repo):
+ """
+ Returns last tag of current branch
+ """
+ cmd = ("git -C {0} describe --abbrev=0 HEAD".format(repo))
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
+ tag = p.stdout.readline().rstrip()
+
+ return str(tag)
+
+
def backup_tempest_config(conf_file):
"""
Copy config file to tempest results directory
@@ -276,3 +287,16 @@ def configure_tempest_multisite_params(tempest_conf_file):
config.write(config_file)
backup_tempest_config(tempest_conf_file)
+
+
+def install_verifier_ext(path):
+ """
+ Install extension to active verifier
+ """
+ logger.info("Installing verifier from existing repo...")
+ tag = get_repo_tag(path)
+ cmd = ("rally verify add-verifier-ext --source {0} "
+ "--version {1}"
+ .format(path, tag))
+ error_msg = ("Problem while adding verifier extension from %s" % path)
+ ft_utils.execute_command_raise(cmd, error_msg=error_msg)
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 4c96500db..a6ce4ee6c 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -160,13 +160,9 @@ class TempestCommon(testcase_base.TestcaseBase):
result_file.write(str(cases_line) + '\n')
result_file.close()
- def _parse_verification_id(line):
- first_pos = line.index("UUID=") + len("UUID=")
- last_pos = line.index(") for deployment")
- return line[first_pos:last_pos]
-
def run_verifier_tests(self):
- self.OPTION += (" --load-list {}".format(conf_utils.TEMPEST_LIST))
+ self.OPTION += (" --load-list {} --detailed"
+ .format(conf_utils.TEMPEST_LIST))
cmd_line = "rally verify start " + self.OPTION
logger.info("Starting Tempest test suite: '%s'." % cmd_line)
@@ -320,6 +316,7 @@ class TempestMultisite(TempestCommon):
self.case_name = "multisite"
self.MODE = "feature_multisite"
self.OPTION = "--concurrency 1"
+ conf_utils.install_verifier_ext(CONST.dir_repo_kingbird)
class TempestCustom(TempestCommon):
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 69818f5a5..c8e9c4920 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -94,8 +94,11 @@ class ODLTests(testcase_base.TestcaseBase):
try:
odlusername = kwargs['odlusername']
odlpassword = kwargs['odlpassword']
- variables = ['KEYSTONE:' + kwargs['keystoneip'],
+ osauthurl = kwargs['osauthurl']
+ keystoneip = urlparse.urlparse(osauthurl).hostname
+ variables = ['KEYSTONE:' + keystoneip,
'NEUTRON:' + kwargs['neutronip'],
+ 'OS_AUTH_URL:"' + osauthurl + '"',
'OSUSERNAME:"' + kwargs['osusername'] + '"',
'OSTENANTNAME:"' + kwargs['ostenantname'] + '"',
'OSPASSWORD:"' + kwargs['ospassword'] + '"',
@@ -147,10 +150,8 @@ class ODLTests(testcase_base.TestcaseBase):
suites = kwargs["suites"]
except KeyError:
pass
- keystone_url = op_utils.get_endpoint(service_type='identity')
neutron_url = op_utils.get_endpoint(service_type='network')
- kwargs = {'keystoneip': urlparse.urlparse(keystone_url).hostname}
- kwargs['neutronip'] = urlparse.urlparse(neutron_url).hostname
+ kwargs = {'neutronip': urlparse.urlparse(neutron_url).hostname}
kwargs['odlip'] = kwargs['neutronip']
kwargs['odlwebport'] = '8080'
kwargs['odlrestconfport'] = '8181'
@@ -161,6 +162,7 @@ class ODLTests(testcase_base.TestcaseBase):
installer_type = os.environ['INSTALLER_TYPE']
kwargs['osusername'] = os.environ['OS_USERNAME']
kwargs['ostenantname'] = os.environ['OS_TENANT_NAME']
+ kwargs['osauthurl'] = os.environ['OS_AUTH_URL']
kwargs['ospassword'] = os.environ['OS_PASSWORD']
if installer_type == 'fuel':
kwargs['odlwebport'] = '8282'
@@ -191,12 +193,12 @@ class ODLParser(object):
def __init__(self):
self.parser = argparse.ArgumentParser()
self.parser.add_argument(
- '-k', '--keystoneip', help='Keystone IP',
- default='127.0.0.1')
- self.parser.add_argument(
'-n', '--neutronip', help='Neutron IP',
default='127.0.0.1')
self.parser.add_argument(
+ '-k', '--osauthurl', help='OS_AUTH_URL as defined by OpenStack',
+ default='http://127.0.0.1:5000/v2.0')
+ self.parser.add_argument(
'-a', '--osusername', help='Username for OpenStack',
default='admin')
self.parser.add_argument(
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 8f2a5d7e4..5961940f1 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -30,6 +30,7 @@ class ODLTesting(unittest.TestCase):
_keystone_ip = "127.0.0.1"
_neutron_ip = "127.0.0.2"
_sdn_controller_ip = "127.0.0.3"
+ _os_auth_url = "http://{}:5000/v2.0".format(_keystone_ip)
_os_tenantname = "admin"
_os_username = "admin"
_os_password = "admin"
@@ -42,14 +43,15 @@ class ODLTesting(unittest.TestCase):
for var in ("INSTALLER_TYPE", "SDN_CONTROLLER", "SDN_CONTROLLER_IP"):
if var in os.environ:
del os.environ[var]
+ os.environ["OS_AUTH_URL"] = self._os_auth_url
os.environ["OS_USERNAME"] = self._os_username
os.environ["OS_PASSWORD"] = self._os_password
os.environ["OS_TENANT_NAME"] = self._os_tenantname
self.test = odl.ODLTests()
self.defaultargs = {'odlusername': self._odl_username,
'odlpassword': self._odl_password,
- 'keystoneip': self._keystone_ip,
'neutronip': self._keystone_ip,
+ 'osauthurl': self._os_auth_url,
'osusername': self._os_username,
'ostenantname': self._os_tenantname,
'ospassword': self._os_password,
@@ -157,8 +159,8 @@ class ODLTesting(unittest.TestCase):
def _get_main_kwargs(self, key=None):
kwargs = {'odlusername': self._odl_username,
'odlpassword': self._odl_password,
- 'keystoneip': self._keystone_ip,
'neutronip': self._neutron_ip,
+ 'osauthurl': self._os_auth_url,
'osusername': self._os_username,
'ostenantname': self._os_tenantname,
'ospassword': self._os_password,
@@ -178,6 +180,7 @@ class ODLTesting(unittest.TestCase):
if len(args) > 1:
variable = ['KEYSTONE:{}'.format(self._keystone_ip),
'NEUTRON:{}'.format(self._neutron_ip),
+ 'OS_AUTH_URL:"{}"'.format(self._os_auth_url),
'OSUSERNAME:"{}"'.format(self._os_username),
'OSTENANTNAME:"{}"'.format(self._os_tenantname),
'OSPASSWORD:"{}"'.format(self._os_password),
@@ -207,12 +210,12 @@ class ODLTesting(unittest.TestCase):
def test_main_missing_odlpassword(self):
self._test_main_missing_keyword('odlpassword')
- def test_main_missing_keystoneip(self):
- self._test_main_missing_keyword('keystoneip')
-
def test_main_missing_neutronip(self):
self._test_main_missing_keyword('neutronip')
+ def test_main_missing_osauthurl(self):
+ self._test_main_missing_keyword('osauthurl')
+
def test_main_missing_osusername(self):
self._test_main_missing_keyword('osusername')
@@ -347,10 +350,11 @@ class ODLTesting(unittest.TestCase):
self.assertEqual(self.test.run(), status)
self.test.main.assert_called_once_with(
odl.ODLTests.default_suites,
- keystoneip=self._keystone_ip, neutronip=self._neutron_ip,
+ neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
odlrestconfport=odlrestconfport,
odlusername=self._odl_username, odlwebport=odlwebport,
+ osauthurl=self._os_auth_url,
ospassword=self._os_password, ostenantname=self._os_tenantname,
osusername=self._os_username)
@@ -368,10 +372,11 @@ class ODLTesting(unittest.TestCase):
self.assertEqual(self.test.run(suites=suites), status)
self.test.main.assert_called_once_with(
suites,
- keystoneip=self._keystone_ip, neutronip=self._neutron_ip,
+ neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
odlrestconfport=odlrestconfport,
odlusername=self._odl_username, odlwebport=odlwebport,
+ osauthurl=self._os_auth_url,
ospassword=self._os_password, ostenantname=self._os_tenantname,
osusername=self._os_username)
@@ -381,6 +386,9 @@ class ODLTesting(unittest.TestCase):
self.assertEqual(self.test.run(),
testcase_base.TestcaseBase.EX_RUN_ERROR)
+ def test_run_missing_os_auth_url(self):
+ self._test_run_missing_env_var("OS_AUTH_URL")
+
def test_run_missing_os_username(self):
self._test_run_missing_env_var("OS_USERNAME")
@@ -507,8 +515,8 @@ class ODLTesting(unittest.TestCase):
def test_argparser_odlpassword(self):
self._test_argparser('odlpassword', 'foo')
- def test_argparser_keystoneip(self):
- self._test_argparser('keystoneip', '127.0.0.4')
+ def test_argparser_osauthurl(self):
+ self._test_argparser('osauthurl', 'http://127.0.0.4:5000/v2')
def test_argparser_neutronip(self):
self._test_argparser('neutronip', '127.0.0.4')
diff --git a/functest/tests/unit/opnfv_tests/openstack/tempest/__init__.py b/functest/tests/unit/opnfv_tests/openstack/tempest/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/tests/unit/opnfv_tests/openstack/tempest/__init__.py
diff --git a/functest/tests/unit/opnfv_tests/openstack/tempest/test_conf_utils.py b/functest/tests/unit/opnfv_tests/openstack/tempest/test_conf_utils.py
new file mode 100644
index 000000000..6121f4ebb
--- /dev/null
+++ b/functest/tests/unit/opnfv_tests/openstack/tempest/test_conf_utils.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+
+# All rights reserved. This program and the accompanying materials
+# 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
+
+import logging
+import unittest
+
+import mock
+
+from functest.opnfv_tests.openstack.tempest import conf_utils
+from functest.utils.constants import CONST
+
+
+class OSTempestConfUtilsTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def test_get_verifier_id_missing_verifier(self):
+ CONST.tempest_deployment_name = 'test_deploy_name'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.subprocess.Popen') as mock_popen, \
+ self.assertRaises(Exception):
+ mock_stdout = mock.Mock()
+ attrs = {'stdout.readline.return_value': ''}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+ conf_utils.get_verifier_id(),
+
+ def test_get_verifier_id_default(self):
+ CONST.tempest_deployment_name = 'test_deploy_name'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.subprocess.Popen') as mock_popen:
+ mock_stdout = mock.Mock()
+ attrs = {'stdout.readline.return_value': 'test_deploy_id'}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+
+ self.assertEqual(conf_utils.get_verifier_id(),
+ 'test_deploy_id')
+
+ def test_get_verifier_deployment_id_missing_rally(self):
+ CONST.rally_deployment_name = 'test_rally_deploy_name'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.subprocess.Popen') as mock_popen, \
+ self.assertRaises(Exception):
+ mock_stdout = mock.Mock()
+ attrs = {'stdout.readline.return_value': ''}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+ conf_utils.get_verifier_deployment_id(),
+
+ def test_get_verifier_deployment_id_default(self):
+ CONST.rally_deployment_name = 'test_rally_deploy_name'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.subprocess.Popen') as mock_popen:
+ mock_stdout = mock.Mock()
+ attrs = {'stdout.readline.return_value': 'test_deploy_id'}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+
+ self.assertEqual(conf_utils.get_verifier_deployment_id(),
+ 'test_deploy_id')
+
+ def test_get_verifier_repo_dir_default(self):
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.os.path.join',
+ return_value='test_verifier_repo_dir'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.get_verifier_id') as m:
+ self.assertEqual(conf_utils.get_verifier_repo_dir(''),
+ 'test_verifier_repo_dir')
+ self.assertTrue(m.called)
+
+ def test_get_verifier_deployment_dir_default(self):
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.os.path.join',
+ return_value='test_verifier_repo_dir'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.get_verifier_id') as m1, \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.get_verifier_deployment_id') as m2:
+ self.assertEqual(conf_utils.get_verifier_deployment_dir('', ''),
+ 'test_verifier_repo_dir')
+ self.assertTrue(m1.called)
+ self.assertTrue(m2.called)
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/opnfv_tests/openstack/tempest/test_tempest.py b/functest/tests/unit/opnfv_tests/openstack/tempest/test_tempest.py
new file mode 100644
index 000000000..8ae7b4db3
--- /dev/null
+++ b/functest/tests/unit/opnfv_tests/openstack/tempest/test_tempest.py
@@ -0,0 +1,279 @@
+#!/usr/bin/env python
+
+# All rights reserved. This program and the accompanying materials
+# 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
+
+import logging
+import unittest
+
+import mock
+
+from functest.core import testcase_base
+from functest.opnfv_tests.openstack.tempest import tempest
+from functest.opnfv_tests.openstack.tempest import conf_utils
+from functest.utils.constants import CONST
+
+
+class OSTempestTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_id',
+ return_value='test_deploy_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_deployment_id',
+ return_value='test_deploy_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_repo_dir',
+ return_value='test_verifier_repo_dir'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_deployment_dir',
+ return_value='test_verifier_deploy_dir'):
+ self.tempestcommon = tempest.TempestCommon()
+
+ def test_create_tempest_resources_missing_network_dic(self):
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_keystone_client',
+ return_value=mock.Mock()), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_tenant',
+ return_value='test_tenant_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_user',
+ return_value='test_user_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_shared_network_full',
+ return_value=None), \
+ self.assertRaises(Exception) as context:
+ self.tempestcommon.create_tempest_resources()
+ msg = 'Failed to create private network'
+ self.assertTrue(msg in context)
+
+ def test_create_tempest_resources_missing_image(self):
+ CONST.tempest_use_custom_images = 'test_image'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_keystone_client',
+ return_value=mock.Mock()), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_tenant',
+ return_value='test_tenant_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_user',
+ return_value='test_user_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_shared_network_full',
+ return_value=mock.Mock()), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_or_create_image',
+ return_value=(mock.Mock(), None)), \
+ self.assertRaises(Exception) as context:
+ self.tempestcommon.create_tempest_resources()
+ msg = 'Failed to create image'
+ self.assertTrue(msg in context)
+
+ def test_create_tempest_resources_missing_flavor(self):
+ CONST.tempest_use_custom_images = 'test_image'
+ CONST.tempest_use_custom_flavors = 'test_flavour'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_keystone_client',
+ return_value=mock.Mock()), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_tenant',
+ return_value='test_tenant_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_user',
+ return_value='test_user_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.create_shared_network_full',
+ return_value=mock.Mock()), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_or_create_image',
+ return_value=(mock.Mock(), 'image_id')), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os_utils.get_or_create_flavor',
+ return_value=(mock.Mock(), None)), \
+ self.assertRaises(Exception) as context:
+ self.tempestcommon.create_tempest_resources()
+ msg = 'Failed to create flavor'
+ self.assertTrue(msg in context)
+
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.logger.debug')
+ def test_generate_test_list_defcore_mode(self, mock_logger_debug):
+ self.tempestcommon.MODE = 'defcore'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'shutil.copyfile') as m:
+ self.tempestcommon.generate_test_list('test_verifier_repo_dir')
+ self.assertTrue(m.called)
+
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.logger.error')
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.logger.debug')
+ def test_generate_test_list_custom_mode_missing_file(self,
+ mock_logger_debug,
+ mock_logger_error):
+ self.tempestcommon.MODE = 'custom'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.isfile', return_value=False), \
+ self.assertRaises(Exception) as context:
+ msg = "Tempest test list file %s NOT found."
+ self.tempestcommon.generate_test_list('test_verifier_repo_dir')
+ self.assertTrue((msg % conf_utils.TEMPEST_CUSTOM) in context)
+
+ def test_generate_test_list_custom_mode_default(self):
+ self.tempestcommon.MODE = 'custom'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'shutil.copyfile') as m, \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.isfile', return_value=True):
+ self.tempestcommon.generate_test_list('test_verifier_repo_dir')
+ self.assertTrue(m.called)
+
+ def _test_generate_test_list_mode_default(self, mode):
+ self.tempestcommon.MODE = mode
+ if self.tempestcommon.MODE == 'smoke':
+ testr_mode = "smoke"
+ elif self.tempestcommon.MODE == 'feature_multisite':
+ testr_mode = "'[Kk]ingbird'"
+ elif self.tempestcommon.MODE == 'full':
+ testr_mode = ""
+ else:
+ testr_mode = 'tempest.api.' + self.tempestcommon.MODE
+ conf_utils.TEMPEST_RAW_LIST = 'raw_list'
+ verifier_repo_dir = 'test_verifier_repo_dir'
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'ft_utils.execute_command') as m:
+ cmd = ("cd {0};"
+ "testr list-tests {1} > {2};"
+ "cd -;".format(verifier_repo_dir,
+ testr_mode,
+ conf_utils.TEMPEST_RAW_LIST))
+ self.tempestcommon.generate_test_list('test_verifier_repo_dir')
+ m.assert_any_call(cmd)
+
+ def test_generate_test_list_smoke_mode(self):
+ self._test_generate_test_list_mode_default('smoke')
+
+ def test_generate_test_list_feature_multisite_mode(self):
+ self._test_generate_test_list_mode_default('feature_multisite')
+
+ def test_generate_test_list_full_mode(self):
+ self._test_generate_test_list_mode_default('full')
+
+ def test_parse_verifier_result_missing_verification_uuid(self):
+ self.tempestcommon.VERIFICATION_ID = ''
+ with self.assertRaises(Exception):
+ self.tempestcommon.parse_verifier_result()
+
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.logger.info')
+ def test_parse_verifier_result_default(self, mock_logger_info):
+ self.tempestcommon.VERIFICATION_ID = 'test_uuid'
+ self.tempestcommon.case_name = 'test_case_name'
+ stdout = ['Testscount||2', 'Success||2', 'Skipped||0', 'Failures||0']
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'subprocess.Popen') as mock_popen, \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'ft_utils.check_success_rate') as mock_method, \
+ mock.patch('__builtin__.open', mock.mock_open()):
+ mock_stdout = mock.Mock()
+ attrs = {'stdout': stdout}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+
+ self.tempestcommon.parse_verifier_result()
+ mock_method.assert_any_call('test_case_name', 100)
+
+ def test_run_missing_create_tempest_dir(self):
+ ret = testcase_base.TestcaseBase.EX_RUN_ERROR
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.exists', return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.makedirs') as mock_os_makedirs, \
+ mock.patch.object(self.tempestcommon, 'create_tempest_resources',
+ return_value=ret):
+ self.assertEqual(self.tempestcommon.run(),
+ ret)
+ self.assertTrue(mock_os_makedirs.called)
+
+ def test_run_missing_configure_tempest(self):
+ ret = testcase_base.TestcaseBase.EX_RUN_ERROR
+ ret_ok = testcase_base.TestcaseBase.EX_OK
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.exists', return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.makedirs') as mock_os_makedirs, \
+ mock.patch.object(self.tempestcommon,
+ 'create_tempest_resources',
+ return_value=ret_ok), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.configure_tempest',
+ return_value=ret):
+ self.assertEqual(self.tempestcommon.run(),
+ ret)
+ self.assertTrue(mock_os_makedirs.called)
+
+ def test_run_missing_generate_test_list(self):
+ ret = testcase_base.TestcaseBase.EX_RUN_ERROR
+ ret_ok = testcase_base.TestcaseBase.EX_OK
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.exists', return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.makedirs') as mock_os_makedirs, \
+ mock.patch.object(self.tempestcommon, 'create_tempest_resources',
+ return_value=ret_ok), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.configure_tempest',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'generate_test_list',
+ return_value=ret):
+ self.assertEqual(self.tempestcommon.run(),
+ ret)
+ self.assertTrue(mock_os_makedirs.called)
+
+ def test_run_missing_apply_tempest_blacklist(self):
+ ret = testcase_base.TestcaseBase.EX_RUN_ERROR
+ ret_ok = testcase_base.TestcaseBase.EX_OK
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.exists', return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.makedirs') as mock_os_makedirs, \
+ mock.patch.object(self.tempestcommon, 'create_tempest_resources',
+ return_value=ret_ok), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.configure_tempest',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'generate_test_list',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'apply_tempest_blacklist',
+ return_value=ret):
+ self.assertEqual(self.tempestcommon.run(),
+ ret)
+ self.assertTrue(mock_os_makedirs.called)
+
+ def test_run_missing_default_criteria_pass(self):
+ ret_ok = testcase_base.TestcaseBase.EX_OK
+ self.tempestcommon.criteria = "PASS"
+ with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.path.exists', return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'os.makedirs') as mock_os_makedirs, \
+ mock.patch.object(self.tempestcommon, 'create_tempest_resources',
+ return_value=ret_ok), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.configure_tempest',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'generate_test_list',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'apply_tempest_blacklist',
+ return_value=ret_ok), \
+ mock.patch.object(self.tempestcommon, 'run_verifier_tests'), \
+ mock.patch.object(self.tempestcommon, 'parse_verifier_result'):
+ self.assertEqual(self.tempestcommon.run(),
+ ret_ok)
+ self.assertTrue(mock_os_makedirs.called)
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/utils/test_openstack_clean.py b/functest/tests/unit/utils/test_openstack_clean.py
index 28eab4f8a..156695380 100644
--- a/functest/tests/unit/utils/test_openstack_clean.py
+++ b/functest/tests/unit/utils/test_openstack_clean.py
@@ -20,13 +20,41 @@ class OSCleanTesting(unittest.TestCase):
def _get_instance(self, key):
mock_obj = mock.Mock()
attrs = {'id': 'id' + str(key), 'name': 'name' + str(key),
- 'ip': 'ip' + str(key)}
+ 'ip': 'ip' + str(key), 'status': 'ACTIVE',
+ 'OS-EXT-STS:task_state': '-'}
+ mock_obj.configure_mock(**attrs)
+ return mock_obj
+
+ def _get_instance_deleted(self, key):
+ mock_obj = mock.Mock()
+ attrs = {'id': 'id' + str(key), 'name': 'name' + str(key),
+ 'ip': 'ip' + str(key), 'status': 'DELETED',
+ 'OS-EXT-STS:task_state': '-'}
+ mock_obj.configure_mock(**attrs)
+ return mock_obj
+
+ def _get_instance_deleting(self, key):
+ mock_obj = mock.Mock()
+ attrs = {'id': 'id' + str(key), 'name': 'name' + str(key),
+ 'ip': 'ip' + str(key), 'status': 'BUILD',
+ 'OS-EXT-STS:task_state': 'deleting'}
+ mock_obj.configure_mock(**attrs)
+ return mock_obj
+
+ def _get_instance_other(self, key):
+ mock_obj = mock.Mock()
+ attrs = {'id': 'id' + str(key), 'name': 'name' + str(key),
+ 'ip': 'ip' + str(key), 'status': 'BUILD',
+ 'OS-EXT-STS:task_state': 'networking'}
mock_obj.configure_mock(**attrs)
return mock_obj
def setUp(self):
self.client = mock.Mock()
self.test_list = [self._get_instance(1), self._get_instance(2)]
+ self.deleted_list = [self._get_instance_deleted(5),
+ self._get_instance_deleting(6)]
+ self.other_list = [self._get_instance_other(7)]
self.update_list = {'id1': 'name1', 'id2': 'name2'}
self.remove_list = {'id3': 'name3', 'id4': 'name4'}
self.test_dict_list = [{'id': 'id1', 'name': 'name1', 'ip': 'ip1',
@@ -77,6 +105,33 @@ class OSCleanTesting(unittest.TestCase):
" '\s*\S+'"
" ..."))
+ @mock.patch('functest.utils.openstack_clean.logger.debug')
+ def test_remove_instances_pending_delete_success(self, mock_logger_debug):
+ with mock.patch('functest.utils.openstack_clean.os_utils'
+ '.get_instances', return_value=self.deleted_list), \
+ mock.patch('functest.utils.openstack_clean.os_utils'
+ '.delete_instance', return_value=True):
+ openstack_clean.remove_instances(self.client, self.remove_list)
+ mock_logger_debug.assert_any_call("Removing Nova instances...")
+ mock_logger_debug.test_utils.RegexMatch("Removing"
+ " instance"
+ " '\s*\S+'"
+ " ...").assert_not_called()
+
+ @mock.patch('functest.utils.openstack_clean.logger.debug')
+ def test_remove_instances_other_delete_success(self, mock_logger_debug):
+ with mock.patch('functest.utils.openstack_clean.os_utils'
+ '.get_instances', return_value=self.other_list), \
+ mock.patch('functest.utils.openstack_clean.os_utils'
+ '.delete_instance', return_value=True):
+ openstack_clean.remove_instances(self.client, self.remove_list)
+ mock_logger_debug.assert_any_call("Removing Nova instances...")
+ mock_logger_debug.assert_any_call(" > Request sent.")
+ mock_logger_debug.assert_any_call(test_utils.RegexMatch("Removing"
+ " instance"
+ " '\s*\S+'"
+ " ..."))
+
@mock.patch('functest.utils.openstack_clean.logger.error')
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_instances_delete_failed(self, mock_logger_debug,
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index 15a8f33d5..ce61fcacf 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -49,9 +49,14 @@ def remove_instances(nova_client, default_instances):
for instance in instances:
instance_name = getattr(instance, 'name')
instance_id = getattr(instance, 'id')
+ instance_status = getattr(instance, 'status')
+ instance_state = getattr(instance, 'OS-EXT-STS:task_state')
+
logger.debug("'%s', ID=%s " % (instance_name, instance_id))
if (instance_id not in default_instances and
- instance_name not in default_instances.values()):
+ instance_name not in default_instances.values() and
+ instance_status != 'DELETED' and
+ (instance_status != 'BUILD' or instance_state != 'deleting')):
logger.debug("Removing instance '%s' ..." % instance_id)
if os_utils.delete_instance(nova_client, instance_id):
logger.debug(" > Request sent.")
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
index e0660910a..32076dabe 100755
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -25,12 +25,10 @@ pip install -r $WORKSPACE/test-requirements.txt
pip install $WORKSPACE
#install releng
-cd $WORKSPACE/../
rm -rf releng-unittests
-git clone https://gerrit.opnfv.org/gerrit/releng releng-unittests
+git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng releng-unittests
pip install releng-unittests/modules/
rm -fr releng-unittests
-cd $WORKSPACE
export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml
# unit tests
@@ -46,7 +44,7 @@ nosetests --with-xunit \
--cover-package=functest.opnfv_tests.sdn.odl.odl \
--cover-package=functest.opnfv_tests.vnf.ims \
--cover-package=functest.utils \
- --cover-package=functest.opnfv_tests.openstack.rally \
+ --cover-package=functest.opnfv_tests.openstack \
--cover-xml \
--cover-html \
--log-config=$(pwd)/functest/tests/unit/test_logging.ini \