@@ -101,6 +101,11 @@ static void waitForPartitionsUpdated() {
101
101
std::this_thread::sleep_for (std::chrono::seconds (3 ));
102
102
}
103
103
104
+ static void waitForPartitionUpdateTaskRunMultipleTimes () {
105
+ // Assume runPartitionUpdateTask run more than one time in 2 seconds if enabled
106
+ std::this_thread::sleep_for (std::chrono::seconds (2 ));
107
+ }
108
+
104
109
TEST (PartitionsUpdateTest, testConfigPartitionsUpdateInterval) {
105
110
ClientConfiguration clientConfig;
106
111
ASSERT_EQ (60 , clientConfig.getPartitionsUpdateInterval ());
@@ -131,6 +136,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
131
136
ASSERT_EQ (ResultOk, partitionsSet.initProducer (topicName, true , lazyStartPartitionedProducers));
132
137
ASSERT_EQ (ResultOk, partitionsSet.initConsumer (topicName, true ));
133
138
139
+ waitForPartitionUpdateTaskRunMultipleTimes ();
134
140
res = makePostRequest (topicOperateUrl, " 3" ); // update partitions to 3
135
141
ASSERT_TRUE (res == 204 || res == 409 ) << " res: " << res;
136
142
waitForPartitionsUpdated ();
@@ -143,6 +149,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
143
149
ASSERT_EQ (ResultOk, partitionsSet.initProducer (topicName, true , false ));
144
150
ASSERT_EQ (ResultOk, partitionsSet.initConsumer (topicName, false ));
145
151
152
+ waitForPartitionUpdateTaskRunMultipleTimes ();
146
153
res = makePostRequest (topicOperateUrl, " 5" ); // update partitions to 5
147
154
ASSERT_TRUE (res == 204 || res == 409 ) << " res: " << res;
148
155
waitForPartitionsUpdated ();
@@ -155,6 +162,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
155
162
ASSERT_EQ (ResultOk, partitionsSet.initProducer (topicName, false , false ));
156
163
ASSERT_EQ (ResultOk, partitionsSet.initConsumer (topicName, true ));
157
164
165
+ waitForPartitionUpdateTaskRunMultipleTimes ();
158
166
res = makePostRequest (topicOperateUrl, " 7" ); // update partitions to 7
159
167
ASSERT_TRUE (res == 204 || res == 409 ) << " res: " << res;
160
168
waitForPartitionsUpdated ();
@@ -167,6 +175,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
167
175
ASSERT_EQ (ResultOk, partitionsSet.initProducer (topicName, false , false ));
168
176
ASSERT_EQ (ResultOk, partitionsSet.initConsumer (topicName, false ));
169
177
178
+ waitForPartitionUpdateTaskRunMultipleTimes ();
170
179
res = makePostRequest (topicOperateUrl, " 10" ); // update partitions to 10
171
180
ASSERT_TRUE (res == 204 || res == 409 ) << " res: " << res;
172
181
waitForPartitionsUpdated ();
0 commit comments