mirror of
https://github.com/vale981/jobmanager
synced 2025-03-05 09:51:38 -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:
|
||||
arg = jm.hashDict()
|
||||
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
|
||||
jm_int.put_arg(a=arg)
|
||||
|
||||
|
@ -146,7 +146,7 @@ def test_distributed_mathieu():
|
|||
arg = f[0]
|
||||
res = f[1]
|
||||
|
||||
a, q = arg['arg']
|
||||
a, q = arg['args']
|
||||
t, x_t = f[1]
|
||||
|
||||
assert np.max(np.abs(t_ref - t)) < 1e-15
|
||||
|
@ -185,7 +185,7 @@ class MYO(object):
|
|||
from collections import namedtuple as nt
|
||||
N1 = nt('N1', ['x', 'y'])
|
||||
|
||||
def test_tuple_equal():
|
||||
def _test_tuple_equal():
|
||||
|
||||
|
||||
myo1 = MYO()
|
||||
|
@ -220,7 +220,7 @@ def test_tuple_equal():
|
|||
|
||||
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)
|
||||
|
||||
|
@ -246,7 +246,9 @@ def test_tuple_equal():
|
|||
|
||||
print(d[key_bytes])
|
||||
|
||||
def test_namedtuple_as_dict():
|
||||
d.terminate()
|
||||
|
||||
def _test_namedtuple_as_dict():
|
||||
from collections import namedtuple
|
||||
import copy
|
||||
|
||||
|
@ -268,8 +270,8 @@ def test_namedtuple_as_dict():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# test_mathiue_dgl(plot=False)
|
||||
# test_distributed_mathieu()
|
||||
# test_tuple_equal()
|
||||
test_namedtuple_as_dict()
|
||||
test_mathiue_dgl(plot=False)
|
||||
test_distributed_mathieu()
|
||||
_test_tuple_equal()
|
||||
_test_namedtuple_as_dict()
|
||||
|
||||
|
|
|
@ -139,7 +139,9 @@ def start_client(verbose=1):
|
|||
port = PORT,
|
||||
nproc = 0,
|
||||
verbose = verbose)
|
||||
jm_client.start()
|
||||
jm_client.start()
|
||||
if verbose > 1:
|
||||
print("jm_client returned")
|
||||
|
||||
def test_jobmanager_basic():
|
||||
"""
|
||||
|
@ -247,18 +249,29 @@ def test_shutdown_server_while_client_running():
|
|||
|
||||
time.sleep(1)
|
||||
|
||||
p_client = mp.Process(target=start_client)
|
||||
p_client = mp.Process(target=start_client, args=(2,))
|
||||
p_client.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
os.kill(p_server.pid, signal.SIGTERM)
|
||||
|
||||
p_server.join(15)
|
||||
p_client.join(15)
|
||||
p_server.join(200)
|
||||
p_client.join(200)
|
||||
|
||||
try:
|
||||
assert not p_server.is_alive()
|
||||
except:
|
||||
p_server.terminate()
|
||||
raise
|
||||
|
||||
try:
|
||||
assert not p_client.is_alive()
|
||||
except:
|
||||
p_client.terminate()
|
||||
raise
|
||||
|
||||
|
||||
assert not p_server.is_alive()
|
||||
assert not p_client.is_alive()
|
||||
|
||||
fname = 'jobmanager.dump'
|
||||
with open(fname, 'rb') as f:
|
||||
|
@ -688,10 +701,10 @@ if __name__ == "__main__":
|
|||
# test_Signal_to_SIG_IGN,
|
||||
# test_Signal_to_sys_exit,
|
||||
# test_Signal_to_terminate_process_list,
|
||||
#
|
||||
#
|
||||
# test_jobmanager_basic,
|
||||
# test_jobmanager_server_signals,
|
||||
# test_shutdown_server_while_client_running,
|
||||
test_shutdown_server_while_client_running,
|
||||
# test_shutdown_client,
|
||||
# test_check_fail,
|
||||
# test_jobmanager_read_old_stat,
|
||||
|
@ -701,7 +714,7 @@ if __name__ == "__main__":
|
|||
# test_jobmanager_local,
|
||||
# test_start_server_on_used_port,
|
||||
# test_shared_const_arg,
|
||||
test_digest_rejected,
|
||||
# test_digest_rejected,
|
||||
|
||||
lambda : print("END")
|
||||
]
|
||||
|
|
|
@ -15,6 +15,14 @@ from jobmanager.persistentData import PersistentDataStructure as PDS
|
|||
|
||||
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():
|
||||
with PDS(name='test_data', verbose=VERBOSE) as data:
|
||||
key = 'a'
|
||||
|
|
|
@ -463,23 +463,23 @@ def test_progress_bar_slow_change():
|
|||
|
||||
if __name__ == "__main__":
|
||||
func = [
|
||||
# test_loop_basic,
|
||||
# test_loop_signals,
|
||||
# test_loop_normal_stop,
|
||||
# test_loop_need_sigterm_to_stop,
|
||||
# test_loop_need_sigkill_to_stop,
|
||||
# test_why_with_statement,
|
||||
# test_progress_bar,
|
||||
# test_progress_bar_with_statement,
|
||||
# test_progress_bar_multi,
|
||||
# test_status_counter,
|
||||
# test_status_counter_multi,
|
||||
# test_intermediate_prints_while_running_progess_bar,
|
||||
# test_intermediate_prints_while_running_progess_bar_multi,
|
||||
# test_progress_bar_counter,
|
||||
# test_progress_bar_counter_non_max,
|
||||
# test_progress_bar_counter_hide_bar,
|
||||
# test_progress_bar_slow_change,
|
||||
test_loop_basic,
|
||||
test_loop_signals,
|
||||
test_loop_normal_stop,
|
||||
test_loop_need_sigterm_to_stop,
|
||||
test_loop_need_sigkill_to_stop,
|
||||
test_why_with_statement,
|
||||
test_progress_bar,
|
||||
test_progress_bar_with_statement,
|
||||
test_progress_bar_multi,
|
||||
test_status_counter,
|
||||
test_status_counter_multi,
|
||||
test_intermediate_prints_while_running_progess_bar,
|
||||
test_intermediate_prints_while_running_progess_bar_multi,
|
||||
test_progress_bar_counter,
|
||||
test_progress_bar_counter_non_max,
|
||||
test_progress_bar_counter_hide_bar,
|
||||
test_progress_bar_slow_change,
|
||||
lambda: print("END")
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue