Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/PartitionedProducerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ void PartitionedProducerImpl::handleGetPartitions(Result result,
}
} else {
LOG_WARN("Failed to getPartitionMetadata: " << strResult(result));
runPartitionUpdateTask();
}
runPartitionUpdateTask();
}

bool PartitionedProducerImpl::isConnected() const {
Expand Down
9 changes: 9 additions & 0 deletions tests/PartitionsUpdateTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ static void waitForPartitionsUpdated() {
std::this_thread::sleep_for(std::chrono::seconds(3));
}

static void waitForPartitionUpdateTaskRunMultipleTimes() {
// Assume runPartitionUpdateTask run more than one time in 2 seconds if enabled
std::this_thread::sleep_for(std::chrono::seconds(2));
}

TEST(PartitionsUpdateTest, testConfigPartitionsUpdateInterval) {
ClientConfiguration clientConfig;
ASSERT_EQ(60, clientConfig.getPartitionsUpdateInterval());
Expand Down Expand Up @@ -131,6 +136,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
ASSERT_EQ(ResultOk, partitionsSet.initProducer(topicName, true, lazyStartPartitionedProducers));
ASSERT_EQ(ResultOk, partitionsSet.initConsumer(topicName, true));

waitForPartitionUpdateTaskRunMultipleTimes();
res = makePostRequest(topicOperateUrl, "3"); // update partitions to 3
ASSERT_TRUE(res == 204 || res == 409) << "res: " << res;
waitForPartitionsUpdated();
Expand All @@ -143,6 +149,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
ASSERT_EQ(ResultOk, partitionsSet.initProducer(topicName, true, false));
ASSERT_EQ(ResultOk, partitionsSet.initConsumer(topicName, false));

waitForPartitionUpdateTaskRunMultipleTimes();
res = makePostRequest(topicOperateUrl, "5"); // update partitions to 5
ASSERT_TRUE(res == 204 || res == 409) << "res: " << res;
waitForPartitionsUpdated();
Expand All @@ -155,6 +162,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
ASSERT_EQ(ResultOk, partitionsSet.initProducer(topicName, false, false));
ASSERT_EQ(ResultOk, partitionsSet.initConsumer(topicName, true));

waitForPartitionUpdateTaskRunMultipleTimes();
res = makePostRequest(topicOperateUrl, "7"); // update partitions to 7
ASSERT_TRUE(res == 204 || res == 409) << "res: " << res;
waitForPartitionsUpdated();
Expand All @@ -167,6 +175,7 @@ void testPartitionsUpdate(bool lazyStartPartitionedProducers, std::string topicN
ASSERT_EQ(ResultOk, partitionsSet.initProducer(topicName, false, false));
ASSERT_EQ(ResultOk, partitionsSet.initConsumer(topicName, false));

waitForPartitionUpdateTaskRunMultipleTimes();
res = makePostRequest(topicOperateUrl, "10"); // update partitions to 10
ASSERT_TRUE(res == 204 || res == 409) << "res: " << res;
waitForPartitionsUpdated();
Expand Down