@@ -1725,6 +1725,14 @@ public void testNoRepeatedReadAndDiscard() throws Exception {
1725
1725
admin .topics ().delete (topic , false );
1726
1726
}
1727
1727
1728
+ @ DataProvider (name = "allowKeySharedOutOfOrder" )
1729
+ public Object [][] allowKeySharedOutOfOrder () {
1730
+ return new Object [][]{
1731
+ {true },
1732
+ {false }
1733
+ };
1734
+ }
1735
+
1728
1736
/**
1729
1737
* This test is in order to guarantee the feature added by https://github.com/apache/pulsar/pull/7105.
1730
1738
* 1. Start 3 consumers:
@@ -1739,8 +1747,8 @@ public void testNoRepeatedReadAndDiscard() throws Exception {
1739
1747
* - no repeated Read-and-discard.
1740
1748
* - at last, all messages will be received.
1741
1749
*/
1742
- @ Test (timeOut = 180 * 1000 ) // the test will be finished in 60s.
1743
- public void testRecentJoinedPosWillNotStuckOtherConsumer () throws Exception {
1750
+ @ Test (timeOut = 180 * 1000 , dataProvider = "allowKeySharedOutOfOrder" ) // the test will be finished in 60s.
1751
+ public void testRecentJoinedPosWillNotStuckOtherConsumer (boolean allowKeySharedOutOfOrder ) throws Exception {
1744
1752
final int messagesSentPerTime = 100 ;
1745
1753
final Set <Integer > totalReceivedMessages = new TreeSet <>();
1746
1754
final String topic = BrokerTestUtil .newUniqueName ("persistent://public/default/tp" );
@@ -1759,6 +1767,8 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1759
1767
log .info ("Published message :{}" , messageId );
1760
1768
}
1761
1769
1770
+ KeySharedPolicy keySharedPolicy = KeySharedPolicy .autoSplitHashRange ()
1771
+ .setAllowOutOfOrderDelivery (allowKeySharedOutOfOrder );
1762
1772
// 1. Start 3 consumers and make ack holes.
1763
1773
// - one consumer will be closed and trigger a messages redeliver.
1764
1774
// - one consumer will not ack any messages to make the new consumer joined late will be stuck due to the
@@ -1769,18 +1779,21 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1769
1779
.subscriptionName (subName )
1770
1780
.receiverQueueSize (10 )
1771
1781
.subscriptionType (SubscriptionType .Key_Shared )
1782
+ .keySharedPolicy (keySharedPolicy )
1772
1783
.subscribe ();
1773
1784
Consumer <Integer > consumer2 = pulsarClient .newConsumer (Schema .INT32 )
1774
1785
.topic (topic )
1775
1786
.subscriptionName (subName )
1776
1787
.receiverQueueSize (10 )
1777
1788
.subscriptionType (SubscriptionType .Key_Shared )
1789
+ .keySharedPolicy (keySharedPolicy )
1778
1790
.subscribe ();
1779
1791
Consumer <Integer > consumer3 = pulsarClient .newConsumer (Schema .INT32 )
1780
1792
.topic (topic )
1781
1793
.subscriptionName (subName )
1782
1794
.receiverQueueSize (10 )
1783
1795
.subscriptionType (SubscriptionType .Key_Shared )
1796
+ .keySharedPolicy (keySharedPolicy )
1784
1797
.subscribe ();
1785
1798
List <Message > msgList1 = new ArrayList <>();
1786
1799
List <Message > msgList2 = new ArrayList <>();
@@ -1829,6 +1842,7 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1829
1842
.subscriptionName (subName )
1830
1843
.receiverQueueSize (1000 )
1831
1844
.subscriptionType (SubscriptionType .Key_Shared )
1845
+ .keySharedPolicy (keySharedPolicy )
1832
1846
.subscribe ();
1833
1847
consumerWillBeClose .close ();
1834
1848
0 commit comments