From 9ba0627dcd0ac73589bd4d7427e126a40ea1edd3 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 28 May 2015 22:45:09 +0200 Subject: [PATCH] still try to fix the non passing test_exception in jobmanager tests (see #24) --- .travis.yml | 1 + jobmanager/jobmanager.py | 1 + tests/test_jobmanager.py | 62 ++++++++++++++++++++++++++++------------ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 570a985..81b35ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ notifications: email: false python: - "3.4" +- "2.7" before_install: - sudo apt-get update -qq - sudo apt-get install -qq libatlas-dev libatlas-base-dev liblapack-dev gfortran diff --git a/jobmanager/jobmanager.py b/jobmanager/jobmanager.py index e2adccc..c3fd2b9 100644 --- a/jobmanager/jobmanager.py +++ b/jobmanager/jobmanager.py @@ -1438,6 +1438,7 @@ def handler_broken_pipe_error(e, verbose): def handler_connection_refused(e, identifier, dest, verbose): if verbose > 1: print("this usually means that no matching Manager object was instanciated at destination side!") + print("either there is no Manager running at all, or it is listening to another port.") raise JMConnectionRefusedError(e) def handler_connection_reset(identifier, dest, c, reconnect_wait, reconnect_tries, verbose): diff --git a/tests/test_jobmanager.py b/tests/test_jobmanager.py index bd77964..cbb1e61 100644 --- a/tests/test_jobmanager.py +++ b/tests/test_jobmanager.py @@ -748,7 +748,10 @@ def test_exception(): str(port), authkey] + print("#"*40) + print("start an autoproxy server with command") print(cmd) + print("#"*40) return subprocess.Popen(cmd, env=python_env, stdout=outfile, stderr=subprocess.STDOUT) def autoproxy_connect(server, port, authkey): @@ -757,7 +760,7 @@ def test_exception(): m = MyManager_Client(address = (server, port), authkey = bytearray(authkey, encoding='utf8')) - jobmanager.call_connect(m.connect, dest = jobmanager.address_authkey_from_manager(m), verbose=1) + jobmanager.call_connect(m.connect, dest = jobmanager.address_authkey_from_manager(m), verbose=2) return m @@ -771,45 +774,68 @@ def test_exception(): print("autoproxy server running with PID {}".format(p_server.pid)) time.sleep(1) - print("running tests ...") + print("running tests with python {} ...".format(sys.version_info[0])) print() try: - try: - autoproxy_connect(server=SERVER, port=port, authkey=authkey) - except jobmanager.RemoteValueError: - if (sys.version_info[0] == 3) and (p_version_server == 2): - print("that is ok") # the occurrence of this Exception is normal - pass - else: - raise # reraise exception - except ValueError: - if (sys.version_info[0] == 2) and (p_version_server == 3): - print("that is ok") # the occurrence of this Exception is normal - pass - else: - raise # reraise exception + if sys.version_info[0] == 3: + print("we are using python 3 ... try to connect ...") + try: + autoproxy_connect(server=SERVER, port=port, authkey=authkey) + except jobmanager.RemoteValueError as e: + if p_version_server == 2: + print("that is ok, because the server is running on python2") # the occurrence of this Exception is normal + print() + pass + else: + print("RemoteValueError error") + raise # reraise exception + except Exception as e: + print("unexpected error {}".format(e)) + raise + + elif sys.version_info[0] == 2: + print("we are using python 2 ... try to connect ...") + try: + autoproxy_connect(server=SERVER, port=port, authkey=authkey) + except ValueError as e: + if p_version_server == 3: + print("that is ok, because the server is running on python3") # the occurrence of this Exception is normal + print() + pass + else: + print("JMConnectionRefusedError error") + raise # reraise exception + except Exception as e: + print("unexpected error {}".format(e)) + raise # all the following only for the same python versions if (sys.version_info[0] != p_version_server): continue try: + print("try to connect to server, use wrong port") autoproxy_connect(server=SERVER, port=port+1, authkey=authkey) except jobmanager.JMConnectionRefusedError: print("that is ok") + print() except: raise try: + print("try to connect to server, use wrong authkey") autoproxy_connect(server=SERVER, port=port, authkey=authkey+'_') except jobmanager.AuthenticationError: print("that is ok") + print() except: raise m = autoproxy_connect(server=SERVER, port=port, authkey=authkey) + print("try pass some data forth and back ...") + q = m.get_q() q_get = jobmanager.proxy_operation_decorator_python3(q, 'get') @@ -819,9 +845,7 @@ def test_exception(): q_put(s1) s2 = q_get() - assert s1 == s2 - - + assert s1 == s2 finally: