Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ut fix #3611

Merged
merged 5 commits into from
Jan 5, 2022
Merged

Ut fix #3611

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/common/expression/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ set(expression_test_common_libs
$<TARGET_OBJECTS:memory_obj>
)


if(ENABLE_STANDALONE_VERSION)
set(expression_test_common_libs
${expression_test_common_libs}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_library(
expr_ctx_mock_obj OBJECT
ExpressionContextMock.cpp
Expand Down
7 changes: 7 additions & 0 deletions src/graph/context/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ SET(CONTEXT_TEST_LIBS
$<TARGET_OBJECTS:storage_client_stats_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(CONTEXT_TEST_LIBS
${CONTEXT_TEST_LIBS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_test(
NAME context_test
SOURCES
Expand Down
14 changes: 14 additions & 0 deletions src/graph/executor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ SET(EXEC_QUERY_TEST_OBJS
$<TARGET_OBJECTS:storage_client_stats_obj>
)

if(ENABLE_STANDALONE_VERSION)

nebula_add_library(
storage_server_stub_obj OBJECT
StorageServerStub.cpp
)

set(EXEC_QUERY_TEST_OBJS
${EXEC_QUERY_TEST_OBJS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
$<TARGET_OBJECTS:storage_server_stub_obj>
)
endif()

SET(EXEC_QUERY_TEST_LIBS
${THRIFT_LIBRARIES}
gtest
Expand Down
154 changes: 154 additions & 0 deletions src/graph/executor/test/StorageServerStub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include <unistd.h>

#include "common/base/Base.h"
#include "storage/GraphStorageLocalServer.h"

#define LOCAL_RETURN_FUTURE(threadManager, respType, callFunc) \
UNUSED(request); \
auto promise = std::make_shared<folly::Promise<respType>>(); \
respType dummyResp; \
auto f = promise->getFuture(); \
promise->setValue(std::move(dummyResp)); \
return f;

namespace nebula::storage {

std::mutex mutex_;
std::shared_ptr<GraphStorageLocalServer> instance_ = nullptr;

void GraphStorageLocalServer::setThreadManager(
std::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager) {
// lock?
threadManager_ = threadManager;
}

void GraphStorageLocalServer::setInterface(
std::shared_ptr<apache::thrift::ServerInterface> handler) {
handler_ = handler;
}

void GraphStorageLocalServer::serve() {
if (serving_) {
LOG(WARNING) << "Server already serving";
return;
}
// do nothing, wait stop
serving_ = true;
sem_.wait();
}

void GraphStorageLocalServer::stop() {
if (!serving_) {
LOG(WARNING) << "Can't stop server not serving";
return;
}
sem_.signal();
serving_ = false;
}

folly::Future<cpp2::GetNeighborsResponse> GraphStorageLocalServer::future_getNeighbors(
const cpp2::GetNeighborsRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetNeighborsResponse, future_getNeighbors);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_addVertices(
const cpp2::AddVerticesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_addVertices);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_chainAddEdges(
const cpp2::AddEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_chainAddEdges);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_addEdges(
const cpp2::AddEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_addEdges);
}

folly::Future<cpp2::GetPropResponse> GraphStorageLocalServer::future_getProps(
const cpp2::GetPropRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetPropResponse, future_getProps);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_deleteEdges(
const cpp2::DeleteEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteEdges);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_chainDeleteEdges(
const cpp2::DeleteEdgesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_chainDeleteEdges);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_deleteVertices(
const cpp2::DeleteVerticesRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteVertices);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_deleteTags(
const cpp2::DeleteTagsRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_deleteTags);
}

folly::Future<cpp2::UpdateResponse> GraphStorageLocalServer::future_updateVertex(
const cpp2::UpdateVertexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_updateVertex);
}

folly::Future<cpp2::UpdateResponse> GraphStorageLocalServer::future_chainUpdateEdge(
const cpp2::UpdateEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_chainUpdateEdge);
}

folly::Future<cpp2::UpdateResponse> GraphStorageLocalServer::future_updateEdge(
const cpp2::UpdateEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::UpdateResponse, future_updateEdge);
}

folly::Future<cpp2::GetUUIDResp> GraphStorageLocalServer::future_getUUID(
const cpp2::GetUUIDReq& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetUUIDResp, future_getUUID);
}

folly::Future<cpp2::LookupIndexResp> GraphStorageLocalServer::future_lookupIndex(
const cpp2::LookupIndexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::LookupIndexResp, future_lookupIndex);
}

folly::Future<cpp2::GetNeighborsResponse> GraphStorageLocalServer::future_lookupAndTraverse(
const cpp2::LookupAndTraverseRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::GetNeighborsResponse, future_lookupAndTraverse);
}

folly::Future<cpp2::ScanResponse> GraphStorageLocalServer::future_scanVertex(
const cpp2::ScanVertexRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ScanResponse, future_scanVertex);
}

folly::Future<cpp2::ScanResponse> GraphStorageLocalServer::future_scanEdge(
const cpp2::ScanEdgeRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ScanResponse, future_scanEdge);
}

