From 0b3980c31d063d80dcc65afbc00c3a5ff1b5ec22 Mon Sep 17 00:00:00 2001 From: Qing Wang Date: Fri, 7 Jul 2023 16:19:51 +0800 Subject: [PATCH] Fix test_internal_kv CI --- tests/test_internal_kv.py | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/test_internal_kv.py b/tests/test_internal_kv.py index b36a773..c57dec4 100644 --- a/tests/test_internal_kv.py +++ b/tests/test_internal_kv.py @@ -6,28 +6,29 @@ import fed._private.compatible_utils as compatible_utils -def test_kv_init(): - def run(party): - compatible_utils.init_ray("local") - cluster = { - 'alice': {'address': '127.0.0.1:11010', 'listen_addr': '0.0.0.0:11010'}, - 'bob': {'address': '127.0.0.1:11011', 'listen_addr': '0.0.0.0:11011'}, - } - assert compatible_utils.kv is None - fed.init(cluster=cluster, party=party) - assert compatible_utils.kv - assert not compatible_utils.kv.put(b"test_key", b"test_val") - assert compatible_utils.kv.get(b"test_key") == b"test_val" - - time.sleep(5) - fed.shutdown() - ray.shutdown() - - assert compatible_utils.kv is None - with pytest.raises(ValueError): - # Make sure the kv actor is non-exist no matter whether it's in client mode - ray.get_actor("_INTERNAL_KV_ACTOR") +def run(party): + compatible_utils.init_ray("local") + cluster = { + 'alice': {'address': '127.0.0.1:11010', 'listen_addr': '0.0.0.0:11010'}, + 'bob': {'address': '127.0.0.1:11011', 'listen_addr': '0.0.0.0:11011'}, + } + assert compatible_utils.kv is None + fed.init(cluster=cluster, party=party) + assert compatible_utils.kv + assert not compatible_utils.kv.put(b"test_key", b"test_val") + assert compatible_utils.kv.get(b"test_key") == b"test_val" + + time.sleep(5) + fed.shutdown() + + assert compatible_utils.kv is None + with pytest.raises(ValueError): + # Make sure the kv actor is non-exist no matter whether it's in client mode + ray.get_actor("_INTERNAL_KV_ACTOR") + ray.shutdown() + +def test_kv_init(): p_alice = multiprocessing.Process(target=run, args=('alice',)) p_bob = multiprocessing.Process(target=run, args=('bob',)) p_alice.start()