mirror of
https://github.com/vale981/jobmanager
synced 2025-03-06 02:11:39 -05:00
some changed to make the test run with python2.7, and some more tests, still not done jet
This commit is contained in:
parent
643197eef7
commit
f54eb0c447
4 changed files with 58 additions and 35 deletions
|
@ -126,7 +126,7 @@ def test_distributed_mathieu():
|
||||||
for q in q_list:
|
for q in q_list:
|
||||||
arg = jm.hashDict()
|
arg = jm.hashDict()
|
||||||
a = mathieu_a(m, q)
|
a = mathieu_a(m, q)
|
||||||
arg['arg'] = (a, q)
|
arg['args'] = (a, q)
|
||||||
arg['x0'] = mathieu_cem(m, q, 0) # gives value and its derivative
|
arg['x0'] = mathieu_cem(m, q, 0) # gives value and its derivative
|
||||||
jm_int.put_arg(a=arg)
|
jm_int.put_arg(a=arg)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ def test_distributed_mathieu():
|
||||||
arg = f[0]
|
arg = f[0]
|
||||||
res = f[1]
|
res = f[1]
|
||||||
|
|
||||||
a, q = arg['arg']
|
a, q = arg['args']
|
||||||
t, x_t = f[1]
|
t, x_t = f[1]
|
||||||
|
|
||||||
assert np.max(np.abs(t_ref - t)) < 1e-15
|
assert np.max(np.abs(t_ref - t)) < 1e-15
|
||||||
|
@ -185,7 +185,7 @@ class MYO(object):
|
||||||
from collections import namedtuple as nt
|
from collections import namedtuple as nt
|
||||||
N1 = nt('N1', ['x', 'y'])
|
N1 = nt('N1', ['x', 'y'])
|
||||||
|
|
||||||
def test_tuple_equal():
|
def _test_tuple_equal():
|
||||||
|
|
||||||
|
|
||||||
myo1 = MYO()
|
myo1 = MYO()
|
||||||
|
@ -220,7 +220,7 @@ def test_tuple_equal():
|
||||||
|
|
||||||
import sqlitedict
|
import sqlitedict
|
||||||
|
|
||||||
d = sqlitedict.SqliteDict(filename='tmp.db', tablename='test', autocommit=True)
|
d = sqlitedict.SqliteDict(filename='./tmp.db', tablename='test', autocommit=True)
|
||||||
|
|
||||||
hash1 = hash(na)
|
hash1 = hash(na)
|
||||||
|
|
||||||
|
@ -246,7 +246,9 @@ def test_tuple_equal():
|
||||||
|
|
||||||
print(d[key_bytes])
|
print(d[key_bytes])
|
||||||
|
|
||||||
def test_namedtuple_as_dict():
|
d.terminate()
|
||||||
|
|
||||||
|
def _test_namedtuple_as_dict():
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
@ -268,8 +270,8 @@ def test_namedtuple_as_dict():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# test_mathiue_dgl(plot=False)
|
test_mathiue_dgl(plot=False)
|
||||||
# test_distributed_mathieu()
|
test_distributed_mathieu()
|
||||||
# test_tuple_equal()
|
_test_tuple_equal()
|
||||||
test_namedtuple_as_dict()
|
_test_namedtuple_as_dict()
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,8 @@ def start_client(verbose=1):
|
||||||
nproc = 0,
|
nproc = 0,
|
||||||
verbose = verbose)
|
verbose = verbose)
|
||||||
jm_client.start()
|
jm_client.start()
|
||||||
|
if verbose > 1:
|
||||||
|
print("jm_client returned")
|
||||||
|
|
||||||
def test_jobmanager_basic():
|
def test_jobmanager_basic():
|
||||||
"""
|
"""
|
||||||
|
@ -247,18 +249,29 @@ def test_shutdown_server_while_client_running():
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
p_client = mp.Process(target=start_client)
|
p_client = mp.Process(target=start_client, args=(2,))
|
||||||
p_client.start()
|
p_client.start()
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
os.kill(p_server.pid, signal.SIGTERM)
|
os.kill(p_server.pid, signal.SIGTERM)
|
||||||
|
|
||||||
p_server.join(15)
|
p_server.join(200)
|
||||||
p_client.join(15)
|
p_client.join(200)
|
||||||
|
|
||||||
|
try:
|
||||||
assert not p_server.is_alive()
|
assert not p_server.is_alive()
|
||||||
|
except:
|
||||||
|
p_server.terminate()
|
||||||
|
raise
|
||||||
|
|
||||||
|
try:
|
||||||
assert not p_client.is_alive()
|
assert not p_client.is_alive()
|
||||||
|
except:
|
||||||
|
p_client.terminate()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fname = 'jobmanager.dump'
|
fname = 'jobmanager.dump'
|
||||||
with open(fname, 'rb') as f:
|
with open(fname, 'rb') as f:
|
||||||
|
@ -691,7 +704,7 @@ if __name__ == "__main__":
|
||||||
#
|
#
|
||||||
# test_jobmanager_basic,
|
# test_jobmanager_basic,
|
||||||
# test_jobmanager_server_signals,
|
# test_jobmanager_server_signals,
|
||||||
# test_shutdown_server_while_client_running,
|
test_shutdown_server_while_client_running,
|
||||||
# test_shutdown_client,
|
# test_shutdown_client,
|
||||||
# test_check_fail,
|
# test_check_fail,
|
||||||
# test_jobmanager_read_old_stat,
|
# test_jobmanager_read_old_stat,
|
||||||
|
@ -701,7 +714,7 @@ if __name__ == "__main__":
|
||||||
# test_jobmanager_local,
|
# test_jobmanager_local,
|
||||||
# test_start_server_on_used_port,
|
# test_start_server_on_used_port,
|
||||||
# test_shared_const_arg,
|
# test_shared_const_arg,
|
||||||
test_digest_rejected,
|
# test_digest_rejected,
|
||||||
|
|
||||||
lambda : print("END")
|
lambda : print("END")
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,6 +15,14 @@ from jobmanager.persistentData import PersistentDataStructure as PDS
|
||||||
|
|
||||||
VERBOSE = 1
|
VERBOSE = 1
|
||||||
|
|
||||||
|
if sys.version_info[0] == 2:
|
||||||
|
# fixes keyword problems with python 2.x
|
||||||
|
old_open = open
|
||||||
|
def new_open(file, mode):
|
||||||
|
old_open(name = file, mode = mode)
|
||||||
|
open = new_open
|
||||||
|
|
||||||
|
|
||||||
def test_pd():
|
def test_pd():
|
||||||
with PDS(name='test_data', verbose=VERBOSE) as data:
|
with PDS(name='test_data', verbose=VERBOSE) as data:
|
||||||
key = 'a'
|
key = 'a'
|
||||||
|
|
|
@ -463,23 +463,23 @@ def test_progress_bar_slow_change():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
func = [
|
func = [
|
||||||
# test_loop_basic,
|
test_loop_basic,
|
||||||
# test_loop_signals,
|
test_loop_signals,
|
||||||
# test_loop_normal_stop,
|
test_loop_normal_stop,
|
||||||
# test_loop_need_sigterm_to_stop,
|
test_loop_need_sigterm_to_stop,
|
||||||
# test_loop_need_sigkill_to_stop,
|
test_loop_need_sigkill_to_stop,
|
||||||
# test_why_with_statement,
|
test_why_with_statement,
|
||||||
# test_progress_bar,
|
test_progress_bar,
|
||||||
# test_progress_bar_with_statement,
|
test_progress_bar_with_statement,
|
||||||
# test_progress_bar_multi,
|
test_progress_bar_multi,
|
||||||
# test_status_counter,
|
test_status_counter,
|
||||||
# test_status_counter_multi,
|
test_status_counter_multi,
|
||||||
# test_intermediate_prints_while_running_progess_bar,
|
test_intermediate_prints_while_running_progess_bar,
|
||||||
# test_intermediate_prints_while_running_progess_bar_multi,
|
test_intermediate_prints_while_running_progess_bar_multi,
|
||||||
# test_progress_bar_counter,
|
test_progress_bar_counter,
|
||||||
# test_progress_bar_counter_non_max,
|
test_progress_bar_counter_non_max,
|
||||||
# test_progress_bar_counter_hide_bar,
|
test_progress_bar_counter_hide_bar,
|
||||||
# test_progress_bar_slow_change,
|
test_progress_bar_slow_change,
|
||||||
lambda: print("END")
|
lambda: print("END")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue