Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3538592
D4768.id15924.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.id15924.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
@@ -80,3 +80,36 @@
<< 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);
+ }
+ for (std::thread &thread : sendingThreads) {
+ thread.join();
+ }
+ EXPECT_TRUE(DeliveryBroker::getInstance().isEmpty(toDeviceID));
+ EXPECT_EQ(receivedMessage.size(), MESSAGES_NUMBER * THREADS_NUMBER);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 11:09 PM (3 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2709416
Default Alt Text
D4768.id15924.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