aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-03-11 13:55:40 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2019-03-12 19:00:47 +0100
commite44841210c53290207db9b958c66cb8019910cb7 (patch)
tree5b2693803938d0c1b3314c4d4f84d9ee17adf0f7 /functest
parentd217430315c5ac571c0006c1178ff6ac50bd3d3a (diff)
Remove Snaps-based testcases
Snaps hasn't been synchronized for a while regarding requirements. We do remove it due to the inactivity. All test result tabs will be updated in a second change. Change-Id: I834afd902829ed3883b0e88e92aa806ec43d6fcf Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest')
-rw-r--r--functest/ci/__init__.py0
-rw-r--r--functest/ci/check_deployment.py188
-rw-r--r--functest/ci/config_aarch64_patch.yaml15
-rw-r--r--functest/ci/config_functest.yaml41
-rw-r--r--functest/ci/config_patch.yaml4
-rw-r--r--functest/ci/download_images.sh5
-rw-r--r--functest/ci/testcases.yaml43
-rw-r--r--functest/opnfv_tests/openstack/snaps/__init__.py0
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py50
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py49
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py48
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py416
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py114
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_utils.py66
-rw-r--r--functest/tests/unit/ci/__init__.py0
-rw-r--r--functest/tests/unit/ci/test_check_deployment.py286
-rw-r--r--functest/tests/unit/openstack/snaps/__init__.py0
-rw-r--r--functest/tests/unit/openstack/snaps/test_snaps.py288
-rw-r--r--functest/tests/unit/vnf/epc/test_juju_epc.py1
19 files changed, 0 insertions, 1614 deletions
diff --git a/functest/ci/__init__.py b/functest/ci/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/ci/__init__.py
+++ /dev/null
diff --git a/functest/ci/check_deployment.py b/functest/ci/check_deployment.py
deleted file mode 100644
index 16c69345c..000000000
--- a/functest/ci/check_deployment.py
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Ericsson and others.
-#
-# 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
-
-""" OpenStack deployment checker
-
-Verifies that:
-
- - Credentials file is given and contains the right information
- - OpenStack endpoints are reachable
-"""
-
-import logging
-import logging.config
-import os
-import socket
-
-import pkg_resources
-from six.moves import urllib
-from snaps.openstack.tests import openstack_tests
-from snaps.openstack.utils import glance_utils
-from snaps.openstack.utils import keystone_utils
-from snaps.openstack.utils import neutron_utils
-from snaps.openstack.utils import nova_utils
-
-from functest.utils import constants
-from functest.opnfv_tests.openstack.snaps import snaps_utils
-
-__author__ = "Jose Lausuch <jose.lausuch@ericsson.com>"
-
-LOGGER = logging.getLogger(__name__)
-
-
-def verify_connectivity(endpoint):
- """ Returns true if an hostname/port is reachable"""
- try:
- connection = socket.socket()
- connection.settimeout(10)
- url = urllib.parse.urlparse(endpoint)
- port = url.port
- if not port:
- port = 443 if url.scheme == "https" else 80
- connection.connect((url.hostname, port))
- LOGGER.debug('%s:%s is reachable!', url.hostname, port)
- return True
- except socket.error:
- LOGGER.error('%s:%s is not reachable.', url.hostname, port)
- except Exception: # pylint: disable=broad-except
- LOGGER.exception(
- 'Errors when verifying connectivity to %s:%s', url.hostname, port)
- return False
-
-
-def get_auth_token(os_creds):
- """ Get auth token """
- sess = keystone_utils.keystone_session(os_creds)
- try:
- return sess.get_token()
- except Exception as error:
- LOGGER.error("Got token ...FAILED")
- raise error
-
-
-class CheckDeployment(object):
- """ Check deployment class."""
-
- def __init__(self, rc_file=constants.ENV_FILE):
- self.rc_file = rc_file
- self.services = ('compute', 'network', 'image')
- self.os_creds = None
-
- def check_rc(self):
- """ Check if RC file exists and contains OS_AUTH_URL """
- if not os.path.isfile(self.rc_file):
- raise IOError('RC file {} does not exist!'.format(self.rc_file))
- if 'OS_AUTH_URL' not in open(self.rc_file).read():
- raise SyntaxError('OS_AUTH_URL not defined in {}.'.
- format(self.rc_file))
-
- def check_auth_endpoint(self):
- """ Verifies connectivity to the OS_AUTH_URL given in the RC file
- and get auth token"""
- rc_endpoint = self.os_creds.auth_url
- if not verify_connectivity(rc_endpoint):
- raise Exception("OS_AUTH_URL {} is not reachable.".
- format(rc_endpoint))
- LOGGER.info("Connectivity to OS_AUTH_URL %s ...OK", rc_endpoint)
- if get_auth_token(self.os_creds):
- LOGGER.info("Got token ...OK")
-
- def check_public_endpoint(self):
- """ Gets the public endpoint and verifies connectivity to it """
- public_endpoint = keystone_utils.get_endpoint(self.os_creds,
- 'identity',
- interface='public')
- if not verify_connectivity(public_endpoint):
- raise Exception("Public endpoint {} is not reachable.".
- format(public_endpoint))
- LOGGER.info("Connectivity to the public endpoint %s ...OK",
- public_endpoint)
-
- def check_service_endpoint(self, service):
- """ Verifies connectivity to a given openstack service """
- endpoint = keystone_utils.get_endpoint(self.os_creds,
- service,
- interface='public')
- if not verify_connectivity(endpoint):
- raise Exception("{} endpoint {} is not reachable.".
- format(service, endpoint))
- LOGGER.info("Connectivity to endpoint '%s' %s ...OK",
- service, endpoint)
-
- def check_nova(self):
- """ checks that a simple nova operation works """
- try:
- client = nova_utils.nova_client(self.os_creds)
- client.servers.list()
- LOGGER.info("Nova service ...OK")
- except Exception as error:
- LOGGER.error("Nova service ...FAILED")
- raise error
-
- def check_neutron(self):
- """ checks that a simple neutron operation works """
- try:
- client = neutron_utils.neutron_client(self.os_creds)
- client.list_networks()
- LOGGER.info("Neutron service ...OK")
- except Exception as error:
- LOGGER.error("Neutron service ...FAILED")
- raise error
-
- def check_glance(self):
- """ checks that a simple glance operation works """
- try:
- client = glance_utils.glance_client(self.os_creds)
- client.images.list()
- LOGGER.info("Glance service ...OK")
- except Exception as error:
- LOGGER.error("Glance service ...FAILED")
- raise error
-
- def check_ext_net(self):
- """ checks if external network exists """
- ext_net = snaps_utils.get_ext_net_name(self.os_creds)
- if ext_net:
- LOGGER.info("External network found: %s", ext_net)
- else:
- raise Exception("ERROR: No external networks in the deployment.")
-
- def check_all(self):
- """
- Calls all the class functions and returns 0 if all of them succeed.
- This is the method called by CLI
- """
- self.check_rc()
- try:
- self.os_creds = openstack_tests.get_credentials(
- os_env_file=self.rc_file,
- proxy_settings_str=None,
- ssh_proxy_cmd=None)
- except:
- raise Exception("Problem while getting credentials object.")
- if self.os_creds is None:
- raise Exception("Credentials is None.")
- self.check_auth_endpoint()
- self.check_public_endpoint()
- for service in self.services:
- self.check_service_endpoint(service)
- self.check_nova()
- self.check_neutron()
- self.check_glance()
- self.check_ext_net()
- return 0
-
-
-def main():
- """Entry point"""
- logging.config.fileConfig(pkg_resources.resource_filename(
- 'functest', 'ci/logging.ini'))
- logging.captureWarnings(True)
- deployment = CheckDeployment()
- return deployment.check_all()
diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml
index 835a82737..1e5aed410 100644
--- a/functest/ci/config_aarch64_patch.yaml
+++ b/functest/ci/config_aarch64_patch.yaml
@@ -80,20 +80,5 @@ os:
rally_full:
image: /home/opnfv/functest/images/cirros-0.4.0-aarch64-disk.img
- snaps:
- images:
- glance_tests:
- disk_file:
- /home/opnfv/functest/images/cirros-0.4.0-aarch64-disk.img
- cirros:
- disk_file:
- /home/opnfv/functest/images/cirros-0.4.0-aarch64-disk.img
- ubuntu:
- disk_file:
- /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-arm64-uefi1.img
- centos:
- disk_file:
- /home/opnfv/functest/images/CentOS-7-aarch64-GenericCloud.qcow2
-
tempest:
use_custom_flavors: 'True'
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 07686f8fa..d7a162f73 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -42,47 +42,6 @@ general:
neutron_private_subnet_gateway: 192.168.120.254
neutron_router_name: functest-router
-snaps:
- use_keystone: 'True'
- use_floating_ips: 'True'
- flavor_extra_specs: {}
- images:
- glance_tests:
- disk_file: /home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img
- cirros:
- disk_file: /home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img
- 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
-# 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:
-# username: {user}
-# password: {password}
-# auth_url: {auth_url}
-# project_name: {project_name}
-# identity_api_version: {2|3}
-# network_api_version: {2}
-# compute_api_version: {2}
-# image_api_version: {1|2}
-# user_domain_id: {user_domain_id}
-# project_domain_id: {projects_domain_id}
-# interface: {interface}
-# cacert: {True|False}
-# proxy_settings:
-# host: {proxy_host}
-# port: {proxy_port}
-# ssh_proxy_cmd: {OpenSSH -o ProxyCommand value}
-
-
vping:
ping_timeout: 200
vm_flavor: m1.tiny # adapt to your environment
diff --git a/functest/ci/config_patch.yaml b/functest/ci/config_patch.yaml
index 42220832e..754f19edf 100644
--- a/functest/ci/config_patch.yaml
+++ b/functest/ci/config_patch.yaml
@@ -3,8 +3,6 @@ fdio:
general:
openstack:
flavor_ram: 1024
- snaps:
- flavor_extra_specs: {'hw:mem_page_size':'large'}
vmready1:
flavor_ram: 1024
vmready2:
@@ -52,8 +50,6 @@ ovs:
general:
openstack:
flavor_ram: 1024
- snaps:
- flavor_extra_specs: {'hw:mem_page_size':'large'}
vmready1:
flavor_ram: 1024
vmready2:
diff --git a/functest/ci/download_images.sh b/functest/ci/download_images.sh
index 9044bfe99..9612f85b2 100644
--- a/functest/ci/download_images.sh
+++ b/functest/ci/download_images.sh
@@ -8,16 +8,11 @@ wget_opts="-N --tries=1 --connect-timeout=30"
cat << EOF | wget ${wget_opts} -i - -P ${1:-/home/opnfv/functest/images}
http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img
-https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img
http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-aarch64-disk.img
https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-arm64-uefi1.img
-http://cloud.centos.org/altarch/7/images/aarch64/CentOS-7-aarch64-GenericCloud.qcow2.xz
http://repository.cloudifysource.org/cloudify/19.01.24/community-release/cloudify-docker-manager-community-19.01.24.tar
http://testresults.opnfv.org/functest/vyos-1.1.8-amd64.qcow2
http://testresults.opnfv.org/functest/shaker-image.qcow2
http://testresults.opnfv.org/functest/shaker-image-arm64.qcow2
EOF
-
-xz --decompress --force --keep \
- ${1:-/home/opnfv/functest/images}/CentOS-7-aarch64-GenericCloud.qcow2.xz
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index 71d524e5c..672349cb5 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -146,33 +146,6 @@ tiers:
- /src/odl_test/csit/suites/openstack/neutron
-
- case_name: api_check
- project_name: functest
- criteria: 100
- blocking: true
- description: >-
- This test case verifies the retrieval of OpenStack clients:
- Keystone, Glance, Neutron and Nova and may perform some
- simple queries. When the config value of
- snaps.use_keystone is True, functest must have access to
- the cloud's private network.
- run:
- name: api_check
-
- -
- case_name: snaps_health_check
- project_name: functest
- criteria: 100
- blocking: true
- 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.
- run:
- name: snaps_health_check
-
- -
case_name: tempest_smoke
project_name: functest
criteria: 100
@@ -296,22 +269,6 @@ tiers:
- 'test_auto_allocated_topology_rbac'
-
- case_name: snaps_smoke
- project_name: functest
- criteria: 100
- blocking: false
- description: >-
- This test case contains tests that setup and destroy
- environments with VMs with and without Floating IPs
- with a newly created user and project. Set the config
- value snaps.use_floating_ips (True|False) to toggle
- this functionality. When the config value of
- snaps.use_keystone is True, functest must have access to
- the cloud's private network.
- run:
- name: snaps_smoke
-
- -
case_name: neutron_trunk
project_name: functest
criteria: 100
diff --git a/functest/opnfv_tests/openstack/snaps/__init__.py b/functest/opnfv_tests/openstack/snaps/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/opnfv_tests/openstack/snaps/__init__.py
+++ /dev/null
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
deleted file mode 100644
index d4204bff1..000000000
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-"""api_check test case implementation"""
-
-import unittest
-
-from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-
-
-class ApiCheck(SnapsTestRunner):
- """
- This test executes the Python Tests included with the SNAPS libraries
- that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
- and Nova
- """
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = "api_check"
- super(ApiCheck, self).__init__(**kwargs)
-
- self.suite = unittest.TestSuite()
-
- def run(self, **kwargs):
- """
- Builds the test suite then calls super.run()
- :param kwargs: the arguments to pass on
- :return:
- """
- snaps_suite_builder.add_openstack_client_tests(
- suite=self.suite,
- os_creds=self.os_creds,
- ext_net_name=self.ext_net_name,
- use_keystone=self.use_keystone)
- snaps_suite_builder.add_openstack_api_tests(
- suite=self.suite,
- os_creds=self.os_creds,
- ext_net_name=self.ext_net_name,
- use_keystone=self.use_keystone,
- image_metadata=self.image_metadata)
- return super(ApiCheck, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
deleted file mode 100644
index 3a9c821d2..000000000
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-"""snaps_health_check test case implementation"""
-
-import unittest
-
-from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck
-from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
-
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
- SnapsTestRunner)
-
-
-class HealthCheck(SnapsTestRunner):
- """
- This test executes the SNAPS Python Test case SimpleHealthCheck which
- creates a VM with a single port with an IPv4 address that is assigned by
- DHCP. This test then validates the expected IP with the actual
- """
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = "snaps_images_cirros"
- super(HealthCheck, self).__init__(**kwargs)
-
- self.suite = unittest.TestSuite()
-
- def run(self, **kwargs):
- """
- Builds the test suite then calls super.run()
- :param kwargs: the arguments to pass on
- :return:
- """
- 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=self.image_metadata,
- netconf_override=self.netconf_override))
- return super(HealthCheck, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
deleted file mode 100644
index bc6781180..000000000
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-"""snaps_smoke test case implementation"""
-
-import unittest
-
-from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
- SnapsTestRunner)
-
-
-class SnapsSmoke(SnapsTestRunner):
- """
- This test executes the Python Tests included with the SNAPS libraries
- that exercise many of the OpenStack APIs within Keystone, Glance, Neutron,
- and Nova
- """
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = "snaps_smoke"
- super(SnapsSmoke, self).__init__(**kwargs)
-
- self.suite = unittest.TestSuite()
-
- def run(self, **kwargs):
- """
- Builds the test suite then calls super.run()
- :param kwargs: the arguments to pass on
- :return:
- """
- snaps_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=self.image_metadata,
- use_floating_ips=self.use_fip,
- netconf_override=self.netconf_override)
- return super(SnapsSmoke, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py b/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
deleted file mode 100644
index 95da15ae8..000000000
--- a/functest/opnfv_tests/openstack/snaps/snaps_suite_builder.py
+++ /dev/null
@@ -1,416 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-"""
-Snaps test suite including openstack client tests, api tests and
-integration tests.
-add_openstack_client_tests: for connection_check
-add_openstack_api_tests: for api_check
-add_openstack_integration_tests: for snaps_smoke
-"""
-
-import logging
-
-from snaps.openstack.tests.create_flavor_tests import (
- CreateFlavorTests)
-from snaps.openstack.tests.create_image_tests import (
- CreateImageSuccessTests, CreateImageNegativeTests,
- CreateMultiPartImageTests)
-from snaps.openstack.tests.create_instance_tests import (
- CreateInstanceOnComputeHost,
- CreateInstanceSimpleTests, InstanceSecurityGroupTests,
- CreateInstancePortManipulationTests, SimpleHealthCheck,
- CreateInstanceFromThreePartImage, CreateInstanceTwoNetTests)
-from snaps.openstack.tests.create_keypairs_tests import (
- CreateKeypairsTests, CreateKeypairsCleanupTests)
-from snaps.openstack.tests.create_network_tests import (
- CreateNetworkSuccessTests)
-from snaps.openstack.tests.create_project_tests import (
- CreateProjectSuccessTests, CreateProjectUserTests)
-from snaps.openstack.tests.create_qos_tests import (
- CreateQoSTests)
-from snaps.openstack.tests.create_router_tests import (
- CreateRouterSuccessTests, CreateRouterNegativeTests)
-from snaps.openstack.tests.create_security_group_tests import (
- CreateSecurityGroupTests)
-from snaps.openstack.tests.create_stack_tests import (
- CreateStackSuccessTests, CreateStackNegativeTests,
- CreateStackFlavorTests, CreateStackFloatingIpTests,
- CreateStackKeypairTests, CreateStackVolumeTests,
- CreateStackSecurityGroupTests)
-from snaps.openstack.tests.create_user_tests import (
- CreateUserSuccessTests)
-from snaps.openstack.tests.create_volume_tests import (
- CreateSimpleVolumeSuccessTests,
- CreateVolumeWithTypeTests, CreateVolumeWithImageTests,
- CreateSimpleVolumeFailureTests)
-from snaps.openstack.tests.create_volume_type_tests import (
- CreateSimpleVolumeTypeSuccessTests,
- CreateVolumeTypeComplexTests)
-from snaps.openstack.tests.os_source_file_test import (
- OSComponentTestCase, OSIntegrationTestCase)
-from snaps.openstack.utils.tests.cinder_utils_tests import (
- CinderSmokeTests, CinderUtilsQoSTests, CinderUtilsSimpleVolumeTypeTests,
- CinderUtilsAddEncryptionTests, CinderUtilsVolumeTypeCompleteTests,
- CinderUtilsVolumeTests)
-from snaps.openstack.utils.tests.glance_utils_tests import (
- GlanceSmokeTests, GlanceUtilsTests)
-from snaps.openstack.utils.tests.heat_utils_tests import (
- HeatSmokeTests, HeatUtilsCreateSimpleStackTests,
- HeatUtilsCreateComplexStackTests, HeatUtilsFlavorTests,
- HeatUtilsKeypairTests, HeatUtilsSecurityGroupTests)
-from snaps.openstack.utils.tests.keystone_utils_tests import KeystoneSmokeTests
-from snaps.openstack.utils.tests.neutron_utils_tests import (
- NeutronSmokeTests, NeutronUtilsNetworkTests, NeutronUtilsSubnetTests,
- NeutronUtilsRouterTests, NeutronUtilsSecurityGroupTests)
-from snaps.openstack.utils.tests.nova_utils_tests import (
- NovaSmokeTests, NovaUtilsKeypairTests, NovaUtilsFlavorTests,
- NovaUtilsInstanceTests)
-
-
-def add_openstack_client_tests(suite, os_creds, ext_net_name,
- use_keystone=True, log_level=logging.INFO):
- """
- Adds tests written to exercise OpenStack client retrieval
-
- :param suite: the unittest.TestSuite object to which to add the tests
- :param os_creds: and instance of OSCreds that holds the credentials
- required by OpenStack
- :param ext_net_name: the name of an external network on the cloud under
- test
- :param use_keystone: when True, tests requiring direct access to Keystone
- are added as these need to be running on a host that
- has access to the cloud's private network
- :param log_level: the logging level
- :return: None as the tests will be adding to the 'suite' parameter object
- """
- # Basic connection tests
- suite.addTest(
- OSComponentTestCase.parameterize(
- GlanceSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
-
- if use_keystone:
- suite.addTest(
- OSComponentTestCase.parameterize(
- KeystoneSmokeTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level))
-
- suite.addTest(
- OSComponentTestCase.parameterize(
- NeutronSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(
- OSComponentTestCase.parameterize(
- NovaSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(
- OSComponentTestCase.parameterize(
- HeatSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(
- OSComponentTestCase.parameterize(
- CinderSmokeTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
-
-
-def add_openstack_api_tests(suite, os_creds, ext_net_name, use_keystone=True,
- image_metadata=None, log_level=logging.INFO):
- # pylint: disable=too-many-arguments
- """
- Adds tests written to exercise all existing OpenStack APIs
-
- :param suite: the unittest.TestSuite object to which to add the tests
- :param os_creds: Instance of OSCreds that holds the credentials
- required by OpenStack
- :param ext_net_name: the name of an external network on the cloud under
- test
- :param use_keystone: when True, tests requiring direct access to Keystone
- are added as these need to be running on a host that
- has access to the cloud's private network
- :param image_metadata: dict() object containing metadata for creating an
- image with custom config
- (see YAML files in examples/image-metadata)
- :param log_level: the logging level
- :return: None as the tests will be adding to the 'suite' parameter object
- """
- # Tests the OpenStack API calls
- if use_keystone:
- suite.addTest(OSComponentTestCase.parameterize(
- CreateUserSuccessTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- CreateProjectSuccessTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- CreateProjectUserTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level))
-
- suite.addTest(OSComponentTestCase.parameterize(
- GlanceUtilsTests, os_creds=os_creds, ext_net_name=ext_net_name,
- image_metadata=image_metadata,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NeutronUtilsNetworkTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NeutronUtilsSubnetTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NeutronUtilsRouterTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NeutronUtilsSecurityGroupTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NovaUtilsKeypairTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NovaUtilsFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- NovaUtilsInstanceTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level, image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CreateFlavorTests, os_creds=os_creds, ext_net_name=ext_net_name,
- log_level=log_level))
- suite.addTest(OSComponentTestCase.parameterize(
- HeatUtilsCreateSimpleStackTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- HeatUtilsCreateComplexStackTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- HeatUtilsFlavorTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- HeatUtilsKeypairTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- HeatUtilsSecurityGroupTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CinderUtilsQoSTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CinderUtilsVolumeTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CinderUtilsSimpleVolumeTypeTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CinderUtilsAddEncryptionTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
- suite.addTest(OSComponentTestCase.parameterize(
- CinderUtilsVolumeTypeCompleteTests, os_creds=os_creds,
- ext_net_name=ext_net_name, log_level=log_level,
- image_metadata=image_metadata))
-
-
-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):
- # pylint: disable=too-many-arguments
- """
- Adds tests written to exercise all long-running OpenStack integration tests
- meaning they will be creating VM instances and potentially performing some
- SSH functions through floatingIPs
-
- :param suite: the unittest.TestSuite object to which to add the tests
- :param os_creds: and instance of OSCreds that holds the credentials
- required by OpenStack
- :param ext_net_name: the name of an external network on the cloud under
- test
- :param use_keystone: when True, tests requiring direct access to Keystone
- are added as these need to be running on a host that
- has access to the cloud's private network
- :param image_metadata: dict() object containing metadata for creating an
- image with custom config
- (see YAML files in examples/image-metadata)
- :param flavor_metadata: dict() object containing the metadata required by
- your flavor based on your configuration:
- (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
- """
- # Tests the OpenStack API calls via a creator. If use_keystone, objects
- # will be created with a custom user and project
-
- # Creator Object tests
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateSecurityGroupTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateImageSuccessTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateImageNegativeTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateMultiPartImageTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateKeypairsTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateKeypairsCleanupTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateNetworkSuccessTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateRouterSuccessTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateRouterNegativeTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateQoSTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateSimpleVolumeTypeSuccessTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateVolumeTypeComplexTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateSimpleVolumeSuccessTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateSimpleVolumeFailureTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateVolumeWithTypeTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateVolumeWithImageTests, 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))
-
- # VM Instances
- suite.addTest(OSIntegrationTestCase.parameterize(
- SimpleHealthCheck, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateInstanceTwoNetTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateInstanceSimpleTests, os_creds=os_creds,
- ext_net_name=ext_net_name, use_keystone=use_keystone,
- flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- 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,
- 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,
- 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,
- 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,
- 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,
- flavor_metadata=flavor_metadata, image_metadata=image_metadata,
- log_level=log_level))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackVolumeTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackFlavorTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackKeypairTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackSecurityGroupTests, 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))
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackNegativeTests, 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))
-
- if use_floating_ips:
- suite.addTest(OSIntegrationTestCase.parameterize(
- CreateStackFloatingIpTests, 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))
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
deleted file mode 100644
index 9fc098a53..000000000
--- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-"""configuration params to run snaps tests"""
-
-import logging
-import uuid
-
-import os_client_config
-import shade
-from xtesting.core import unit
-
-from functest.core import tenantnetwork
-from functest.opnfv_tests.openstack.snaps import snaps_utils
-from functest.utils import config
-from functest.utils import functest_utils
-
-
-class SnapsTestRunner(unit.Suite):
- # pylint: disable=too-many-instance-attributes
- """
- This test executes the SNAPS Python Tests
- """
-
- def __init__(self, **kwargs):
- super(SnapsTestRunner, self).__init__(**kwargs)
- self.logger = logging.getLogger(__name__)
-
- try:
- cloud_config = os_client_config.get_config()
- self.orig_cloud = shade.OpenStackCloud(cloud_config=cloud_config)
- guid = str(uuid.uuid4())
- self.project = tenantnetwork.NewProject(
- self.orig_cloud, self.case_name, guid)
- self.project.create()
- except Exception: # pylint: disable=broad-except
- raise Exception("Cannot create user or project")
-
- if self.orig_cloud.get_role("admin"):
- role_name = "admin"
- elif self.orig_cloud.get_role("Admin"):
- role_name = "Admin"
- else:
- raise Exception("Cannot detect neither admin nor Admin")
- self.orig_cloud.grant_role(
- role_name, user=self.project.user.id,
- project=self.project.project.id,
- domain=self.project.domain.id)
- self.role = None
- if not self.orig_cloud.get_role("heat_stack_owner"):
- self.role = self.orig_cloud.create_role("heat_stack_owner")
- self.orig_cloud.grant_role(
- "heat_stack_owner", user=self.project.user.id,
- project=self.project.project.id,
- domain=self.project.domain.id)
- creds_overrides = dict(
- username=self.project.user.name,
- project_name=self.project.project.name,
- project_id=self.project.project.id,
- password=self.project.password)
- self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials(
- overrides=creds_overrides)
- if 'ext_net_name' in kwargs:
- self.ext_net_name = kwargs['ext_net_name']
- else:
- self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
-
- self.netconf_override = None
- if hasattr(config.CONF, 'snaps_network_config'):
- self.netconf_override = getattr(
- config.CONF, 'snaps_network_config')
-
- self.use_fip = (
- getattr(config.CONF, 'snaps_use_floating_ips') == 'True')
- self.use_keystone = (
- getattr(config.CONF, 'snaps_use_keystone') == 'True')
-
- self.flavor_metadata = getattr(config.CONF, 'snaps_flavor_extra_specs',
- None)
- self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
-
- self.image_metadata = None
- if hasattr(config.CONF, 'snaps_images'):
- self.image_metadata = getattr(config.CONF, 'snaps_images')
-
- def clean(self):
- """Cleanup of OpenStack resources. Should be called on completion."""
- try:
- super(SnapsTestRunner, self).clean()
- assert self.orig_cloud
- assert self.project
- if self.role:
- self.orig_cloud.delete_role(self.role.id)
- self.project.clean()
- except Exception: # pylint: disable=broad-except
- self.__logger.exception("Cannot clean all resources")
-
- def check_requirements(self):
- """Skip if OpenStack Rocky or newer."""
- try:
- cloud_config = os_client_config.get_config()
- cloud = shade.OpenStackCloud(cloud_config=cloud_config)
- if functest_utils.get_nova_version(cloud) > (2, 60):
- self.is_skipped = True
- self.project.clean()
- except Exception: # pylint: disable=broad-except
- pass
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py
deleted file mode 100644
index f4a6e2ea0..000000000
--- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2015 All rights reserved
-# This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-
-"""Some common utils wrapping snaps functions"""
-
-from snaps.openstack.tests import openstack_tests
-from snaps.openstack.utils import neutron_utils
-from snaps.openstack.utils import nova_utils
-
-from functest.utils import config
-from functest.utils import constants
-from functest.utils import env
-
-
-def get_ext_net_name(os_creds):
- """
- Returns the configured external network name or
- the first retrieved external network name
- :param: os_creds: an instance of snaps OSCreds object
- :return:
- """
- neutron = neutron_utils.neutron_client(os_creds)
- ext_nets = neutron_utils.get_external_networks(neutron)
- if env.get('EXTERNAL_NETWORK'):
- extnet_config = env.get('EXTERNAL_NETWORK')
- for ext_net in ext_nets:
- if ext_net.name == extnet_config:
- return extnet_config
- return ext_nets[0].name if ext_nets else ""
-
-
-def get_active_compute_cnt(os_creds):
- """
- Returns the number of active compute servers
- :param: os_creds: an instance of snaps OSCreds object
- :return: the number of active compute servers
- """
- nova = nova_utils.nova_client(os_creds)
- computes = nova_utils.get_availability_zone_hosts(nova, zone_name='nova')
- return len(computes)
-
-
-def get_credentials(proxy_settings_str=None, ssh_proxy_cmd=None,
- overrides=None):
- """
- Returns snaps OSCreds object instance
- :param: proxy_settings_str: proxy settings string <host>:<port>
- :param: ssh_proxy_cmd: the SSH proxy command for the environment
- :param overrides: dict() values to override in credentials
- :return: an instance of snaps OSCreds object
- """
- creds_override = {}
- if hasattr(config.CONF, 'snaps_os_creds_override'):
- creds_override.update(getattr(config.CONF, 'snaps_os_creds_override'))
- if overrides:
- creds_override.update(overrides)
- os_creds = openstack_tests.get_credentials(
- os_env_file=constants.ENV_FILE, proxy_settings_str=proxy_settings_str,
- ssh_proxy_cmd=ssh_proxy_cmd, overrides=creds_override)
- return os_creds
diff --git a/functest/tests/unit/ci/__init__.py b/functest/tests/unit/ci/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/tests/unit/ci/__init__.py
+++ /dev/null
diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py
deleted file mode 100644
index aeeca5871..000000000
--- a/functest/tests/unit/ci/test_check_deployment.py
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2017 Ericsson and others.
-#
-# 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
-
-# pylint: disable=missing-docstring
-
-import socket
-import unittest
-
-import logging
-import mock
-
-from functest.ci import check_deployment
-
-__author__ = "Jose Lausuch <jose.lausuch@ericsson.com>"
-
-
-class CheckDeploymentTesting(unittest.TestCase):
- """The super class which testing classes could inherit."""
- # pylint: disable=missing-docstring,too-many-public-methods
-
- logging.disable(logging.CRITICAL)
-
- def setUp(self):
- self.client_test = mock.Mock()
- self.deployment = check_deployment.CheckDeployment()
- self.service_test = 'compute'
- self.rc_file = self.deployment.rc_file
- self.endpoint_test = 'http://192.168.0.6:5000/v3'
- creds_attr = {'auth_url': self.endpoint_test,
- 'proxy_settings': ''}
- proxy_attr = {'host': '192.168.0.1', 'port': '5000'}
- proxy_settings = mock.Mock()
- proxy_settings.configure_mock(**proxy_attr)
- self.os_creds = mock.Mock()
- self.os_creds.configure_mock(**creds_attr)
- self.os_creds.proxy_settings = proxy_settings
- self.deployment.os_creds = self.os_creds
-
- @mock.patch('socket.socket.connect', side_effect=TypeError)
- def test_verify_connectivity_ko1(self, *args):
- self.assertFalse(check_deployment.verify_connectivity("127.0.0.1"))
- args[0].assert_called_once_with((None, 80))
-
- @mock.patch('socket.socket.connect', side_effect=socket.error)
- def test_verify_connectivity_ko2(self, *args):
- self.assertFalse(
- check_deployment.verify_connectivity("http://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 80))
-
- @mock.patch('socket.socket.connect', side_effect=socket.error)
- def test_verify_connectivity_ko3(self, *args):
- self.assertFalse(
- check_deployment.verify_connectivity("https://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 443))
-
- @mock.patch('socket.socket.connect')
- def test_verify_connectivity(self, *args):
- self.assertTrue(
- check_deployment.verify_connectivity("https://127.0.0.1"))
- args[0].assert_called_once_with(("127.0.0.1", 443))
-
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_session',
- return_value=mock.Mock(
- get_token=mock.Mock(side_effect=Exception)))
- def test_get_auth_token_ko(self, *args):
- with self.assertRaises(Exception):
- check_deployment.get_auth_token(self.os_creds)
- args[0].assert_called_once_with(self.os_creds)
-
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_session',
- return_value=mock.Mock(
- get_token=mock.Mock(return_value="foo")))
- def test_get_auth_token(self, *args):
- self.assertEqual(check_deployment.get_auth_token(self.os_creds), "foo")
- args[0].assert_called_once_with(self.os_creds)
-
- @mock.patch('six.moves.builtins.open',
- mock.mock_open(read_data='OS_AUTH_URL'))
- @mock.patch('functest.ci.check_deployment.os.path.isfile', returns=True)
- def test_check_rc(self, *args):
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
-
- @mock.patch('functest.ci.check_deployment.os.path.isfile',
- return_value=False)
- def test_check_rc_missing_file(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
- msg = 'RC file {} does not exist!'.format(self.rc_file)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('six.moves.builtins.open',
- mock.mock_open(read_data='test'))
- @mock.patch('functest.ci.check_deployment.os.path.isfile',
- return_value=True)
- def test_check_rc_missing_os_auth(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_rc()
- args[0].assert_called_once_with(self.rc_file)
- msg = 'OS_AUTH_URL not defined in {}.'.format(self.rc_file)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.get_auth_token',
- return_value='gAAAAABaOhXGS')
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- def test_check_auth_endpoint(self, *args):
- self.deployment.check_auth_endpoint()
- args[0].assert_called_once_with(self.endpoint_test)
- args[1].assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- def test_check_auth_endpoint_ko(self, *args):
- with self.assertRaises(Exception) as context:
- self.deployment.check_auth_endpoint()
- msg = "OS_AUTH_URL {} is not reachable.".format(self.os_creds.auth_url)
- args[0].assert_called_once_with(self.os_creds.auth_url)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_public_endpoint(self, *args):
- args[0].return_value = self.endpoint_test
- self.deployment.check_public_endpoint()
- args[0].assert_called_once_with(
- mock.ANY, 'identity', interface='public')
- args[1].assert_called_once_with(self.endpoint_test)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_public_endpoint_ko(self, *args):
- args[0].return_value = self.endpoint_test
- with self.assertRaises(Exception) as context:
- self.deployment.check_public_endpoint()
- args[0].assert_called_once_with(
- mock.ANY, 'identity', interface='public')
- args[1].assert_called_once_with(self.endpoint_test)
- msg = "Public endpoint {} is not reachable.".format(self.endpoint_test)
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=True)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_service_endpoint(self, *args):
- self.deployment.check_service_endpoint(self.service_test)
- args[0].assert_called_once_with(
- mock.ANY, self.service_test, interface='public')
- args[1].assert_called_once_with(args[0].return_value)
-
- @mock.patch('functest.ci.check_deployment.verify_connectivity',
- return_value=False)
- @mock.patch('functest.ci.check_deployment.keystone_utils.get_endpoint')
- def test_check_service_endpoint_ko(self, *args):
- args[0].return_value = self.endpoint_test
- with self.assertRaises(Exception) as context:
- self.deployment.check_service_endpoint(self.service_test)
- msg = "{} endpoint {} is not reachable.".format(
- self.service_test, self.endpoint_test)
- self.assertTrue(msg in str(context.exception))
- args[0].assert_called_once_with(
- mock.ANY, self.service_test, interface='public')
- args[1].assert_called_once_with(args[0].return_value)
-
- @mock.patch('functest.ci.check_deployment.nova_utils.nova_client')
- def test_check_nova(self, mock_method):
- self.deployment.check_nova()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.nova_utils.nova_client',
- return_value=mock.Mock(
- servers=mock.Mock(list=mock.Mock(side_effect=Exception))))
- def test_check_nova_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_nova()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.neutron_utils.neutron_client')
- def test_check_neutron(self, mock_method):
- self.deployment.check_neutron()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.neutron_utils.neutron_client',
- return_value=mock.Mock(
- list_networks=mock.Mock(side_effect=Exception)))
- def test_check_neutron_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_neutron()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.glance_utils.glance_client')
- def test_check_glance(self, mock_method):
- self.deployment.check_glance()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.glance_utils.glance_client',
- return_value=mock.Mock(
- images=mock.Mock(list=mock.Mock(side_effect=Exception))))
- def test_check_glance_fail(self, mock_method):
- with self.assertRaises(Exception):
- self.deployment.check_glance()
- mock_method.assert_called_once_with(mock.ANY)
-
- @mock.patch('functest.ci.check_deployment.LOGGER.info')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_ext_net_name', return_value='ext-net')
- def test_check_extnet(self, *args):
- self.deployment.check_ext_net()
- args[0].assert_called_once_with(mock.ANY)
- args[1].assert_called_once_with(
- "External network found: %s", "ext-net")
-
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_ext_net_name', return_value='')
- def test_check_extnet_none(self, mock_getext):
- with self.assertRaises(Exception) as context:
- self.deployment.check_ext_net()
- self.assertTrue(mock_getext.called)
- msg = 'ERROR: No external networks in the deployment.'
- self.assertTrue(msg in str(context.exception))
-
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc',
- side_effect=Exception)
- def test_check_all_exc1(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
-
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
- side_effect=Exception)
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all_exc2(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
-
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
- return_value=None)
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all_exc3(self, *args):
- with self.assertRaises(Exception):
- self.deployment.check_all()
- args[0].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
-
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_ext_net')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_glance')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_neutron')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_nova')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_service_endpoint')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_public_endpoint')
- @mock.patch(
- 'functest.ci.check_deployment.CheckDeployment.check_auth_endpoint')
- @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
- @mock.patch('functest.ci.check_deployment.CheckDeployment.check_rc')
- def test_check_all(self, *args):
- self.assertEqual(self.deployment.check_all(), 0)
- for i in [0, 2, 3, 5, 6, 7, 8]:
- args[i].assert_called_once_with()
- args[1].assert_called_once_with(
- os_env_file=self.rc_file, proxy_settings_str=None,
- ssh_proxy_cmd=None)
- calls = [mock.call('compute'), mock.call('network'),
- mock.call('image')]
- args[4].assert_has_calls(calls)
-
-
-if __name__ == "__main__":
- logging.disable(logging.CRITICAL)
- unittest.main(verbosity=2)
diff --git a/functest/tests/unit/openstack/snaps/__init__.py b/functest/tests/unit/openstack/snaps/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/tests/unit/openstack/snaps/__init__.py
+++ /dev/null
diff --git a/functest/tests/unit/openstack/snaps/test_snaps.py b/functest/tests/unit/openstack/snaps/test_snaps.py
deleted file mode 100644
index db8e3e04a..000000000
--- a/functest/tests/unit/openstack/snaps/test_snaps.py
+++ /dev/null
@@ -1,288 +0,0 @@
-# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
-#
-# 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
-
-# pylint: disable=missing-docstring
-
-import logging
-import unittest
-
-import mock
-from snaps.openstack.os_credentials import OSCreds
-from xtesting.core import testcase
-
-from functest.opnfv_tests.openstack.snaps import api_check
-from functest.opnfv_tests.openstack.snaps import health_check
-from functest.opnfv_tests.openstack.snaps import smoke
-
-
-class APICheckTesting(unittest.TestCase):
- """
- Ensures the ApiCheck class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.api_check = api_check.ApiCheck(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('unittest.TestLoader')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- testcase.TestCase.EX_OK, self.api_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', image_metadata=mock.ANY,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- testcase.TestCase.EX_TESTCASE_FAILED,
- self.api_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', image_metadata=mock.ANY,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_api_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.api_check.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.api_check.run())
- self.assertEqual(
- testcase.TestCase.EX_OK, self.api_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', image_metadata=mock.ANY,
- os_creds=self.os_creds, suite=mock.ANY, use_keystone=True)
-
-
-class HealthCheckTesting(unittest.TestCase):
- """
- Ensures the HealthCheck class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.health_check = health_check.HealthCheck(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- testcase.TestCase.EX_OK, self.health_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- mock.ANY, ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- testcase.TestCase.EX_TESTCASE_FAILED,
- self.health_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- mock.ANY, ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('snaps.openstack.tests.os_source_file_test.'
- 'OSIntegrationTestCase.parameterize')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.health_check.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.health_check.run())
- self.assertEqual(
- testcase.TestCase.EX_OK, self.health_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- mock.ANY, ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, use_keystone=True)
-
-
-class SmokeTesting(unittest.TestCase):
- """
- Ensures the SnapsSmoke class can run in Functest. This test does not
- actually connect with an OpenStack pod.
- """
-
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- with mock.patch('os_client_config.get_config') as mock_get_config, \
- mock.patch('shade.OpenStackCloud') as mock_shade, \
- mock.patch('functest.core.tenantnetwork.NewProject') \
- as mock_new_project:
- self.smoke = smoke.SnapsSmoke(
- os_creds=self.os_creds, ext_net_name='foo')
- mock_get_config.assert_called()
- mock_shade.assert_called()
- mock_new_project.assert_called()
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_success(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=[]))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(
- testcase.TestCase.EX_TESTCASE_FAILED, self.smoke.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=mock.ANY,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
- @mock.patch('xtesting.core.unit.Suite.generate_html')
- @mock.patch('xtesting.core.unit.Suite.generate_xunit')
- @mock.patch('xtesting.core.unit.Suite.generate_stats')
- @mock.patch('os.path.isdir', return_value=True)
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_integration_tests')
- @mock.patch('subunit.run.SubunitTestRunner.run')
- def test_run_1_of_100_ko_criteria(self, *args):
- self.smoke.criteria = 90
- args[0].return_value = mock.Mock(
- decorated=mock.Mock(
- testsRun=100, errors=[], failures=['foo']))
- with mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.assertEqual(testcase.TestCase.EX_OK, self.smoke.run())
- self.assertEqual(
- testcase.TestCase.EX_OK, self.smoke.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', flavor_metadata=mock.ANY,
- image_metadata=mock.ANY, netconf_override=None,
- os_creds=self.os_creds, suite=mock.ANY, use_floating_ips=True,
- use_keystone=True)
-
-
-if __name__ == "__main__":
- logging.disable(logging.CRITICAL)
- unittest.main(verbosity=2)
diff --git a/functest/tests/unit/vnf/epc/test_juju_epc.py b/functest/tests/unit/vnf/epc/test_juju_epc.py
index 6b4137069..a72c61586 100644
--- a/functest/tests/unit/vnf/epc/test_juju_epc.py
+++ b/functest/tests/unit/vnf/epc/test_juju_epc.py
@@ -62,7 +62,6 @@ class JujuEpcTesting(unittest.TestCase):
'test_vnf': {}}
@unittest.skip("It must be fixed. Please see JIRA FUNCTEST-915")
- @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
@mock.patch('os.system')
def test_prepare_default(self, *args):
""" Unittest for Prepare testcase """