Ejemplo n.º 1
0
async def test_client_with_recovered_server_async(request, with_partition_awareness):
    srv = start_ignite(idx=4)
    try:
        client = AioClient(partition_aware=with_partition_awareness)
        async with client.connect([("127.0.0.1", 10804)]):
            cache = await client.get_or_create_cache(request.node.name)
            await cache.put(1, 1)

            # Kill and restart server
            kill_process_tree(srv.pid)
            srv = start_ignite(idx=4)

            # First request may fail.
            try:
                await cache.put(1, 2)
            except connection_errors:
                pass

            # Retry succeeds
            await cache.put(1, 2)
            assert await cache.get(1) == 2
    finally:
        kill_process_tree(srv.pid)
Ejemplo n.º 2
0
def test_client_with_recovered_server(request, with_partition_awareness):
    srv = start_ignite(idx=4)
    try:
        client = Client(partition_aware=with_partition_awareness, timeout=CLIENT_SOCKET_TIMEOUT)
        with client.connect([("127.0.0.1", 10804)]):
            cache = client.get_or_create_cache(request.node.name)
            cache.put(1, 1)

            # Kill and restart server
            kill_process_tree(srv.pid)
            srv = start_ignite(idx=4)

            # First request may fail.
            try:
                cache.put(1, 2)
            except connection_errors:
                pass

            # Retry succeeds
            cache.put(1, 2)
            assert cache.get(1) == 2
    finally:
        kill_process_tree(srv.pid)
Ejemplo n.º 3
0
    async def inner_async():
        await wait_for_affinity_distribution_async(cache, key, 3)
        await cache.put(key, key)
        await cache.put(key, key)
        assert requests.pop() == 3

        srv = start_ignite(idx=4)
        try:
            # Wait for rebalance and partition map exchange
            await wait_for_affinity_distribution_async(cache, key, 4)

            # Response is correct and comes from the new node
            res = await cache.get_and_remove(key)
            assert res == key
            assert requests.pop() == 4
        finally:
            kill_process_tree(srv.pid)
Ejemplo n.º 4
0
async def test_client_with_failed_server_async(request, with_partition_awareness):
    srv = start_ignite(idx=4)
    try:
        client = AioClient(partition_aware=with_partition_awareness)
        async with client.connect([("127.0.0.1", 10804)]):
            cache = await client.get_or_create_cache(request.node.name)
            await cache.put(1, 1)
            kill_process_tree(srv.pid)

            if with_partition_awareness:
                ex_class = (ReconnectError, ConnectionResetError)
            else:
                ex_class = ConnectionResetError

            with pytest.raises(ex_class):
                await cache.get(1)
    finally:
        kill_process_tree(srv.pid)
Ejemplo n.º 5
0
def test_all_registered_cache_updated_on_new_server(client_routed):
    with create_caches(client_routed) as caches:
        key = 12
        test_cache = random.choice(caches)
        wait_for_affinity_distribution(test_cache, key, 3)
        test_cache.put(key, key)
        assert requests.pop() == 3

        srv = start_ignite(idx=4)
        try:
            # Wait for rebalance and partition map exchange
            wait_for_affinity_distribution(test_cache, key, 4)

            for cache in caches:
                cache.get(key)
                assert requests.pop() == 4
        finally:
            kill_process_tree(srv.pid)
Ejemplo n.º 6
0
async def test_replicated_cache_operation_not_routed_to_failed_node_async(
        async_replicated_cache):
    srv = start_ignite(idx=4)
    try:
        while True:
            await async_replicated_cache.put(1, 1)

            if requests.pop() == 4:
                break

        kill_process_tree(srv.pid)

        num_failures = 0
        for i in range(100):
            # Request may fail one time, because query can be requested before affinity update or connection
            # lost will be detected.
            try:
                await async_replicated_cache.put(1, 1)
            except:  # noqa 13
                num_failures += 1
                assert num_failures <= 1, "Expected no more than 1 failure."
    finally:
        kill_process_tree(srv.pid)
Ejemplo n.º 7
0
 def start(idx=1, debug=False, use_ssl=False, use_auth=False, jvm_opts=''):
     return start_ignite(idx=idx,
                         debug=debug,
                         use_ssl=use_ssl,
                         use_auth=use_auth,
                         jvm_opts=jvm_opts)