Commit aabeca71 authored by Mirek Klimos's avatar Mirek Klimos Committed by Facebook Github Bot 0

Test creation of RequestContext inside a fiber task

Summary: ^, as discussed on D3279644

Reviewed By: andriigrynenko

Differential Revision: D3299473

fbshipit-source-id: dc302132db64399f768d69c641f848d0da1075c4
parent 4d499e08
...@@ -1236,10 +1236,11 @@ TEST(FiberManager, RequestContext) { ...@@ -1236,10 +1236,11 @@ TEST(FiberManager, RequestContext) {
bool checkRun1 = false; bool checkRun1 = false;
bool checkRun2 = false; bool checkRun2 = false;
bool checkRun3 = false; bool checkRun3 = false;
bool checkRun4 = false;
folly::fibers::Baton baton1; folly::fibers::Baton baton1;
folly::fibers::Baton baton2; folly::fibers::Baton baton2;
folly::fibers::Baton baton3; folly::fibers::Baton baton3;
folly::fibers::Baton baton4;
folly::RequestContext::create(); folly::RequestContext::create();
auto rcontext1 = folly::RequestContext::get(); auto rcontext1 = folly::RequestContext::get();
...@@ -1276,6 +1277,15 @@ TEST(FiberManager, RequestContext) { ...@@ -1276,6 +1277,15 @@ TEST(FiberManager, RequestContext) {
checkRun3 = true; checkRun3 = true;
}); });
folly::RequestContext::setContext(nullptr);
fm.addTask([&]() {
folly::RequestContext::create();
auto rcontext4 = folly::RequestContext::get();
baton4.wait();
EXPECT_EQ(rcontext4, folly::RequestContext::get());
checkRun4 = true;
});
folly::RequestContext::create(); folly::RequestContext::create();
auto rcontext = folly::RequestContext::get(); auto rcontext = folly::RequestContext::get();
...@@ -1299,6 +1309,12 @@ TEST(FiberManager, RequestContext) { ...@@ -1299,6 +1309,12 @@ TEST(FiberManager, RequestContext) {
fm.loopUntilNoReady(); fm.loopUntilNoReady();
EXPECT_TRUE(checkRun3); EXPECT_TRUE(checkRun3);
EXPECT_EQ(rcontext, folly::RequestContext::get()); EXPECT_EQ(rcontext, folly::RequestContext::get());
baton4.post();
EXPECT_EQ(rcontext, folly::RequestContext::get());
fm.loopUntilNoReady();
EXPECT_TRUE(checkRun4);
EXPECT_EQ(rcontext, folly::RequestContext::get());
} }
TEST(FiberManager, resizePeriodically) { TEST(FiberManager, resizePeriodically) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment