Add POC thrift echo test

This commit is contained in:
gvolfing 2022-08-16 12:20:22 +02:00 committed by Tyler Neely
parent c1f9fb7a59
commit f8d1129af1
3 changed files with 12 additions and 8 deletions

View File

@ -1,8 +1,11 @@
# include(MgThrift)
set(test_prefix memgraph__unit__)
find_package(fmt REQUIRED)
find_package(gflags REQUIRED)
find_package(Threads REQUIRED)
find_package(Folly REQUIRED)
add_custom_target(memgraph__unit)
@ -37,7 +40,7 @@ function(_add_unit_test test_cpp custom_main)
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
target_link_libraries(${target_name} mg-memory mg-utils gtest gmock Threads::Threads dl)
target_link_libraries(${target_name} mg-memory mg-utils gtest gmock Threads::Threads dl mg-interface-echo-cpp2)
# register test
if(TEST_COVERAGE)

View File

@ -9,11 +9,15 @@
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
#include <folly/init/Init.h>
#include <gtest/gtest.h>
#include <utils/logging.hpp>
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
folly::Init(&argc, &argv);
memgraph::logging::RedirectToStderr();
spdlog::set_level(spdlog::level::trace);
return RUN_ALL_TESTS();

View File

@ -89,10 +89,6 @@ class EchoSvc : public EchoSvIf {
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
int argc = 0;
char **argv;
folly::init(&argc, &argv);
auto ptr1 = std::make_shared<EchoSvc>();
auto ptr2 = std::make_shared<EchoSvc>();
@ -110,18 +106,19 @@ TEST(ThriftTransport, Echo) {
s->serve();
});
// Wait some time...
std::this_thread::sleep_for(4000ms);
ptr1->SendOneShotMessage(6666, "original");
// Wait some time...
std::this_thread::sleep_for(4000ms);
ptr2->SendOutMessage(6665);
// Wait some time...
std::this_thread::sleep_for(4000ms);
auto result = ptr1->GetCurrentMessage();
ASSERT_EQ(result, std::string("00original"));
// Solve this once this is not just a POC.
server_thread2.detach();
server_thread1.detach();
}