folly::Future<cpp2::KVGetResponse> GraphStorageLocalServer::future_get(
const cpp2::KVGetRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::KVGetResponse, future_get);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_put(
const cpp2::KVPutRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_put);
}

folly::Future<cpp2::ExecResponse> GraphStorageLocalServer::future_remove(
const cpp2::KVRemoveRequest& request) {
LOCAL_RETURN_FUTURE(threadManager_, cpp2::ExecResponse, future_remove);
}

} // namespace nebula::storage
7 changes: 7 additions & 0 deletions src/graph/optimizer/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ set(OPTIMIZER_TEST_LIB
$<TARGET_OBJECTS:storage_client_stats_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(OPTIMIZER_TEST_LIB
${OPTIMIZER_TEST_LIB}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_test(
NAME
index_scan_rule_test
Expand Down
14 changes: 13 additions & 1 deletion src/graph/planner/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
#
# This source code is licensed under Apache 2.0 License.

set(EXEC_PLAN_TEST_FLAG_DEPS
$<TARGET_OBJECTS:graph_flags_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(EXEC_PLAN_TEST_FLAG_DEPS
${EXEC_PLAN_TEST_FLAG_DEPS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
$<TARGET_OBJECTS:storage_local_server_obj>
)
endif()

nebula_add_test(
NAME execution_plan_test
SOURCES
Expand Down Expand Up @@ -39,7 +51,7 @@ nebula_add_test(
$<TARGET_OBJECTS:version_obj>
$<TARGET_OBJECTS:query_engine_obj>
$<TARGET_OBJECTS:graph_session_obj>
$<TARGET_OBJECTS:graph_flags_obj>
${EXEC_PLAN_TEST_FLAG_DEPS}
$<TARGET_OBJECTS:parser_obj>
$<TARGET_OBJECTS:validator_obj>
$<TARGET_OBJECTS:expr_visitor_obj>
Expand Down
1 change: 1 addition & 0 deletions src/graph/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ nebula_add_library(
CloudAuthenticator.cpp
)

nebula_add_subdirectory(test)
10 changes: 10 additions & 0 deletions src/graph/service/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.

# note: These flags is used for standalone version ut.

nebula_add_library(
sa_test_graph_flags_obj OBJECT
StandAloneTestGraphFlags.cpp
)
13 changes: 13 additions & 0 deletions src/graph/service/test/StandAloneTestGraphFlags.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Copyright (c) 2018 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "graph/service/GraphFlags.h"
#include "version/Version.h"

DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
DEFINE_string(client_white_list,
nebula::getOriginVersion() + ":2.5.0:2.5.1:2.6.0",
"A white list for different client versions, separate with colon.");
13 changes: 12 additions & 1 deletion src/graph/util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
set(UTIL_TEST_FLAG_DEPS
$<TARGET_OBJECTS:graph_flags_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(UTIL_TEST_FLAG_DEPS
${UTIL_TEST_FLAG_DEPS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_test(
NAME utils_test
SOURCES
Expand Down Expand Up @@ -38,7 +49,7 @@ nebula_add_test(
$<TARGET_OBJECTS:expr_visitor_obj>
$<TARGET_OBJECTS:graph_session_obj>
$<TARGET_OBJECTS:graph_auth_obj>
$<TARGET_OBJECTS:graph_flags_obj>
${UTIL_TEST_FLAG_DEPS}
$<TARGET_OBJECTS:util_obj>
$<TARGET_OBJECTS:plan_obj>
$<TARGET_OBJECTS:parser_obj>
Expand Down
7 changes: 7 additions & 0 deletions src/graph/validator/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ set(VALIDATOR_TEST_LIBS
$<TARGET_OBJECTS:ssl_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(VALIDATOR_TEST_LIBS
${VALIDATOR_TEST_LIBS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_test(
NAME
validator_test
Expand Down
13 changes: 12 additions & 1 deletion src/graph/visitor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
#
# This source code is licensed under Apache 2.0 License.

set(EXPR_FLAG_DEPS
$<TARGET_OBJECTS:graph_flags_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(EXPR_FLAG_DEPS
${EXPR_FLAG_DEPS}
$<TARGET_OBJECTS:sa_test_graph_flags_obj>
)
endif()

nebula_add_test(
NAME
expr_visitor_test
Expand All @@ -21,7 +32,7 @@ nebula_add_test(
$<TARGET_OBJECTS:plan_obj>
$<TARGET_OBJECTS:planner_obj>
$<TARGET_OBJECTS:graph_session_obj>
$<TARGET_OBJECTS:graph_flags_obj>
${EXPR_FLAG_DEPS}
$<TARGET_OBJECTS:parser_obj>
$<TARGET_OBJECTS:idgenerator_obj>
$<TARGET_OBJECTS:graph_context_obj>
Expand Down
7 changes: 7 additions & 0 deletions src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ set(meta_test_deps
$<TARGET_OBJECTS:storage_stats_obj>
)

if(ENABLE_STANDALONE_VERSION)
set(meta_test_deps
${meta_test_deps}
$<TARGET_OBJECTS:storage_local_server_obj>
)
endif()

nebula_add_subdirectory(http)
nebula_add_subdirectory(test)
nebula_add_subdirectory(upgrade)
Expand Down
Loading