|
96 | 96 | import org.testng.Assert; |
97 | 97 | import org.testng.annotations.AfterMethod; |
98 | 98 | import org.testng.annotations.BeforeMethod; |
| 99 | +import org.testng.annotations.DataProvider; |
99 | 100 | import org.testng.annotations.Test; |
100 | 101 |
|
101 | 102 | public class TopicsTest extends MockedPulsarServiceBaseTest { |
@@ -168,10 +169,19 @@ private static List<ProducerMessage> createMessages(String message) throws JsonP |
168 | 169 | }).readValue(message); |
169 | 170 | } |
170 | 171 |
|
171 | | - @Test |
172 | | - public void testProduceToPartitionedTopic() throws Exception { |
| 172 | + @DataProvider(name = "partitionNumbers") |
| 173 | + public Object[][] partitionNumbers() { |
| 174 | + return new Object[][] { |
| 175 | + //produce to single-partitioned topic |
| 176 | + {1}, |
| 177 | + {5}, |
| 178 | + }; |
| 179 | + } |
| 180 | + |
| 181 | + @Test(dataProvider = "partitionNumbers") |
| 182 | + public void testProduceToPartitionedTopic(int numPartitions) throws Exception { |
173 | 183 | admin.topics().createPartitionedTopic("persistent://" + testTenant + "/" + testNamespace |
174 | | - + "/" + testTopicName + "-p", 5); |
| 184 | + + "/" + testTopicName + "-p", numPartitions); |
175 | 185 | AsyncResponse asyncResponse = mock(AsyncResponse.class); |
176 | 186 | Schema<String> schema = StringSchema.utf8(); |
177 | 187 | ProducerMessages producerMessages = new ProducerMessages(); |
@@ -210,7 +220,7 @@ public void testProduceToPartitionedTopic() throws Exception { |
210 | 220 | } |
211 | 221 | for (int index = 0; index < messagePerPartition.length; index++) { |
212 | 222 | // We publish to each partition in round robin mode so each partition should get at most 2 message. |
213 | | - Assert.assertTrue(messagePerPartition[index] <= 2); |
| 223 | + Assert.assertTrue(messagePerPartition[index] <= 10 / numPartitions); |
214 | 224 | } |
215 | 225 | } |
216 | 226 |
|
|
0 commit comments