aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack/api/connection_check.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-06-25 06:07:26 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-06-25 07:46:18 +0200
commit0503756fa4584e82081fb44b9133d2564d77105b (patch)
treef7986d1271c5a94038afa0783ed48ea5f32797ee /functest/opnfv_tests/openstack/api/connection_check.py
parente905fbe2253bf43da2661c3a9e67429e0292993a (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/api/connection_check.py')
-rw-r--r--functest/opnfv_tests/openstack/api/connection_check.py54
1 files changed, 54 insertions, 0 deletions
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