Migrate leftover tests away from old storage
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2590
This commit is contained in:
parent
dd68065d34
commit
1aadebbb70
@ -31,7 +31,7 @@ add_benchmark(data_structures/concurrent/map_concurrent.cpp)
|
||||
target_link_libraries(${test_prefix}map_concurrent mg-single-node kvstore_dummy_lib)
|
||||
|
||||
add_benchmark(data_structures/ring_buffer.cpp)
|
||||
target_link_libraries(${test_prefix}ring_buffer mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}ring_buffer mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
|
||||
add_benchmark(query/eval.cpp)
|
||||
target_link_libraries(${test_prefix}eval mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
|
@ -30,16 +30,16 @@ add_concurrent_test(dynamic_bitset_set_n.cpp)
|
||||
target_link_libraries(${test_prefix}dynamic_bitset_set_n mg-single-node kvstore_dummy_lib)
|
||||
|
||||
add_concurrent_test(network_read_hang.cpp)
|
||||
target_link_libraries(${test_prefix}network_read_hang mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}network_read_hang mg-communication)
|
||||
|
||||
add_concurrent_test(network_server.cpp)
|
||||
target_link_libraries(${test_prefix}network_server mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}network_server mg-communication)
|
||||
|
||||
add_concurrent_test(network_session_leak.cpp)
|
||||
target_link_libraries(${test_prefix}network_session_leak mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}network_session_leak mg-communication)
|
||||
|
||||
add_concurrent_test(push_queue.cpp)
|
||||
target_link_libraries(${test_prefix}push_queue mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}push_queue glog gflags Threads::Threads)
|
||||
|
||||
add_concurrent_test(stack.cpp)
|
||||
target_link_libraries(${test_prefix}stack mg-utils)
|
||||
@ -92,5 +92,5 @@ target_link_libraries(${test_prefix}sl_set mg-single-node kvstore_dummy_lib)
|
||||
add_concurrent_test(sl_simulation.cpp)
|
||||
target_link_libraries(${test_prefix}sl_simulation mg-single-node kvstore_dummy_lib)
|
||||
|
||||
add_concurrent_test(spinlock.cpp)
|
||||
target_link_libraries(${test_prefix}spinlock mg-single-node kvstore_dummy_lib)
|
||||
add_concurrent_test(spin_lock.cpp)
|
||||
target_link_libraries(${test_prefix}spin_lock mg-utils)
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "communication/server.hpp"
|
||||
#include "database/single_node/graph_db_accessor.hpp"
|
||||
|
||||
static constexpr const int SIZE = 60000;
|
||||
static constexpr const int REPLY = 10;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "communication/server.hpp"
|
||||
#include "database/single_node/graph_db_accessor.hpp"
|
||||
|
||||
static constexpr const char interface[] = "127.0.0.1";
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "utils/thread/sync.hpp"
|
||||
#include "utils/spin_lock.hpp"
|
||||
|
||||
int x = 0;
|
||||
utils::SpinLock lock;
|
@ -41,16 +41,16 @@ add_manual_test(kvstore_console.cpp)
|
||||
target_link_libraries(${test_prefix}kvstore_console kvstore_lib gflags glog)
|
||||
|
||||
add_manual_test(query_hash.cpp)
|
||||
target_link_libraries(${test_prefix}query_hash mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}query_hash mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
|
||||
add_manual_test(query_planner.cpp interactive_planning.cpp)
|
||||
target_link_libraries(${test_prefix}query_planner mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}query_planner mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
if (READLINE_FOUND)
|
||||
target_link_libraries(${test_prefix}query_planner readline)
|
||||
endif()
|
||||
|
||||
add_manual_test(expression_pretty_printer.cpp)
|
||||
target_link_libraries(${test_prefix}expression_pretty_printer mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}expression_pretty_printer mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
|
||||
add_manual_test(single_query.cpp)
|
||||
target_link_libraries(${test_prefix}single_query mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
@ -62,7 +62,7 @@ add_manual_test(snapshot_explorer.cpp)
|
||||
target_link_libraries(${test_prefix}snapshot_explorer mg-single-node kvstore_dummy_lib)
|
||||
|
||||
add_manual_test(stripped_timing.cpp)
|
||||
target_link_libraries(${test_prefix}stripped_timing mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}stripped_timing mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
|
||||
add_manual_test(ssl_client.cpp)
|
||||
target_link_libraries(${test_prefix}ssl_client mg-communication)
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <gflags/gflags.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "query/context.hpp"
|
||||
#include "query/db_accessor.hpp"
|
||||
#include "query/frontend/ast/cypher_main_visitor.hpp"
|
||||
#include "query/frontend/opencypher/parser.hpp"
|
||||
#include "query/frontend/semantic/symbol_generator.hpp"
|
||||
@ -129,18 +129,22 @@ class Timer {
|
||||
// Dummy DbAccessor which forwards user input for various vertex counts.
|
||||
class InteractiveDbAccessor {
|
||||
public:
|
||||
InteractiveDbAccessor(database::GraphDbAccessor *dba, int64_t vertices_count,
|
||||
InteractiveDbAccessor(query::DbAccessor *dba, int64_t vertices_count,
|
||||
Timer &timer)
|
||||
: dba_(dba), vertices_count_(vertices_count), timer_(timer) {}
|
||||
|
||||
auto NameToLabel(const std::string &name) { return dba_->Label(name); }
|
||||
auto NameToProperty(const std::string &name) { return dba_->Property(name); }
|
||||
auto NameToEdgeType(const std::string &name) { return dba_->EdgeType(name); }
|
||||
auto NameToLabel(const std::string &name) { return dba_->NameToLabel(name); }
|
||||
auto NameToProperty(const std::string &name) {
|
||||
return dba_->NameToProperty(name);
|
||||
}
|
||||
auto NameToEdgeType(const std::string &name) {
|
||||
return dba_->NameToEdgeType(name);
|
||||
}
|
||||
|
||||
int64_t VerticesCount() { return vertices_count_; }
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id) {
|
||||
auto label = dba_->LabelName(label_id);
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
if (label_vertex_count_.find(label) == label_vertex_count_.end()) {
|
||||
label_vertex_count_[label] = ReadVertexCount("label '" + label + "'");
|
||||
}
|
||||
@ -149,8 +153,8 @@ class InteractiveDbAccessor {
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id,
|
||||
storage::Property property_id) {
|
||||
auto label = dba_->LabelName(label_id);
|
||||
auto property = dba_->PropertyName(property_id);
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
if (label_property_vertex_count_.find(key) ==
|
||||
label_property_vertex_count_.end()) {
|
||||
@ -162,8 +166,8 @@ class InteractiveDbAccessor {
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id, storage::Property property_id,
|
||||
const PropertyValue &value) {
|
||||
auto label = dba_->LabelName(label_id);
|
||||
auto property = dba_->PropertyName(property_id);
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto label_prop = std::make_pair(label, property);
|
||||
if (label_property_index_.find(label_prop) == label_property_index_.end()) {
|
||||
return 0;
|
||||
@ -183,8 +187,8 @@ class InteractiveDbAccessor {
|
||||
storage::Label label_id, storage::Property property_id,
|
||||
const std::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::optional<utils::Bound<PropertyValue>> upper) {
|
||||
auto label = dba_->LabelName(label_id);
|
||||
auto property = dba_->PropertyName(property_id);
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
std::stringstream range_string;
|
||||
if (lower) {
|
||||
range_string << (lower->IsInclusive() ? "[" : "(") << lower->value()
|
||||
@ -203,8 +207,8 @@ class InteractiveDbAccessor {
|
||||
|
||||
bool LabelPropertyIndexExists(storage::Label label_id,
|
||||
storage::Property property_id) {
|
||||
auto label = dba_->LabelName(label_id);
|
||||
auto property = dba_->PropertyName(property_id);
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
if (label_property_index_.find(key) == label_property_index_.end()) {
|
||||
bool resp = timer_.WithPause([&label, &property]() {
|
||||
@ -317,7 +321,7 @@ class InteractiveDbAccessor {
|
||||
private:
|
||||
typedef std::pair<std::string, std::string> LabelPropertyKey;
|
||||
|
||||
database::GraphDbAccessor *dba_;
|
||||
query::DbAccessor *dba_;
|
||||
int64_t vertices_count_;
|
||||
Timer &timer_;
|
||||
std::map<std::string, int64_t> label_vertex_count_;
|
||||
@ -367,8 +371,7 @@ DEFCOMMAND(Top) {
|
||||
for (int64_t i = 0; i < n_plans; ++i) {
|
||||
std::cout << "---- Plan #" << i << " ---- " << std::endl;
|
||||
std::cout << "cost: " << plans[i].cost << std::endl;
|
||||
query::DbAccessor query_dba(&dba);
|
||||
query::plan::PrettyPrint(query_dba, plans[i].final_plan.get());
|
||||
query::plan::PrettyPrint(dba, plans[i].final_plan.get());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
@ -381,8 +384,7 @@ DEFCOMMAND(Show) {
|
||||
const auto &plan = plans[plan_ix].final_plan;
|
||||
auto cost = plans[plan_ix].cost;
|
||||
std::cout << "Plan cost: " << cost << std::endl;
|
||||
query::DbAccessor query_dba(&dba);
|
||||
query::plan::PrettyPrint(query_dba, plan.get());
|
||||
query::plan::PrettyPrint(dba, plan.get());
|
||||
}
|
||||
|
||||
DEFCOMMAND(ShowUnoptimized) {
|
||||
@ -391,8 +393,7 @@ DEFCOMMAND(ShowUnoptimized) {
|
||||
ss >> plan_ix;
|
||||
if (ss.fail() || !ss.eof() || plan_ix >= plans.size()) return;
|
||||
const auto &plan = plans[plan_ix].unoptimized_plan;
|
||||
query::DbAccessor query_dba(&dba);
|
||||
query::plan::PrettyPrint(query_dba, plan.get());
|
||||
query::plan::PrettyPrint(dba, plan.get());
|
||||
}
|
||||
|
||||
DEFCOMMAND(Help);
|
||||
@ -421,7 +422,7 @@ DEFCOMMAND(Help) {
|
||||
}
|
||||
}
|
||||
|
||||
void ExaminePlans(database::GraphDbAccessor &dba,
|
||||
void ExaminePlans(query::DbAccessor *dba,
|
||||
const query::SymbolTable &symbol_table,
|
||||
std::vector<InteractivePlan> &plans,
|
||||
const query::AstStorage &ast) {
|
||||
@ -444,7 +445,7 @@ void ExaminePlans(database::GraphDbAccessor &dba,
|
||||
<< " arguments" << std::endl;
|
||||
continue;
|
||||
}
|
||||
command.function(dba, symbol_table, plans, args, ast);
|
||||
command.function(*dba, symbol_table, plans, args, ast);
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +492,7 @@ auto MakeLogicalPlans(query::CypherQuery *query, query::AstStorage &ast,
|
||||
return interactive_plans;
|
||||
}
|
||||
|
||||
void RunInteractivePlanning(database::GraphDbAccessor *dba) {
|
||||
void RunInteractivePlanning(query::DbAccessor *dba) {
|
||||
std::string in_db_filename(utils::Trim(FLAGS_load_mock_db_file));
|
||||
if (!in_db_filename.empty() && !std::filesystem::exists(in_db_filename)) {
|
||||
std::cerr << "File '" << in_db_filename << "' does not exist!" << std::endl;
|
||||
@ -526,7 +527,7 @@ void RunInteractivePlanning(database::GraphDbAccessor *dba) {
|
||||
<< std::chrono::duration<double, std::milli>(planning_time).count()
|
||||
<< "ms" << std::endl;
|
||||
std::cout << "Generated " << plans.size() << " plans" << std::endl;
|
||||
ExaminePlans(*dba, symbol_table, plans, ast);
|
||||
ExaminePlans(dba, symbol_table, plans, ast);
|
||||
} catch (const utils::BasicException &e) {
|
||||
std::cout << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "query/db_accessor.hpp"
|
||||
#include "query/frontend/semantic/symbol_table.hpp"
|
||||
#include "query/plan/operator.hpp"
|
||||
|
||||
@ -30,7 +31,7 @@ typedef std::vector<InteractivePlan> PlansWithCost;
|
||||
struct Command {
|
||||
typedef std::vector<std::string> Args;
|
||||
// Function of this command
|
||||
std::function<void(database::GraphDbAccessor &, const query::SymbolTable &,
|
||||
std::function<void(query::DbAccessor &, const query::SymbolTable &,
|
||||
PlansWithCost &, const Args &, const query::AstStorage &)>
|
||||
function;
|
||||
// Number of arguments the function works with.
|
||||
@ -40,11 +41,11 @@ struct Command {
|
||||
};
|
||||
|
||||
#define DEFCOMMAND(Name) \
|
||||
void Name##Command(database::GraphDbAccessor &dba, \
|
||||
void Name##Command(query::DbAccessor &dba, \
|
||||
const query::SymbolTable &symbol_table, \
|
||||
PlansWithCost &plans, const Command::Args &args, \
|
||||
const query::AstStorage &ast_storage)
|
||||
|
||||
void AddCommand(const std::string &name, const Command &command);
|
||||
|
||||
void RunInteractivePlanning(database::GraphDbAccessor *dba);
|
||||
void RunInteractivePlanning(query::DbAccessor *dba);
|
||||
|
@ -3,8 +3,7 @@
|
||||
#include <gflags/gflags.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "database/single_node/graph_db.hpp"
|
||||
#include "database/single_node/graph_db_accessor.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
|
||||
DECLARE_int32(min_log_level);
|
||||
|
||||
@ -12,8 +11,9 @@ int main(int argc, char *argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
FLAGS_min_log_level = google::ERROR;
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
database::GraphDb db;
|
||||
auto dba = db.Access();
|
||||
storage::Storage db;
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
RunInteractivePlanning(&dba);
|
||||
return 0;
|
||||
}
|
||||
|
@ -145,11 +145,11 @@ target_link_libraries(${test_prefix}query_plan mg-single-node-v2 mg-auth kvstore
|
||||
|
||||
# Test query/procedure
|
||||
add_unit_test(query_procedure_mgp_type.cpp)
|
||||
target_link_libraries(${test_prefix}query_procedure_mgp_type mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}query_procedure_mgp_type mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
target_include_directories(${test_prefix}query_procedure_mgp_type PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
add_unit_test(query_procedure_mgp_module.cpp)
|
||||
target_link_libraries(${test_prefix}query_procedure_mgp_module mg-single-node kvstore_dummy_lib)
|
||||
target_link_libraries(${test_prefix}query_procedure_mgp_module mg-single-node-v2 mg-auth kvstore_dummy_lib)
|
||||
target_include_directories(${test_prefix}query_procedure_mgp_module PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
# END query/procedure
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user