Skip to content

Commit bde6ee1

Browse files
committed
Upgrade the C++ client to 3.5.0 for some bug fixes
Fixes #199 Fixes #193 Upgraded the pulsar-client-cpp dependency to 3.5.0, which has the fixes for them. Then add relevant unit tests.
1 parent 865bc9d commit bde6ee1

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

Diff for: dependencies.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
cmake: 3.24.2
21-
pulsar-cpp: 3.4.2
21+
pulsar-cpp: 3.5.0
2222
pybind11: 2.10.1
2323
boost: 1.80.0
2424
protobuf: 3.20.0

Diff for: tests/pulsar_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from _pulsar import ProducerConfiguration, ConsumerConfiguration, RegexSubscriptionMode
5353

5454
from schema_test import *
55+
from reader_test import *
5556

5657
from urllib.request import urlopen, Request
5758

Diff for: tests/reader_test.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
from unittest import TestCase, main
22+
import time
23+
24+
from pulsar import Client, MessageId
25+
26+
class ReaderTest(TestCase):
27+
28+
def setUp(self):
29+
self._client: Client = Client('pulsar://localhost:6650')
30+
31+
def tearDown(self) -> None:
32+
self._client.close()
33+
34+
def test_has_message_available_after_seek(self):
35+
topic = f'test_has_message_available_after_seek-{time.time()}'
36+
producer = self._client.create_producer(topic)
37+
reader = self._client.create_reader(topic, start_message_id=MessageId.earliest)
38+
39+
producer.send('msg-0'.encode())
40+
self.assertTrue(reader.has_message_available())
41+
42+
reader.seek(MessageId.latest)
43+
self.assertFalse(reader.has_message_available())
44+
45+
producer.send('msg-1'.encode())
46+
self.assertTrue(reader.has_message_available())
47+
48+
def test_seek_latest_message_id(self):
49+
topic = f'test_seek_latest_message_id-{time.time()}'
50+
producer = self._client.create_producer(topic)
51+
msg_id = producer.send('msg'.encode())
52+
53+
reader = self._client.create_reader(topic,
54+
start_message_id=MessageId.latest)
55+
self.assertFalse(reader.has_message_available())
56+
reader.close()
57+
58+
reader = self._client.create_reader(topic,
59+
start_message_id=MessageId.latest,
60+
start_message_id_inclusive=True)
61+
self.assertTrue(reader.has_message_available())
62+
msg = reader.read_next(3000)
63+
self.assertEqual(msg.message_id(), msg_id)
64+
reader.close()
65+
66+
67+
if __name__ == "__main__":
68+
main()

0 commit comments

Comments
 (0)