@@ -1741,6 +1741,14 @@ public void testNoRepeatedReadAndDiscard() throws Exception {
1741
1741
admin .topics ().delete (topic , false );
1742
1742
}
1743
1743
1744
+ @ DataProvider (name = "allowKeySharedOutOfOrder" )
1745
+ public Object [][] allowKeySharedOutOfOrder () {
1746
+ return new Object [][]{
1747
+ {true },
1748
+ {false }
1749
+ };
1750
+ }
1751
+
1744
1752
/**
1745
1753
* This test is in order to guarantee the feature added by https://github.com/apache/pulsar/pull/7105.
1746
1754
* 1. Start 3 consumers:
@@ -1755,8 +1763,8 @@ public void testNoRepeatedReadAndDiscard() throws Exception {
1755
1763
* - no repeated Read-and-discard.
1756
1764
* - at last, all messages will be received.
1757
1765
*/
1758
- @ Test (timeOut = 180 * 1000 ) // the test will be finished in 60s.
1759
- public void testRecentJoinedPosWillNotStuckOtherConsumer () throws Exception {
1766
+ @ Test (timeOut = 180 * 1000 , dataProvider = "allowKeySharedOutOfOrder" ) // the test will be finished in 60s.
1767
+ public void testRecentJoinedPosWillNotStuckOtherConsumer (boolean allowKeySharedOutOfOrder ) throws Exception {
1760
1768
final int messagesSentPerTime = 100 ;
1761
1769
final Set <Integer > totalReceivedMessages = new TreeSet <>();
1762
1770
final String topic = BrokerTestUtil .newUniqueName ("persistent://public/default/tp" );
@@ -1775,6 +1783,8 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1775
1783
log .info ("Published message :{}" , messageId );
1776
1784
}
1777
1785
1786
+ KeySharedPolicy keySharedPolicy = KeySharedPolicy .autoSplitHashRange ()
1787
+ .setAllowOutOfOrderDelivery (allowKeySharedOutOfOrder );
1778
1788
// 1. Start 3 consumers and make ack holes.
1779
1789
// - one consumer will be closed and trigger a messages redeliver.
1780
1790
// - one consumer will not ack any messages to make the new consumer joined late will be stuck due to the
@@ -1785,18 +1795,21 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1785
1795
.subscriptionName (subName )
1786
1796
.receiverQueueSize (10 )
1787
1797
.subscriptionType (SubscriptionType .Key_Shared )
1798
+ .keySharedPolicy (keySharedPolicy )
1788
1799
.subscribe ();
1789
1800
Consumer <Integer > consumer2 = pulsarClient .newConsumer (Schema .INT32 )
1790
1801
.topic (topic )
1791
1802
.subscriptionName (subName )
1792
1803
.receiverQueueSize (10 )
1793
1804
.subscriptionType (SubscriptionType .Key_Shared )
1805
+ .keySharedPolicy (keySharedPolicy )
1794
1806
.subscribe ();
1795
1807
Consumer <Integer > consumer3 = pulsarClient .newConsumer (Schema .INT32 )
1796
1808
.topic (topic )
1797
1809
.subscriptionName (subName )
1798
1810
.receiverQueueSize (10 )
1799
1811
.subscriptionType (SubscriptionType .Key_Shared )
1812
+ .keySharedPolicy (keySharedPolicy )
1800
1813
.subscribe ();
1801
1814
List <Message > msgList1 = new ArrayList <>();
1802
1815
List <Message > msgList2 = new ArrayList <>();
@@ -1845,6 +1858,7 @@ public void testRecentJoinedPosWillNotStuckOtherConsumer() throws Exception {
1845
1858
.subscriptionName (subName )
1846
1859
.receiverQueueSize (1000 )
1847
1860
.subscriptionType (SubscriptionType .Key_Shared )
1861
+ .keySharedPolicy (keySharedPolicy )
1848
1862
.subscribe ();
1849
1863
consumerWillBeClose .close ();
1850
1864
0 commit comments