SharedThreadPool unittest
authorDave Watson <davejwatson@fb.com>
Mon, 29 Dec 2014 20:18:39 +0000 (12:18 -0800)
committerAjit Banerjee <ajitb@fb.com>
Wed, 7 Jan 2015 20:24:35 +0000 (12:24 -0800)
Summary: Add a test to check that the accept IOPool can be the same as the IO worker thread pool

Test Plan: unittest

Reviewed By: jsedgwick@fb.com

Subscribers: doug, fugalh, njormrod, folly-diffs@

FB internal diff: D1710628

Signature: t1:1710628:1417469919:6d81a9426b61e9f1b804114f895ed541e547110f

folly/wangle/bootstrap/BootstrapTest.cpp

index 6b902d20b845ec6adb05a0b50493415f7e0a229c..1efb4e089f0f32a5630483dd6a5694fe5fb62331 100644 (file)
@@ -169,3 +169,37 @@ TEST(Bootstrap, ServerAcceptGroup2Test) {
 
   CHECK(factory->pipelines == 1);
 }
+
+TEST(Bootstrap, SharedThreadPool) {
+  auto pool = std::make_shared<IOThreadPoolExecutor>(2);
+
+  TestServer server;
+  auto factory = std::make_shared<TestPipelineFactory>();
+  server.childPipeline(factory);
+  server.group(pool, pool);
+
+  server.bind(0);
+
+  SocketAddress address;
+  server.getSockets()[0]->getAddress(&address);
+
+  TestClient client;
+  client.connect(address);
+
+  TestClient client2;
+  client2.connect(address);
+
+  TestClient client3;
+  client3.connect(address);
+
+  TestClient client4;
+  client4.connect(address);
+
+  TestClient client5;
+  client5.connect(address);
+
+  EventBaseManager::get()->getEventBase()->loop();
+
+  server.stop();
+  CHECK(factory->pipelines == 5);
+}