diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-06-25 06:07:26 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-06-25 07:46:18 +0200 |
commit | 0503756fa4584e82081fb44b9133d2564d77105b (patch) | |
tree | f7986d1271c5a94038afa0783ed48ea5f32797ee /functest/opnfv_tests/openstack | |
parent | e905fbe2253bf43da2661c3a9e67429e0292993a (diff) |
Implement connection_check via shade too
SNAPS connection_check tests are merged into api_check.
It would ease debugging deployment as well [1]
[1] https://build.opnfv.org/ci/view/functest/job/functest-apex-baremetal-daily-master/127/console
Change-Id: I30254a46c3dc6874881d687e36903c6b7878d63d
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/opnfv_tests/openstack')
4 files changed, 59 insertions, 44 deletions
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() |