summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/healthcheck/testcases.yaml6
-rw-r--r--functest/ci/testcases.yaml6
-rw-r--r--functest/opnfv_tests/openstack/api/__init__.py0
-rw-r--r--functest/opnfv_tests/openstack/api/connection_check.py54
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py5
-rw-r--r--functest/opnfv_tests/openstack/snaps/connection_check.py44
-rw-r--r--functest/tests/unit/openstack/snaps/test_snaps.py76
7 files changed, 72 insertions, 119 deletions
diff --git a/docker/healthcheck/testcases.yaml b/docker/healthcheck/testcases.yaml
index 12dc7d298..9e9b68b44 100644
--- a/docker/healthcheck/testcases.yaml
+++ b/docker/healthcheck/testcases.yaml
@@ -16,15 +16,13 @@ tiers:
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.
+ simple queries.
dependencies:
installer: ''
scenario: ''
run:
module:
- 'functest.opnfv_tests.openstack.snaps.connection_check'
+ 'functest.opnfv_tests.openstack.api.connection_check'
class: 'ConnectionCheck'
-
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index a4415536c..68d1a369a 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -16,15 +16,13 @@ tiers:
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.
+ simple queries.
dependencies:
installer: ''
scenario: ''
run:
module:
- 'functest.opnfv_tests.openstack.snaps.connection_check'
+ 'functest.opnfv_tests.openstack.api.connection_check'
class: 'ConnectionCheck'
-
diff --git a/functest/opnfv_tests/openstack/api/__init__.py b/functest/opnfv_tests/openstack/api/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/opnfv_tests/openstack/api/__init__.py
diff --git a/functest/opnfv_tests/openstack/api/connection_check.py b/functest/opnfv_tests/openstack/api/connection_check.py
new file mode 100644
index 000000000..663119ade
--- /dev/null
+++ b/functest/opnfv_tests/openstack/api/connection_check.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2018 Orange 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
+
+"""Verify the connection to OpenStack Services"""
+
+import logging
+import time
+
+import os_client_config
+import shade
+from xtesting.core import testcase
+
+
+class ConnectionCheck(testcase.TestCase):
+ """Perform simplest queries"""
+ __logger = logging.getLogger(__name__)
+
+ def __init__(self, **kwargs):
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = 'connection_check'
+ super(ConnectionCheck, self).__init__(**kwargs)
+ try:
+ cloud_config = os_client_config.get_config()
+ self.cloud = shade.OpenStackCloud(cloud_config=cloud_config)
+ except Exception: # pylint: disable=broad-except
+ self.cloud = None
+
+ def run(self, **kwargs):
+ """Run all read operations to check connections"""
+ status = testcase.TestCase.EX_RUN_ERROR
+ try:
+ assert self.cloud
+ self.start_time = time.time()
+ for func in ["list_aggregates", "list_domains", "list_endpoints",
+ "list_floating_ip_pools", "list_floating_ips",
+ "list_hypervisors", "list_keypairs", "list_networks",
+ "list_ports", "list_role_assignments", "list_roles",
+ "list_routers", "list_servers", "list_services",
+ "list_subnets", "list_zones"]:
+ self.__logger.debug(
+ "%s: %s", func, getattr(self.cloud, func)())
+ self.result = 100
+ status = testcase.TestCase.EX_OK
+ except Exception: # pylint: disable=broad-except
+ self.__logger.exception('Cannot run %s', self.case_name)
+ finally:
+ self.stop_time = time.time()
+ return status
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index b8cd4fdd4..d4204bff1 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -36,6 +36,11 @@ class ApiCheck(SnapsTestRunner):
: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,
diff --git a/functest/opnfv_tests/openstack/snaps/connection_check.py b/functest/opnfv_tests/openstack/snaps/connection_check.py
deleted file mode 100644
index f8bf8852e..000000000
--- a/functest/opnfv_tests/openstack/snaps/connection_check.py
+++ /dev/null
@@ -1,44 +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
-
-# pylint: disable=missing-docstring
-
-import unittest
-
-from functest.opnfv_tests.openstack.snaps import snaps_suite_builder
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-
-
-class ConnectionCheck(SnapsTestRunner):
- """
- This test executes the Python Tests included with the SNAPS libraries
- that simply obtain the different OpenStack clients and may perform
- simple queries
- """
- def __init__(self, **kwargs):
- if "case_name" not in kwargs:
- kwargs["case_name"] = "connection_check"
- super(ConnectionCheck, 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)
- return super(ConnectionCheck, self).run()
diff --git a/functest/tests/unit/openstack/snaps/test_snaps.py b/functest/tests/unit/openstack/snaps/test_snaps.py
index 9da4f2ac8..a3760445f 100644
--- a/functest/tests/unit/openstack/snaps/test_snaps.py
+++ b/functest/tests/unit/openstack/snaps/test_snaps.py
@@ -15,73 +15,9 @@ import mock
from snaps.openstack.os_credentials import OSCreds
from xtesting.core import testcase
-from functest.opnfv_tests.openstack.snaps import (
- connection_check, api_check, health_check, smoke)
-
-
-class ConnectionCheckTesting(unittest.TestCase):
- """
- Ensures the VPingUserdata 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')
-
- self.connection_check = connection_check.ConnectionCheck(
- os_creds=self.os_creds, ext_net_name='foo')
-
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
- def test_run_success(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = []
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run())
- self.assertEquals(
- testcase.TestCase.EX_OK, self.connection_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY,
- use_keystone=True)
-
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
- def test_run_1_of_100_ko(self, *args):
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run())
- self.assertEquals(
- testcase.TestCase.EX_TESTCASE_FAILED,
- self.connection_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY,
- use_keystone=True)
-
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_suite_builder.'
- 'add_openstack_client_tests')
- @mock.patch('unittest.TextTestRunner.run',
- return_value=mock.MagicMock(name='unittest.TextTestResult'))
- def test_run_1_of_100_ko_criteria(self, *args):
- self.connection_check.criteria = 90
- args[0].return_value.testsRun = 100
- args[0].return_value.failures = ['foo']
- args[0].return_value.errors = []
- self.assertEquals(testcase.TestCase.EX_OK, self.connection_check.run())
- self.assertEquals(
- testcase.TestCase.EX_OK, self.connection_check.is_successful())
- args[0].assert_called_with(mock.ANY)
- args[1].assert_called_with(
- ext_net_name='foo', os_creds=self.os_creds, suite=mock.ANY,
- use_keystone=True)
+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):
@@ -99,6 +35,8 @@ class APICheckTesting(unittest.TestCase):
os_creds=self.os_creds, ext_net_name='foo')
@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('unittest.TextTestRunner.run',
return_value=mock.MagicMock(name='unittest.TextTestResult'))
@@ -115,6 +53,8 @@ class APICheckTesting(unittest.TestCase):
os_creds=self.os_creds, suite=mock.ANY, use_keystone=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('unittest.TextTestRunner.run',
return_value=mock.MagicMock(name='unittest.TextTestResult'))
@@ -132,6 +72,8 @@ class APICheckTesting(unittest.TestCase):
os_creds=self.os_creds, suite=mock.ANY, use_keystone=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('unittest.TextTestRunner.run',
return_value=mock.MagicMock(name='unittest.TextTestResult'))