1515
1616import pytest
1717
18+ from pyignite import Client , AioClient
1819from pyignite .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
2324@pytest .fixture (params = ['with-partition-awareness' , 'without-partition-awareness' ])
@@ -27,22 +28,24 @@ def with_partition_awareness(request):
2728
2829def test_client_with_multiple_bad_servers (with_partition_awareness ):
2930 with pytest .raises (ReconnectError , match = "Can not connect." ):
30- with get_client (partition_aware = with_partition_awareness ) as client :
31- client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )])
31+ client = Client (partition_aware = with_partition_awareness )
32+ with client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )]):
33+ pass
3234
3335
3436@pytest .mark .asyncio
3537async def test_client_with_multiple_bad_servers_async (with_partition_awareness ):
3638 with pytest .raises (ReconnectError , match = "Can not connect." ):
37- async with get_client_async (partition_aware = with_partition_awareness ) as client :
38- await client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )])
39+ client = AioClient (partition_aware = with_partition_awareness )
40+ async with client .connect ([("127.0.0.1" , 10900 ), ("127.0.0.1" , 10901 )]):
41+ pass
3942
4043
4144def test_client_with_failed_server (request , with_partition_awareness ):
4245 srv = start_ignite (idx = 4 )
4346 try :
44- with get_client (partition_aware = with_partition_awareness ) as client :
45- client .connect ([("127.0.0.1" , 10804 )])
47+ client = Client (partition_aware = with_partition_awareness )
48+ with client .connect ([("127.0.0.1" , 10804 )]):
4649 cache = client .get_or_create_cache (request .node .name )
4750 cache .put (1 , 1 )
4851 kill_process_tree (srv .pid )
@@ -62,8 +65,8 @@ def test_client_with_failed_server(request, with_partition_awareness):
6265async def test_client_with_failed_server_async (request , with_partition_awareness ):
6366 srv = start_ignite (idx = 4 )
6467 try :
65- async with get_client_async (partition_aware = with_partition_awareness ) as client :
66- await client .connect ([("127.0.0.1" , 10804 )])
68+ client = AioClient (partition_aware = with_partition_awareness )
69+ async with client .connect ([("127.0.0.1" , 10804 )]):
6770 cache = await client .get_or_create_cache (request .node .name )
6871 await cache .put (1 , 1 )
6972 kill_process_tree (srv .pid )
@@ -82,8 +85,8 @@ async def test_client_with_failed_server_async(request, with_partition_awareness
8285def test_client_with_recovered_server (request , with_partition_awareness ):
8386 srv = start_ignite (idx = 4 )
8487 try :
85- with get_client (partition_aware = with_partition_awareness , timeout = CLIENT_SOCKET_TIMEOUT ) as client :
86- client .connect ([("127.0.0.1" , 10804 )])
88+ client = Client (partition_aware = with_partition_awareness , timeout = CLIENT_SOCKET_TIMEOUT )
89+ with client .connect ([("127.0.0.1" , 10804 )]):
8790 cache = client .get_or_create_cache (request .node .name )
8891 cache .put (1 , 1 )
8992
@@ -108,8 +111,8 @@ def test_client_with_recovered_server(request, with_partition_awareness):
108111async def test_client_with_recovered_server_async (request , with_partition_awareness ):
109112 srv = start_ignite (idx = 4 )
110113 try :
111- async with get_client_async (partition_aware = with_partition_awareness ) as client :
112- await client .connect ([("127.0.0.1" , 10804 )])
114+ client = AioClient (partition_aware = with_partition_awareness )
115+ async with client .connect ([("127.0.0.1" , 10804 )]):
113116 cache = await client .get_or_create_cache (request .node .name )
114117 await cache .put (1 , 1 )
115118
0 commit comments