summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc1
-rw-r--r--docker/Dockerfile5
-rw-r--r--docker/Dockerfile.aarch645
-rw-r--r--docker/thirdparty-requirements.txt5
-rw-r--r--functest/ci/config_aarch64_patch.yaml8
-rw-r--r--functest/ci/config_functest.yaml20
-rwxr-xr-xfunctest/ci/download_images.sh7
-rw-r--r--functest/ci/testcases.yaml8
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py5
-rw-r--r--functest/opnfv_tests/openstack/rally/scenario/opnfv-requests.yaml11
-rw-r--r--functest/opnfv_tests/openstack/rally/task.yaml4
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py25
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py3
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py11
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py19
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py4
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/sdn/odl/odl.py27
-rw-r--r--functest/tests/unit/odl/test_odl.py48
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py8
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py22
-rw-r--r--functest/tests/unit/utils/test_openstack_utils.py53
-rw-r--r--functest/utils/openstack_utils.py37
-rw-r--r--setup.cfg1
23 files changed, 87 insertions, 250 deletions
diff --git a/.coveragerc b/.coveragerc
index fe258c6c6..613ea33df 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,3 +1,4 @@
[report]
exclude_lines =
if __name__ == .__main__.:
+ def main
diff --git a/docker/Dockerfile b/docker/Dockerfile
index a3ebc1a1c..d38713e06 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -90,7 +90,6 @@ RUN ln -s /usr/local/lib/python2.7/dist-packages/functest ${FUNCTEST_REPO_DIR}/f
# OPNFV repositories
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor
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
@@ -118,8 +117,7 @@ RUN find -L ${FUNCTEST_REPO_DIR} -name "*.py" \
-not -path "*functest_venv*" \
|xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
-RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR}
-RUN wget -q https://raw.githubusercontent.com/openstack/rally/${RALLY_TAG}/install_rally.sh \
+RUN wget -q https://git.openstack.org/cgit/openstack/rally/plain/install_rally.sh?h=${RALLY_TAG} -O install_rally.sh \
&& bash install_rally.sh --branch ${RALLY_TAG} --yes && rm install_rally.sh
RUN add_images.sh
@@ -133,6 +131,7 @@ RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/se
# refstack-client integration
RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \
&& bash setup_env -t ${REFSTACK_TAG} && rm setup_env
+RUN ln -s ${HOME}/.tempest /usr/local/lib/python2.7/dist-packages/.tempest
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
&& cd ${REPOS_VNFS_DIR}/vims-test \
diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64
index 1a7dc0279..77c94b02f 100644
--- a/docker/Dockerfile.aarch64
+++ b/docker/Dockerfile.aarch64
@@ -85,7 +85,6 @@ RUN pip install ${PIP_OPTS} \
# OPNFV repositories
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
@@ -110,8 +109,7 @@ RUN find -L ${FUNCTEST_REPO_DIR} -name "*.py" \
-not -path "*functest_venv*" \
|xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
-RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR}
-RUN wget -q https://raw.githubusercontent.com/openstack/rally/${RALLY_TAG}/install_rally.sh \
+RUN wget -q https://git.openstack.org/cgit/openstack/rally/plain/install_rally.sh?h=${RALLY_TAG} -O install_rally.sh \
&& bash install_rally.sh --branch ${RALLY_TAG} --yes && rm install_rally.sh
RUN add_images.sh
@@ -125,6 +123,7 @@ RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/se
# refstack-client integration
RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \
&& bash setup_env -t ${REFSTACK_TAG} && rm setup_env
+RUN ln -s ${HOME}/.tempest /usr/local/lib/python2.7/dist-packages/.tempest
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
&& cd ${REPOS_VNFS_DIR}/vims-test \
diff --git a/docker/thirdparty-requirements.txt b/docker/thirdparty-requirements.txt
index f51a5e29d..d1c3a917f 100644
--- a/docker/thirdparty-requirements.txt
+++ b/docker/thirdparty-requirements.txt
@@ -3,7 +3,8 @@ git+https://gerrit.opnfv.org/gerrit/sdnvpn#egg=sdnvpn
git+https://gerrit.opnfv.org/gerrit/opera#egg=opera
git+https://gerrit.opnfv.org/gerrit/securityscanning#egg=securityscanning
git+https://gerrit.opnfv.org/gerrit/sfc#egg=sfc
-networking-bgpvpn
+tosca-parser>=0.7.0 # Apache-2.0
+heat-translator>=0.4.0 # Apache-2.0
rally
tempest>=15.0.0 # Apache-2.0
-git+https://github.com/openstack/refstack-client#egg=refstack-client
+git+https://github.com/openstack/refstack-client#egg=refstack-client \ No newline at end of file
diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml
index 80cf4ccc2..45af8d743 100644
--- a/functest/ci/config_aarch64_patch.yaml
+++ b/functest/ci/config_aarch64_patch.yaml
@@ -5,14 +5,6 @@ os:
image_file_name: cirros-d161201-aarch64-disk.img
image_password: gocubsgo
- snaps_health_check:
- disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
- kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
- ramdisk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-initramfs
- extra_properties:
- os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
- hw_video_model: vga
-
vping:
image_name: TestVM
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 1199be5ad..b93730cdf 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -11,9 +11,7 @@ general:
repo_barometer: /home/opnfv/repos/barometer
repo_doctor: /home/opnfv/repos/doctor
repo_copper: /home/opnfv/repos/copper
- 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
@@ -24,7 +22,6 @@ general:
ims_data: /home/opnfv/functest/data/ims/
functest_images: /home/opnfv/functest/images
rally_inst: /home/opnfv/.rally
- refstack_client: /home/opnfv/repos/refstack-client
openstack:
creds: /home/opnfv/functest/conf/openstack.creds
@@ -58,19 +55,14 @@ snaps:
use_keystone: True
use_floating_ips: True
images:
+ glance_tests:
+ disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
cirros:
disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
- # ARM
-# disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
-# kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
-# ramdisk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-initramfs
-# extra_properties:
-# os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
-# hw_video_model: vga
-# ubuntu:
-# disk_url: http://uec-images.ubuntu.com/releases/trusty/14.04/ubuntu-14.04-server-cloudimg-amd64-disk1.img
-# centos:
-# disk_url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
+ ubuntu:
+ disk_file: /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img
+ centos:
+ disk_file: /home/opnfv/functest/images/CentOS-7-x86_64-GenericCloud.qcow2
vping:
ping_timeout: 200
diff --git a/functest/ci/download_images.sh b/functest/ci/download_images.sh
index f3fdef2e3..23e09c10b 100755
--- a/functest/ci/download_images.sh
+++ b/functest/ci/download_images.sh
@@ -28,4 +28,11 @@ wget -nc http://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-di
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-disk.img -P ${IMAGES_FOLDER_DIR}
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-initramfs -P ${IMAGES_FOLDER_DIR}
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-kernel -P ${IMAGES_FOLDER_DIR}
+
+# Add Ubuntu 14 qcow2 image
+wget -nc http://uec-images.ubuntu.com/releases/trusty/14.04/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P ${IMAGES_FOLDER_DIR}
+
+# Add Centos 7 qcow2 image
+wget -nc http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 -P ${IMAGES_FOLDER_DIR}
+
set +ex \ No newline at end of file
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index 2763d0c23..11af98231 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -198,7 +198,7 @@ tiers:
Robot as the test framework.
dependencies:
installer: 'apex'
- scenario: 'odl_l2-fdio'
+ scenario: 'odl.*-fdio'
run:
module: 'functest.opnfv_tests.sdn.odl.odl'
class: 'ODLTests'
@@ -297,7 +297,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /home/opnfv/repos/sdnvpn/sdnvpn/test/functest && python ./run_tests.py'
+ cmd: 'cd /usr/local/lib/python2.7/dist-packages/sdnvpn/test/functest && python ./run_tests.py'
-
case_name: security_scan
@@ -314,7 +314,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: '. /home/opnfv/functest/conf/stackrc && cd /home/opnfv/repos/securityscanning && python security_scan.py --config config.ini && cd -'
+ cmd: '. /home/opnfv/functest/conf/stackrc && cd /usr/local/lib/python2.7/dist-packages && python security_scan.py --config config.ini && cd -'
-
case_name: copper
@@ -363,7 +363,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /home/opnfv/repos/sfc/sfc/tests/functest && python ./run_tests.py'
+ cmd: 'cd /usr/local/lib/python2.7/dist-packages/sfc/tests/functest && python ./run_tests.py'
-
case_name: onos_sfc
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 8970a5c04..24c9147c8 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
class RallyBase(testcase.OSGCTestCase):
TESTS = ['authenticate', 'glance', 'cinder', 'heat', 'keystone',
- 'neutron', 'nova', 'quotas', 'requests', 'vm', 'all']
+ 'neutron', 'nova', 'quotas', 'vm', 'all']
GLANCE_IMAGE_NAME = CONST.__getattribute__('openstack_image_name')
GLANCE_IMAGE_FILENAME = CONST.__getattribute__('openstack_image_file_name')
GLANCE_IMAGE_PATH = os.path.join(
@@ -102,9 +102,6 @@ class RallyBase(testcase.OSGCTestCase):
else:
task_args['netid'] = ''
- # get keystone auth endpoint
- task_args['request_url'] = CONST.__getattribute__('OS_AUTH_URL') or ''
-
return task_args
def _prepare_test_list(self, test_name):
diff --git a/functest/opnfv_tests/openstack/rally/scenario/opnfv-requests.yaml b/functest/opnfv_tests/openstack/rally/scenario/opnfv-requests.yaml
deleted file mode 100644
index 161369786..000000000
--- a/functest/opnfv_tests/openstack/rally/scenario/opnfv-requests.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
- HttpRequests.check_request:
- -
- args:
- url: "{{ request_url }}"
- method: "GET"
- status_code: 200
- allow_redirects: True
- runner:
- {{ constant_runner(concurrency=concurrency, times=iterations, is_smoke=smoke) }}
- sla:
- {{ no_failures_sla() }}
diff --git a/functest/opnfv_tests/openstack/rally/task.yaml b/functest/opnfv_tests/openstack/rally/task.yaml
index c482f120d..033edb831 100644
--- a/functest/opnfv_tests/openstack/rally/task.yaml
+++ b/functest/opnfv_tests/openstack/rally/task.yaml
@@ -35,10 +35,6 @@
{%- include "var/opnfv-quotas.yaml"-%}
{% endif %}
-{% if "requests" in service_list %}
-{%- include "var/opnfv-requests.yaml"-%}
-{% endif %}
-
{% if "heat" in service_list %}
{%- include "var/opnfv-heat.yaml"-%}
{% endif %}
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 30d1cf089..c46188947 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
# matthew.lijun@huawei.com wangwulin@huawei.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -45,31 +45,18 @@ class RefstackClient(testcase.OSGCTestCase):
self.defcorelist = pkg_resources.resource_filename(
'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
- def source_venv(self):
-
- cmd = ("cd {0};"
- ". .venv/bin/activate;"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client')))
- ft_utils.execute_command(cmd)
-
def run_defcore(self, conf, testlist):
logger.debug("Generating test case list...")
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
- conf,
- testlist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(conf, testlist))
ft_utils.execute_command(cmd)
def run_defcore_default(self):
logger.debug("Generating test case list...")
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
- self.confpath,
- self.defcorelist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(self.confpath, self.defcorelist))
logger.info("Starting Refstack_defcore test case: '%s'." % cmd)
header = ("Refstack environment:\n"
@@ -159,7 +146,6 @@ class RefstackClient(testcase.OSGCTestCase):
try:
tempestconf = TempestConf()
tempestconf.generate_tempestconf()
- self.source_venv()
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
@@ -192,7 +178,6 @@ class RefstackClient(testcase.OSGCTestCase):
"%s", e)
return self.EX_RUN_ERROR
try:
- self.source_venv()
self._prep_test()
self.run_defcore(self.confpath, self.testlist)
res = testcase.TestCase.EX_OK
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index 43518cb4e..c3cd90635 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -37,5 +37,6 @@ class ApiCheck(SnapsTestRunner):
suite=self.suite,
os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
- use_keystone=self.use_keystone)
+ use_keystone=self.use_keystone,
+ image_metadata=self.image_metadata)
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 4e94460c2..1b8d05375 100644
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ b/functest/opnfv_tests/openstack/snaps/health_check.py
@@ -8,9 +8,8 @@
import unittest
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-from functest.utils.constants import CONST
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
+ SnapsTestRunner)
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck
@@ -35,15 +34,11 @@ class HealthCheck(SnapsTestRunner):
:param kwargs: the arguments to pass on
:return:
"""
- image_custom_config = None
-
- if hasattr(CONST, 'snaps_images_cirros'):
- image_custom_config = CONST.__getattribute__('snaps_images_cirros')
self.suite.addTest(
OSIntegrationTestCase.parameterize(
SimpleHealthCheck, os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
- image_metadata=image_custom_config))
+ image_metadata=self.image_metadata))
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 c3c55c7c3..7a3eb2f8f 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -6,14 +6,12 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import os
import unittest
from snaps import test_suite_builder
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-from functest.utils.constants import CONST
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
+ SnapsTestRunner)
class SnapsSmoke(SnapsTestRunner):
@@ -35,23 +33,12 @@ class SnapsSmoke(SnapsTestRunner):
:param kwargs: the arguments to pass on
:return:
"""
- image_config = None
- if hasattr(CONST, 'snaps_images_cirros'):
- image_config = CONST.__getattribute__('snaps_images_cirros')
-
- # Tests requiring floating IPs leverage files contained within the
- # SNAPS repository and are found relative to that path
- if self.use_fip:
- snaps_dir = os.path.join(CONST.__getattribute__('dir_repo_snaps'),
- 'snaps')
- os.chdir(snaps_dir)
-
test_suite_builder.add_openstack_integration_tests(
suite=self.suite,
os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
- image_metadata=image_config,
+ image_metadata=self.image_metadata,
use_floating_ips=self.use_fip)
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
index e8a421595..0b87440b8 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
@@ -46,3 +46,7 @@ class SnapsTestRunner(unit.Suite):
self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
+
+ self.image_metadata = None
+ if hasattr(CONST, 'snaps_images'):
+ self.image_metadata = CONST.__getattribute__('snaps_images')
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index fb5dcbc6e..67bf66e34 100755..100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -117,7 +117,7 @@ class ODLTests(testcase.TestCase):
self.details['description'] = result.suite.name
self.details['tests'] = visitor.get_data()
- def main(self, suites=None, **kwargs):
+ def run_suites(self, suites=None, **kwargs):
"""Run the test suites
It has been designed to be called in any context.
@@ -246,7 +246,7 @@ class ODLTests(testcase.TestCase):
self.__logger.exception("Cannot run ODL testcases.")
return self.EX_RUN_ERROR
- return self.main(suites, **kwargs)
+ return self.run_suites(suites, **kwargs)
class ODLParser(object): # pylint: disable=too-few-public-methods
@@ -301,16 +301,19 @@ class ODLParser(object): # pylint: disable=too-few-public-methods
return vars(self.parser.parse_args(argv))
-if __name__ == '__main__':
+def main():
+ """Entry point"""
logging.basicConfig()
- ODL = ODLTests()
- PARSER = ODLParser()
- ARGS = PARSER.parse_args(sys.argv[1:])
+ odl = ODLTests()
+ parser = ODLParser()
+ args = parser.parse_args(sys.argv[1:])
try:
- RESULT = ODL.main(ODLTests.default_suites, **ARGS)
- if RESULT != testcase.TestCase.EX_OK:
- sys.exit(RESULT)
- if ARGS['pushtodb']:
- sys.exit(ODL.push_to_db())
+ result = odl.run_suites(ODLTests.default_suites, **args)
+ if result != testcase.TestCase.EX_OK:
+ return result
+ if args['pushtodb']:
+ return odl.push_to_db()
+ else:
+ return result
except Exception: # pylint: disable=broad-except
- sys.exit(testcase.TestCase.EX_RUN_ERROR)
+ return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 60adf211d..070a8d2ec 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -202,10 +202,10 @@ class ODLRobotTesting(ODLTesting):
class ODLMainTesting(ODLTesting):
- """The class testing ODLTests.main()."""
+ """The class testing ODLTests.run_suites()."""
# pylint: disable=missing-docstring
- def _get_main_kwargs(self, key=None):
+ def _get_run_suites_kwargs(self, key=None):
kwargs = {'odlusername': self._odl_username,
'odlpassword': self._odl_password,
'neutronip': self._neutron_ip,
@@ -220,9 +220,9 @@ class ODLMainTesting(ODLTesting):
del kwargs[key]
return kwargs
- def _test_main(self, status, *args):
- kwargs = self._get_main_kwargs()
- self.assertEqual(self.test.main(**kwargs), status)
+ def _test_run_suites(self, status, *args):
+ kwargs = self._get_run_suites_kwargs()
+ self.assertEqual(self.test.run_suites(**kwargs), status)
if len(args) > 0:
args[0].assert_called_once_with(
odl.ODLTests.res_dir)
@@ -249,8 +249,8 @@ class ODLMainTesting(ODLTesting):
os.path.join(odl.ODLTests.res_dir, 'stdout.txt'))
def _test_no_keyword(self, key):
- kwargs = self._get_main_kwargs(key)
- self.assertEqual(self.test.main(**kwargs),
+ kwargs = self._get_run_suites_kwargs(key)
+ self.assertEqual(self.test.run_suites(**kwargs),
testcase.TestCase.EX_RUN_ERROR)
def test_no_odlusername(self):
@@ -286,7 +286,7 @@ class ODLMainTesting(ODLTesting):
def test_set_vars_ko(self):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=False) as mock_object:
- self._test_main(testcase.TestCase.EX_RUN_ERROR)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR)
mock_object.assert_called_once_with(
self._odl_username, self._odl_password)
@@ -295,15 +295,15 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
self.assertRaises(Exception):
- self._test_main(testcase.TestCase.EX_RUN_ERROR,
- mock_method)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR,
+ mock_method)
@mock.patch('os.makedirs', side_effect=OSError)
def test_makedirs_oserror(self, mock_method):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True):
- self._test_main(testcase.TestCase.EX_RUN_ERROR,
- mock_method)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR,
+ mock_method)
@mock.patch('robot.run', side_effect=RobotError)
@mock.patch('os.makedirs')
@@ -311,7 +311,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
self.assertRaises(RobotError):
- self._test_main(testcase.TestCase.EX_RUN_ERROR, *args)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs')
@@ -320,7 +320,7 @@ class ODLMainTesting(ODLTesting):
return_value=True), \
mock.patch.object(self.test, 'parse_results',
side_effect=RobotError):
- self._test_main(testcase.TestCase.EX_RUN_ERROR, *args)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs')
@@ -328,7 +328,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs', side_effect=OSError(errno.EEXIST, ''))
@@ -336,7 +336,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
@mock.patch('robot.run', return_value=1)
@mock.patch('os.makedirs')
@@ -344,7 +344,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
class ODLRunTesting(ODLTesting):
@@ -371,11 +371,11 @@ class ODLRunTesting(ODLTesting):
return_value="http://{}:9696".format(
ODLTesting._neutron_ip)):
if exception:
- self.test.main = mock.Mock(side_effect=exception)
+ self.test.run_suites = mock.Mock(side_effect=exception)
else:
- self.test.main = mock.Mock(return_value=status)
+ self.test.run_suites = mock.Mock(return_value=status)
self.assertEqual(self.test.run(), status)
- self.test.main.assert_called_once_with(
+ self.test.run_suites.assert_called_once_with(
odl.ODLTests.default_suites,
neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
@@ -394,9 +394,9 @@ class ODLRunTesting(ODLTesting):
with mock.patch('functest.utils.openstack_utils.get_endpoint',
return_value="http://{}:9696".format(
ODLTesting._neutron_ip)):
- self.test.main = mock.Mock(return_value=status)
+ self.test.run_suites = mock.Mock(return_value=status)
self.assertEqual(self.test.run(suites=suites), status)
- self.test.main.assert_called_once_with(
+ self.test.run_suites.assert_called_once_with(
suites,
neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
@@ -424,13 +424,13 @@ class ODLRunTesting(ODLTesting):
def test_no_os_tenant_name(self):
self._test_no_env_var("OS_TENANT_NAME")
- def test_main_false(self):
+ def test_run_suites_false(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
self._test_run(testcase.TestCase.EX_RUN_ERROR,
odlip=self._sdn_controller_ip,
odlwebport=self._odl_webport)
- def test_main_exc(self):
+ def test_run_suites_exc(self):
with self.assertRaises(Exception):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
self._test_run(status=testcase.TestCase.EX_RUN_ERROR,
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index b9e786162..8845f6604 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -53,14 +53,6 @@ class OSRallyTesting(unittest.TestCase):
task_args = self.rally_base._build_task_args('test_file_name')
self.assertEqual(task_args['netid'], '')
- def test_build_task_args_missing_auth_url(self):
- CONST.__setattr__('OS_AUTH_URL', None)
- with mock.patch('functest.opnfv_tests.openstack.rally.rally.'
- 'os_utils.get_external_net',
- return_value='test_floating_network'):
- task_args = self.rally_base._build_task_args('test_file_name')
- self.assertEqual(task_args['request_url'], '')
-
def check_scenario_file(self, value):
yaml_file = 'opnfv-{}.yaml'.format('test_file_name')
if yaml_file in value:
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 3a121245c..f92d28065 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
-
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+# matthew.lijun@huawei.com wangwulin@huawei.com
# 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
@@ -12,7 +13,6 @@ import unittest
from functest.core import testcase
from functest.opnfv_tests.openstack.refstack_client import refstack_client
-from functest.utils.constants import CONST
class OSRefstackClientTesting(unittest.TestCase):
@@ -28,27 +28,13 @@ class OSRefstackClientTesting(unittest.TestCase):
'testlist': self._testlist}
self.refstackclient = refstack_client.RefstackClient()
- def test_source_venv(self):
- with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
- 'refstack_client.ft_utils.execute_command') as m:
- cmd = ("cd {0};"
- ". .venv/bin/activate;"
- "cd -;"
- .format(CONST.__getattribute__('dir_refstack_client')))
- self.refstackclient.source_venv()
- m.assert_any_call(cmd)
-
def test_run_defcore(self):
config = 'tempest.conf'
testlist = 'testlist'
with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
'refstack_client.ft_utils.execute_command') as m:
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;"
- .format(CONST.__getattribute__('dir_refstack_client'),
- config,
- testlist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(config, testlist))
self.refstackclient.run_defcore(config, testlist)
m.assert_any_call(cmd)
diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py
index 74b49aaaf..828fb3d45 100644
--- a/functest/tests/unit/utils/test_openstack_utils.py
+++ b/functest/tests/unit/utils/test_openstack_utils.py
@@ -255,12 +255,6 @@ class OSUtilsTesting(unittest.TestCase):
'delete_port.return_value': mock.Mock(),
'remove_interface_router.return_value': mock.Mock(),
'remove_gateway_router.return_value': mock.Mock(),
- 'create_bgpvpn.return_value': self.mock_return,
- 'create_network_association.return_value': self.mock_return,
- 'create_router_association.return_value': self.mock_return,
- 'update_bgpvpn.return_value': self.mock_return,
- 'delete_bgpvpn.return_value': self.mock_return,
- 'show_bgpvpn.return_value': self.mock_return,
'list_security_groups.return_value': {'security_groups':
[self.sec_group]},
'list_security_group_rules.'
@@ -1212,53 +1206,6 @@ class OSUtilsTesting(unittest.TestCase):
'router_id'))
self.assertTrue(mock_logger_error.called)
- def test_create_bgpvpn(self):
- self.assertEqual(openstack_utils.
- create_bgpvpn(self.neutron_client),
- self.mock_return)
-
- def test_create_network_association(self):
- self.assertEqual(openstack_utils.
- create_network_association(self.neutron_client,
- 'bgpvpn_id',
- 'network_id'),
- self.mock_return)
-
- def test_create_router_association(self):
- self.assertEqual(openstack_utils.
- create_router_association(self.neutron_client,
- 'bgpvpn_id',
- 'router_id'),
- self.mock_return)
-
- def test_update_bgpvpn(self):
- self.assertEqual(openstack_utils.
- update_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_delete_bgpvpn(self):
- self.assertEqual(openstack_utils.
- delete_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_get_bgpvpn(self):
- self.assertEqual(openstack_utils.
- get_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_get_bgpvpn_routers(self):
- with mock.patch('functest.utils.openstack_utils.'
- 'get_bgpvpn',
- return_value={'bgpvpn':
- {'routers': [self.router]}}):
- self.assertEqual(openstack_utils.
- get_bgpvpn_routers(self.neutron_client,
- 'bgpvpn_id'),
- [self.router])
-
def test_get_security_groups_default(self):
self.assertEqual(openstack_utils.
get_security_groups(self.neutron_client),
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index e7cdfc862..0ab630583 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -962,43 +962,6 @@ def create_shared_network_full(net_name, subnt_name, router_name, subnet_cidr):
return network_dic
-def create_bgpvpn(neutron_client, **kwargs):
- # route_distinguishers
- # route_targets
- json_body = {"bgpvpn": kwargs}
- return neutron_client.create_bgpvpn(json_body)
-
-
-def create_network_association(neutron_client, bgpvpn_id, neutron_network_id):
- json_body = {"network_association": {"network_id": neutron_network_id}}
- return neutron_client.create_network_association(bgpvpn_id, json_body)
-
-
-def create_router_association(neutron_client, bgpvpn_id, router_id):
- json_body = {"router_association": {"router_id": router_id}}
- return neutron_client.create_router_association(bgpvpn_id, json_body)
-
-
-def update_bgpvpn(neutron_client, bgpvpn_id, **kwargs):
- json_body = {"bgpvpn": kwargs}
- return neutron_client.update_bgpvpn(bgpvpn_id, json_body)
-
-
-def delete_bgpvpn(neutron_client, bgpvpn_id):
- return neutron_client.delete_bgpvpn(bgpvpn_id)
-
-
-def get_bgpvpn(neutron_client, bgpvpn_id):
- return neutron_client.show_bgpvpn(bgpvpn_id)
-
-
-def get_bgpvpn_routers(neutron_client, bgpvpn_id):
- return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['routers']
-
-
-def get_bgpvpn_networks(neutron_client, bgpvpn_id):
- return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['networks']
-
# *********************************************
# SEC GROUPS
# *********************************************
diff --git a/setup.cfg b/setup.cfg
index ba137687d..12da1b63a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -13,3 +13,4 @@ scripts =
[entry_points]
console_scripts =
functest = functest.cli.cli_base:cli
+ functest_odl = functest.opnfv_tests.sdn.odl.odl:main