mirror of
https://github.com/vale981/jobmanager
synced 2025-03-05 18:01:38 -05:00
still try to fix the non passing test_exception in jobmanager tests (see #24)
This commit is contained in:
parent
cbe5fa0ae0
commit
9ba0627dcd
3 changed files with 45 additions and 19 deletions
|
@ -3,6 +3,7 @@ notifications:
|
||||||
email: false
|
email: false
|
||||||
python:
|
python:
|
||||||
- "3.4"
|
- "3.4"
|
||||||
|
- "2.7"
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq libatlas-dev libatlas-base-dev liblapack-dev gfortran
|
- sudo apt-get install -qq libatlas-dev libatlas-base-dev liblapack-dev gfortran
|
||||||
|
|
|
@ -1438,6 +1438,7 @@ def handler_broken_pipe_error(e, verbose):
|
||||||
def handler_connection_refused(e, identifier, dest, verbose):
|
def handler_connection_refused(e, identifier, dest, verbose):
|
||||||
if verbose > 1:
|
if verbose > 1:
|
||||||
print("this usually means that no matching Manager object was instanciated at destination side!")
|
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)
|
raise JMConnectionRefusedError(e)
|
||||||
|
|
||||||
def handler_connection_reset(identifier, dest, c, reconnect_wait, reconnect_tries, verbose):
|
def handler_connection_reset(identifier, dest, c, reconnect_wait, reconnect_tries, verbose):
|
||||||
|
|
|
@ -748,7 +748,10 @@ def test_exception():
|
||||||
str(port),
|
str(port),
|
||||||
authkey]
|
authkey]
|
||||||
|
|
||||||
|
print("#"*40)
|
||||||
|
print("start an autoproxy server with command")
|
||||||
print(cmd)
|
print(cmd)
|
||||||
|
print("#"*40)
|
||||||
return subprocess.Popen(cmd, env=python_env, stdout=outfile, stderr=subprocess.STDOUT)
|
return subprocess.Popen(cmd, env=python_env, stdout=outfile, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
def autoproxy_connect(server, port, authkey):
|
def autoproxy_connect(server, port, authkey):
|
||||||
|
@ -757,7 +760,7 @@ def test_exception():
|
||||||
m = MyManager_Client(address = (server, port),
|
m = MyManager_Client(address = (server, port),
|
||||||
authkey = bytearray(authkey, encoding='utf8'))
|
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
|
return m
|
||||||
|
|
||||||
|
@ -771,45 +774,68 @@ def test_exception():
|
||||||
print("autoproxy server running with PID {}".format(p_server.pid))
|
print("autoproxy server running with PID {}".format(p_server.pid))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
print("running tests ...")
|
print("running tests with python {} ...".format(sys.version_info[0]))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
if sys.version_info[0] == 3:
|
||||||
autoproxy_connect(server=SERVER, port=port, authkey=authkey)
|
print("we are using python 3 ... try to connect ...")
|
||||||
except jobmanager.RemoteValueError:
|
try:
|
||||||
if (sys.version_info[0] == 3) and (p_version_server == 2):
|
autoproxy_connect(server=SERVER, port=port, authkey=authkey)
|
||||||
print("that is ok") # the occurrence of this Exception is normal
|
except jobmanager.RemoteValueError as e:
|
||||||
pass
|
if p_version_server == 2:
|
||||||
else:
|
print("that is ok, because the server is running on python2") # the occurrence of this Exception is normal
|
||||||
raise # reraise exception
|
print()
|
||||||
except ValueError:
|
pass
|
||||||
if (sys.version_info[0] == 2) and (p_version_server == 3):
|
else:
|
||||||
print("that is ok") # the occurrence of this Exception is normal
|
print("RemoteValueError error")
|
||||||
pass
|
raise # reraise exception
|
||||||
else:
|
except Exception as e:
|
||||||
raise # reraise exception
|
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
|
# all the following only for the same python versions
|
||||||
if (sys.version_info[0] != p_version_server):
|
if (sys.version_info[0] != p_version_server):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
print("try to connect to server, use wrong port")
|
||||||
autoproxy_connect(server=SERVER, port=port+1, authkey=authkey)
|
autoproxy_connect(server=SERVER, port=port+1, authkey=authkey)
|
||||||
except jobmanager.JMConnectionRefusedError:
|
except jobmanager.JMConnectionRefusedError:
|
||||||
print("that is ok")
|
print("that is ok")
|
||||||
|
print()
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
print("try to connect to server, use wrong authkey")
|
||||||
autoproxy_connect(server=SERVER, port=port, authkey=authkey+'_')
|
autoproxy_connect(server=SERVER, port=port, authkey=authkey+'_')
|
||||||
except jobmanager.AuthenticationError:
|
except jobmanager.AuthenticationError:
|
||||||
print("that is ok")
|
print("that is ok")
|
||||||
|
print()
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
m = autoproxy_connect(server=SERVER, port=port, authkey=authkey)
|
m = autoproxy_connect(server=SERVER, port=port, authkey=authkey)
|
||||||
|
|
||||||
|
print("try pass some data forth and back ...")
|
||||||
|
|
||||||
q = m.get_q()
|
q = m.get_q()
|
||||||
|
|
||||||
q_get = jobmanager.proxy_operation_decorator_python3(q, 'get')
|
q_get = jobmanager.proxy_operation_decorator_python3(q, 'get')
|
||||||
|
@ -819,9 +845,7 @@ def test_exception():
|
||||||
q_put(s1)
|
q_put(s1)
|
||||||
s2 = q_get()
|
s2 = q_get()
|
||||||
|
|
||||||
assert s1 == s2
|
assert s1 == s2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Reference in a new issue