From c1f9fb7a59afd4d5fbcf51eea9237b6d9473a2a9 Mon Sep 17 00:00:00 2001
From: gvolfing <gabor.volfinger@memgraph.io>
Date: Tue, 16 Aug 2022 10:02:01 +0200
Subject: [PATCH] Conform cmake

---
 environment/toolchain/fbthrift.patch | 12 ++++++++++++
 src/CMakeLists.txt                   |  2 +-
 src/interface/CMakeLists.txt         |  2 +-
 src/interface/echo.thrift            |  7 +++++++
 tests/unit/CMakeLists.txt            |  2 +-
 tests/unit/thrift_transport_echo.cpp |  6 +-----
 6 files changed, 23 insertions(+), 8 deletions(-)
 create mode 100644 environment/toolchain/fbthrift.patch
 create mode 100644 src/interface/echo.thrift

diff --git a/environment/toolchain/fbthrift.patch b/environment/toolchain/fbthrift.patch
new file mode 100644
index 000000000..c1b370247
--- /dev/null
+++ b/environment/toolchain/fbthrift.patch
@@ -0,0 +1,12 @@
+diff -ur a/thrift/lib/cpp2/server/IOWorkerContext.h b/thrift/lib/cpp2/server/IOWorkerContext.h
+--- a/thrift/lib/cpp2/server/IOWorkerContext.h  2022-06-08 11:50:43.043948657 +0200
++++ b/thrift/lib/cpp2/server/IOWorkerContext.h  2022-06-08 11:47:33.232695125 +0200
+@@ -59,7 +59,7 @@
+           auto aliveLocked = alive->rlock();
+           if (*aliveLocked) {
+             // IOWorkerContext is still alive and so is replyQueue_
+-            queue->startConsumingInternal(&evb);
++            queue->startConsuming(&evb);
+           }
+         });
+   }
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf1d626c3..3a239dda2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,7 +42,7 @@ set(mg_single_node_v2_sources
 )
 
 set(mg_single_node_v2_libs stdc++fs Threads::Threads
-    telemetry_lib mg-query mg-communication mg-memory mg-utils mg-auth mg-license mg-settings, mg-interface-storage-cpp2)
+    telemetry_lib mg-query mg-communication mg-memory mg-utils mg-auth mg-license mg-settings)
 if (MG_ENTERPRISE)
   # These are enterprise subsystems
   set(mg_single_node_v2_libs ${mg_single_node_v2_libs} mg-audit)
diff --git a/src/interface/CMakeLists.txt b/src/interface/CMakeLists.txt
index baafd86c6..8cbdf3433 100644
--- a/src/interface/CMakeLists.txt
+++ b/src/interface/CMakeLists.txt
@@ -27,7 +27,7 @@ mg_thrift_library(
 )
 
 mg_thrift_library(
-  "echo_trial" #file_name
+  "echo" #file_name
   "Echo" #services
   "${MG_INTERFACE_PATH}" #file_path
   "${MG_INTERFACE_PATH}" #output_path
diff --git a/src/interface/echo.thrift b/src/interface/echo.thrift
new file mode 100644
index 000000000..b7059f828
--- /dev/null
+++ b/src/interface/echo.thrift
@@ -0,0 +1,7 @@
+struct EchoMessage {
+    1: binary message;
+}
+
+service Echo {
+    oneway void ReceiveSend(1: EchoMessage m)
+}
diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt
index c4c957b8b..c30577dea 100644
--- a/tests/unit/CMakeLists.txt
+++ b/tests/unit/CMakeLists.txt
@@ -397,4 +397,4 @@ target_link_libraries(${test_prefix}future mg-io)
 
 # Test Thrift transport echo
 add_unit_test(thrift_transport_echo.cpp)
-target_link_libraries(${test_prefix}thrift_transport_echo mg-io)
+target_link_libraries(${test_prefix}thrift_transport_echo mg-io Threads::Threads mg-interface-echo-cpp2 fmt)
diff --git a/tests/unit/thrift_transport_echo.cpp b/tests/unit/thrift_transport_echo.cpp
index 607805212..a0752e396 100644
--- a/tests/unit/thrift_transport_echo.cpp
+++ b/tests/unit/thrift_transport_echo.cpp
@@ -33,8 +33,6 @@ using namespace folly;
 
 using namespace std::chrono_literals;
 
-namespace {
-
 // static constexpr int port = 6666;  // The port on which server is listening
 
 class EchoSvc : public EchoSvIf {
@@ -49,7 +47,7 @@ class EchoSvc : public EchoSvIf {
   // The Thrift handle method
   void ReceiveSend(const EchoMessage &m) override {
     // m.get_message();
-    LOG(ERROR) << "Received\n";
+    // LOG(ERROR) << "Received\n";
     current_message_ = prefix_ + m.get_message();
     // SendOutMessage(6665);
     //  LOG(ERROR) << "Sent\n";
@@ -88,8 +86,6 @@ class EchoSvc : public EchoSvIf {
   std::string GetCurrentMessage() { return current_message_; }
 };
 
-}  // namespace
-
 TEST(ThriftTransport, Echo) {
   // TODO(tyler and gabor) use thrift-generated echo, and thrift transport, to send, reply, and receive the response for
   // a thrift-defined message