1515#
1616import pytest
1717
18+ from pygridgain import Client , AioClient
1819from pygridgain .exceptions import ReconnectError , connection_errors
1920from tests .affinity .conftest import CLIENT_SOCKET_TIMEOUT
20- from tests .util import start_ignite , kill_process_tree , get_client , get_client_async
21+ from tests .util import start_ignite , kill_process_tree
2122
2223@pytest .fixture (params = ['with-partition-awareness' , 'without-partition-awareness' ])
2324def with_partition_awareness (request ):
@@ -26,22 +27,24 @@ def with_partition_awareness(request):
2627
2728def test_client_with_multiple_bad_servers (with_partition_awareness ):
2829 with pytest .raises (ReconnectError , match = "Can not connect." ):
29- with get_client (partition_aware = with_partition_awareness ) as client :
30- client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )])
30+ client = Client (partition_aware = with_partition_awareness )
31+ with client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )]):
32+ pass
3133
3234
3335@pytest .mark .asyncio
3436async def test_client_with_multiple_bad_servers_async (with_partition_awareness ):
3537 with pytest .raises (ReconnectError , match = "Can not connect." ):
36- async with get_client_async (partition_aware = with_partition_awareness ) as client :
37- await client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )])
38+ client = AioClient (partition_aware = with_partition_awareness )
39+ async with client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )]):
40+ pass
3841
3942
4043def test_client_with_failed_server (request , with_partition_awareness ):
4144 srv = start_ignite (idx = 4 )
4245 try :
43- with get_client (partition_aware = with_partition_awareness ) as client :
44- client .connect ([("127.0.0.1" , 10804 )])
46+ client = Client (partition_aware = with_partition_awareness )
47+ with client .connect ([("127.0.0.1" , 10804 )]):
4548 cache = client .get_or_create_cache (request .node .name )
4649 cache .put (1 , 1 )
4750 kill_process_tree (srv .pid )
@@ -61,8 +64,8 @@ def test_client_with_failed_server(request, with_partition_awareness):
6164async def test_client_with_failed_server_async (request , with_partition_awareness ):
6265 srv = start_ignite (idx = 4 )
6366 try :
64- async with get_client_async (partition_aware = with_partition_awareness ) as client :
65- await client .connect ([("127.0.0.1" , 10804 )])
67+ client = AioClient (partition_aware = with_partition_awareness )
68+ async with client .connect ([("127.0.0.1" , 10804 )]):
6669 cache = await client .get_or_create_cache (request .node .name )
6770 await cache .put (1 , 1 )
6871 kill_process_tree (srv .pid )
@@ -81,8 +84,8 @@ async def test_client_with_failed_server_async(request, with_partition_awareness
8184def test_client_with_recovered_server (request , with_partition_awareness ):
8285 srv = start_ignite (idx = 4 )
8386 try :
84- with get_client (partition_aware = with_partition_awareness , timeout = CLIENT_SOCKET_TIMEOUT ) as client :
85- client .connect ([("127.0.0.1" , 10804 )])
87+ client = Client (partition_aware = with_partition_awareness , timeout = CLIENT_SOCKET_TIMEOUT )
88+ with client .connect ([("127.0.0.1" , 10804 )]):
8689 cache = client .get_or_create_cache (request .node .name )
8790 cache .put (1 , 1 )
8891
@@ -107,8 +110,8 @@ def test_client_with_recovered_server(request, with_partition_awareness):
107110async def test_client_with_recovered_server_async (request , with_partition_awareness ):
108111 srv = start_ignite (idx = 4 )
109112 try :
110- async with get_client_async (partition_aware = with_partition_awareness ) as client :
111- await client .connect ([("127.0.0.1" , 10804 )])
113+ client = AioClient (partition_aware = with_partition_awareness )
114+ async with client .connect ([("127.0.0.1" , 10804 )]):
112115 cache = await client .get_or_create_cache (request .node .name )
113116 await cache .put (1 , 1 )
114117
0 commit comments