From ea2efb8779a13c7863cda3dde92faac74504b262 Mon Sep 17 00:00:00 2001 From: Eli Qiao Date: Tue, 1 Dec 2015 17:35:37 +0800 Subject: [PATCH] Wait more time after swarm bay creation before doing functional testing This patch increases waiting loop time after swarm bay creation finished. Raise a meaningful exception to indicate ca initial failed. Closes-Bug: #1521395 Change-Id: I58c94affe3dc07aa43dc8d7a120b0b62e0cdb47a --- .../swarm/test_swarm_python_client.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/magnum/tests/functional/swarm/test_swarm_python_client.py b/magnum/tests/functional/swarm/test_swarm_python_client.py index 864814d4d7..8a3f947fa1 100644 --- a/magnum/tests/functional/swarm/test_swarm_python_client.py +++ b/magnum/tests/functional/swarm/test_swarm_python_client.py @@ -97,18 +97,29 @@ extendedKeyUsage = clientAuth # This is required, without this any api call will fail as # 'ConnectionError: [Errno 111] Connection refused'. - for i in range(30): + bay_is_ready = False + + for i in range(150): try: cls.docker_client.containers() - except req_exceptions.ConnectionError: - time.sleep(2) - else: # Note(eliqiao): Right after the connection is ready, wait # for a while (at least 5s) to aovid this error: # docker.errors.APIError: 500 Server Error: Internal # Server Error ("No healthy node available in the cluster") time.sleep(10) + bay_is_ready = True break + except req_exceptions.ConnectionError: + time.sleep(2) + # In such case, no need to test below cases on gate, raise a meanful + # exception message to indicate ca setup failed after bay creation, + # Better to do a `recheck` + if not bay_is_ready: + msg = ("If you see this error in the functional test, it means " + "the docker service took too long to come up. This may not " + "be an actual error, so an option is to rerun the " + "functional test.") + raise Exception(msg) def _create_container(self, **kwargs): name = kwargs.get('name', 'test_container')