From 81aa529403bedffb26f34994e3ee34a4516cee00 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Wed, 20 Dec 2017 07:51:17 +0000 Subject: Get auth token when checking deployment JIRA: FUNCTEST-900 Change-Id: Ie313d273a357a35b176b3918de108d85164776fa Signed-off-by: Linda Wang --- functest/ci/check_deployment.py | 15 ++++++++++++++- functest/tests/unit/ci/test_check_deployment.py | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/functest/ci/check_deployment.py b/functest/ci/check_deployment.py index ffea6beb4..9453c6d49 100644 --- a/functest/ci/check_deployment.py +++ b/functest/ci/check_deployment.py @@ -52,6 +52,16 @@ def verify_connectivity(endpoint): 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.""" @@ -69,12 +79,15 @@ class CheckDeployment(object): format(self.rc_file)) def check_auth_endpoint(self): - """ Verifies connectivity to the OS_AUTH_URL given in the RC file """ + """ 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 """ diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py index fa2f21306..fc6368e5a 100644 --- a/functest/tests/unit/ci/test_check_deployment.py +++ b/functest/tests/unit/ci/test_check_deployment.py @@ -63,9 +63,12 @@ class CheckDeploymentTesting(unittest.TestCase): def test_check_auth_endpoint(self): with mock.patch('functest.ci.check_deployment.verify_connectivity', - return_value=True) as m: + return_value=True) as m,\ + mock.patch('functest.ci.check_deployment.get_auth_token', + return_value='gAAAAABaOhXGS') as mock_token: self.deployment.check_auth_endpoint() self.assertTrue(m.called) + self.assertTrue(mock_token.called) def test_check_auth_endpoint_not_reachable(self): with mock.patch('functest.ci.check_deployment.verify_connectivity', -- cgit 1.2.3-korg