nats-io / nats.py

Python3 client for NATS
https://nats-io.github.io/nats.py/
Apache License 2.0
874 stars 184 forks source link

PullSubscribeTest fails in 2.1.3 #329

Open HRio opened 2 years ago

HRio commented 2 years ago

PullSubscribeTest was fine in 2.1.2 but does not work in 2.1.3

=================================== FAILURES ===================================
________________________ PullSubscribeTest.test_fetch_n ________________________
self = <tests.test_js.PullSubscribeTest testMethod=test_fetch_n>
    @async_long_test
    async def test_fetch_n(self):
        nc = NATS()
        await nc.connect()
        js = nc.jetstream()

        await js.add_stream(name="TESTN", subjects=["a", "b", "c"])

        for i in range(0, 10):
            await js.publish("a", f'i:{i}'.encode())

        sub = await js.pull_subscribe(
            "a",
            "durable-1",
            config=nats.js.api.ConsumerConfig(max_waiting=3),
        )
        info = await sub.consumer_info()
        assert info.config.max_waiting == 3

        # 10 messages
        # -5 fetched
        # -----------
        #  5 pending
        msgs = await sub.fetch(5)
        assert len(msgs) == 5

        i = 0
        for msg in msgs:
            assert msg.data == f'i:{i}'.encode()
            await msg.ack()
            i += 1
        info = await sub.consumer_info()
        assert info.num_pending == 5

        # 5 messages
        # -10 fetched
        # -----------
        #  5 pending
        msgs = await sub.fetch(10, timeout=0.5)
        assert len(msgs) == 5

        i = 5
        for msg in msgs:
            assert msg.data == f'i:{i}'.encode()
            await msg.ack()
            i += 1

        info = await sub.consumer_info()
>       assert info.num_ack_pending == 0
E       AssertionError: assert 5 == 0
E        +  where 5 = ConsumerInfo(name='durable-1', stream_name='TESTN', config=ConsumerConfig(durable_name='durable-1', description=None, ...sterInfo(leader='NBPRCBIJJKWAJOO7T2NZE4W3KRB7KJXRWWKJKGJM5ZGCA4ZNV3FO53VD', name=None, replicas=None), push_bound=None).num_ack_pending
tests/test_js.py:326: AssertionError
---------- coverage: platform linux, python 3.10.5-final-0 -----------
Coverage HTML written to dir htmlcov
=========================== short test summary info ============================
FAILED tests/test_js.py::PullSubscribeTest::test_fetch_n - AssertionError: as...
============= 1 failed, 121 passed, 5 skipped in 106.39s (0:01:46) =============

Bisection points at dba601d31a30306de54c590f5dabf9ce4e3bf67d

Note Using nats-server v2.8.4 built from sources.

HRio commented 2 years ago

Python version used is 3.10.5