-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move source ip from req context to req common
Summary: - move source ip to req common - use folly::IPAddress instead of std::string - change callsites to get ip from req rather than ctx Reviewed By: disylh Differential Revision: D64721214 fbshipit-source-id: d5d7bc35def6555e5de78db50c704b9bed0e77ee
- Loading branch information
1 parent
ebb0407
commit 4450ce9
Showing
14 changed files
with
138 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "mcrouter/lib/test/TestRouteHandle.h" | ||
#include "mcrouter/routes/LoggingRoute.h" | ||
#include "mcrouter/routes/test/RouteHandleTestUtil.h" | ||
|
||
using TestRouterInfo = facebook::memcache::TestRouterInfo; | ||
using TestHandle = | ||
facebook::memcache::TestHandleImpl<facebook::memcache::TestRouteHandleIf>; | ||
using LoggingRoute = facebook::memcache::mcrouter::LoggingRoute<TestRouterInfo>; | ||
|
||
TEST(LoggingRouteTest, basic) { | ||
std::shared_ptr<TestHandle> test_handle = std::make_shared<TestHandle>( | ||
facebook::memcache::GetRouteTestData(carbon::Result::FOUND, "a")); | ||
|
||
auto rh = facebook::memcache::mcrouter::createLoggingRoute<TestRouterInfo>( | ||
test_handle->rh); | ||
facebook::memcache::McGetRequest req("key"); | ||
req.setSourceIpAddr(folly::IPAddress("1.2.3.4")); | ||
|
||
facebook::memcache::TestFiberManager<facebook::memcache::TestRouterInfo> fm; | ||
fm.run([&]() { | ||
facebook::memcache::mcrouter::mockFiberContext(); | ||
facebook::memcache::mcrouter::getTestRouter()->setPostprocessCallback( | ||
[](const folly::dynamic&, | ||
const folly::dynamic&, | ||
const char* const, | ||
const folly::StringPiece ip) { EXPECT_EQ("1.2.3.4", ip); }); | ||
auto reply = rh->route(req); | ||
EXPECT_EQ("a", carbon::valueRangeSlow(reply).str()); | ||
}); | ||
} |
Oops, something went wrong.