Skip to content

Commit 1f6d345

Browse files
committed
Use folly::Init for mock servers to avoid glog warnings
As D57798214 but for the standalone mock binaries used in integration testing. This avoids repeated "WARNING: Logging before InitGoogleLogging() is written to STDERR" errors in test logs.
1 parent b0ad0f3 commit 1f6d345

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

‎mcrouter/lib/network/test/MockMcServer.cpp‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
#include <glog/logging.h>
1414

1515
#include <folly/Format.h>
16-
#include <folly/Singleton.h>
16+
#include <folly/init/Init.h>
1717
#include <folly/logging/Init.h>
1818

1919
#include "mcrouter/lib/network/AsyncMcServer.h"
2020
#include "mcrouter/lib/network/AsyncMcServerWorker.h"
21-
#include "mcrouter/lib/network/CarbonMessageDispatcher.h"
2221
#include "mcrouter/lib/network/McServerRequestContext.h"
2322
#include "mcrouter/lib/network/gen/MemcacheServer.h"
24-
#include "mcrouter/lib/network/test/MockMc.h"
2523
#include "mcrouter/lib/network/test/MockMcOnRequest.h"
2624

2725
/**
@@ -69,7 +67,7 @@ void serverLoop(
6967
FOLLY_INIT_LOGGING_CONFIG(".=WARNING,folly=INFO; default:async=true");
7068

7169
int main(int argc, char** argv) {
72-
folly::SingletonVault::singleton()->registrationComplete();
70+
folly::Init init(&argc, &argv, folly::InitOptions{}.useGFlags(false).removeFlags(false));
7371

7472
AsyncMcServer::Options opts;
7573
opts.worker.versionString = "MockMcServer-1.0";

‎mcrouter/lib/network/test/MockMcServerDual.cpp‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <glog/logging.h>
1414

1515
#include <folly/Format.h>
16-
#include <folly/Singleton.h>
1716
#include <folly/executors/IOThreadPoolExecutor.h>
17+
#include <folly/init/Init.h>
1818
#include <folly/io/async/AsyncSignalHandler.h>
1919
#include <folly/io/async/EventBase.h>
2020
#include <folly/logging/Init.h>
@@ -23,8 +23,6 @@
2323
#include "mcrouter/ExecutorObserver.h"
2424
#include "mcrouter/lib/network/AsyncMcServer.h"
2525
#include "mcrouter/lib/network/AsyncMcServerWorker.h"
26-
#include "mcrouter/lib/network/CarbonMessageDispatcher.h"
27-
#include "mcrouter/lib/network/McServerRequestContext.h"
2826
#include "mcrouter/lib/network/ServerLoad.h"
2927
#include "mcrouter/lib/network/test/MockMcThriftServerHandler.h"
3028

@@ -98,7 +96,7 @@ class ShutdownSignalHandler : public folly::AsyncSignalHandler {
9896
};
9997

10098
int main(int argc, char** argv) {
101-
folly::SingletonVault::singleton()->registrationComplete();
99+
folly::Init init(&argc, &argv, folly::InitOptions{}.useGFlags(false).removeFlags(false));
102100

103101
AsyncMcServer::Options asyncOpts;
104102
asyncOpts.worker.versionString = "MockMcServer-1.0";

‎mcrouter/lib/network/test/MockMcThriftServer.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <glog/logging.h>
1414

1515
#include <folly/Format.h>
16-
#include <folly/Singleton.h>
16+
#include <folly/init/Init.h>
1717
#include <folly/logging/Init.h>
1818
#include <thrift/lib/cpp2/server/ThriftServer.h>
1919

@@ -52,7 +52,7 @@ void sigHandler(int /* signo */) {
5252
}
5353

5454
int main(int argc, char** argv) {
55-
folly::SingletonVault::singleton()->registrationComplete();
55+
folly::Init init(&argc, &argv, folly::InitOptions{}.useGFlags(false).removeFlags(false));
5656

5757
uint16_t port = 0;
5858
int existingSocketFd = 0;

0 commit comments

Comments
 (0)