Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3540328
D4768.id15793.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4768.id15793.diff
View Options
diff --git a/services/tunnelbroker/test/AmqpManagerTest.cpp b/services/tunnelbroker/test/AmqpManagerTest.cpp
--- a/services/tunnelbroker/test/AmqpManagerTest.cpp
+++ b/services/tunnelbroker/test/AmqpManagerTest.cpp
@@ -117,3 +117,37 @@
<< receivedMessage.payload;
AmqpManager::getInstance().ack(receivedMessage.deliveryTag);
}
+
+TEST_F(AmqpManagerTest, MultipleThreadsMessagesSendingStressTest) {
+ const size_t MESSAGES_NUMBER = 10;
+ const size_t THREADS_NUMBER = 100;
+ const std::string toDeviceID =
+ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH);
+
+ std::vector<std::thread> sendingThreads;
+ for (size_t i = 0; i < THREADS_NUMBER; ++i) {
+ sendingThreads.push_back(std::thread([toDeviceID, MESSAGES_NUMBER]() {
+ for (size_t i = 0; i < MESSAGES_NUMBER; ++i) {
+ const std::string messageID = tools::generateUUID();
+ const std::string fromDeviceID =
+ "web:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH);
+ const std::string payload = tools::generateRandomString(512);
+ const database::MessageItem messageItem{
+ messageID, fromDeviceID, toDeviceID, payload, ""};
+ EXPECT_TRUE(AmqpManager::getInstance().send(&messageItem));
+ }
+ }));
+ }
+
+ std::vector<DeliveryBrokerMessage> receivedMessage;
+
+ for (size_t i = 0; i < MESSAGES_NUMBER * THREADS_NUMBER; ++i) {
+ receivedMessage.push_back(DeliveryBroker::getInstance().pop(toDeviceID));
+ AmqpManager::getInstance().ack(receivedMessage.back().deliveryTag);
+ }
+ EXPECT_TRUE(DeliveryBroker::getInstance().isEmpty(toDeviceID));
+ EXPECT_EQ(receivedMessage.size(), MESSAGES_NUMBER * THREADS_NUMBER);
+ for (std::thread &thread : sendingThreads) {
+ thread.join();
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 4:45 AM (9 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2710567
Default Alt Text
D4768.id15793.diff (1 KB)
Attached To
Mode
D4768: [services] Tunnelbroker - Amqp Manager in parallel threads messages throughput test
Attached
Detach File
Event Timeline
Log In to Comment