Skip to content

Commit

Permalink
fix grin test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglei1949 committed Sep 12, 2023
1 parent 21d1e22 commit c776861
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 71 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/flex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ jobs:
cd flex/engines/graph_db/grin
mkdir build && cd build
cmake .. && sudo make -j$(nproc)
export FLEX_DATA_DIR=../../../../storages/rt_mutable_graph/modern_graph/
./run_grin_test flex://../../../../interactive/examples/modern_graph/ \
../../../../interactive/examples/modern_graph/modern_graph.yaml \
../../../../interactive/examples/modern_graph/bulk_load.yaml
export FLEX_DATA_DIR=../../../../interactive/examples/modern_graph/
./run_grin_test 'flex://schema_file=../../../../interactive/examples/modern_graph/modern_graph.yaml&bulk_load_file=../../../../interactive/examples/modern_graph/bulk_load.yaml'
- name: Test Graph Loading on modern graph
env:
Expand Down
33 changes: 28 additions & 5 deletions flex/engines/graph_db/grin/src/topology/structure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ limitations under the License.
* flex://{path_to_yaml}
* @return A graph handle.
*/
GRIN_GRAPH grin_get_graph_from_storage(const char* uri, const char* schema_file,
const char* bulk_load_file) {
GRIN_GRAPH grin_get_graph_from_storage(const char* uri) {
std::string _uri(uri);
std::string::size_type pos = _uri.find("://");
if (pos == std::string::npos) {
Expand All @@ -36,9 +35,33 @@ GRIN_GRAPH grin_get_graph_from_storage(const char* uri, const char* schema_file,
return GRIN_NULL_GRAPH;
}
_uri = _uri.substr(pos + 3);
std::string graph_schema_path = schema_file;
std::string data_path = uri;
std::string bulk_load_config_path = bulk_load_file;
LOG(INFO) << "Params: " << _uri;
std::string graph_schema_path, bulk_load_config_path;
if (pos != std::string::npos) {
auto params = _uri;
std::vector<std::string> param_list;
boost::split(param_list, params, boost::is_any_of("&"));
for (auto& param : param_list) {
std::vector<std::string> kv;
boost::split(kv, param, boost::is_any_of("="));
if (kv.size() != 2) {
return GRIN_NULL_GRAPH;
}
if (kv[0] == "schema_file") {
graph_schema_path = kv[1];
} else if (kv[0] == "bulk_load_file") {
bulk_load_config_path = kv[1];
}
}
} else {
return GRIN_NULL_GRAPH;
}
VLOG(10) << "Schema file: " << graph_schema_path;
VLOG(10) << "Bulk load file: " << bulk_load_config_path;
if (graph_schema_path.empty() || bulk_load_config_path.empty()) {
return GRIN_NULL_GRAPH;
}
// get schema_file from
if (!std::filesystem::exists(graph_schema_path) ||
!(std::filesystem::exists(bulk_load_config_path))) {
return GRIN_NULL_GRAPH;
Expand Down
110 changes: 48 additions & 62 deletions flex/engines/graph_db/grin/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ const char* v_names[][4] = {{"josh", "vadas", "peter", "marko"},
{"lop", "ripple", "wrong",
"wrong"}}; // TODO align with order in local graph

GRIN_GRAPH get_graph(const char* uri_str, const char* schema_file,
const char* bulk_load_file, int p) {
GRIN_GRAPH get_graph(const char* uri_str, int p) {
#ifdef GRIN_ENABLE_GRAPH_PARTITION
GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]);
GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg);
Expand All @@ -145,7 +144,7 @@ GRIN_GRAPH get_graph(const char* uri_str, const char* schema_file,
grin_destroy_partition_list(pg, local_partitions);
grin_destroy_partitioned_graph(pg);
#else
GRIN_GRAPH g = grin_get_graph_from_storage(uri_str, schema_file, bulk_load_file);
GRIN_GRAPH g = grin_get_graph_from_storage(uri_str);
#endif
return g;
}
Expand Down Expand Up @@ -182,11 +181,10 @@ GRIN_VERTEX get_one_person(GRIN_GRAPH g) {
return v;
}

void test_property_type(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_property_type(const char* uri_str) {
printf("+++++++++++++++++++++ Test property/type +++++++++++++++++++++\n");

GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

printf("------------ Vertex Type ------------\n");
GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g);
Expand Down Expand Up @@ -336,11 +334,9 @@ void test_property_type(const char* uri_str, const char* schema_file,
grin_destroy_graph(g);
}

void test_property_vertex_property_value(const char* uri_str,
const char* schema_file,
const char* bulk_load_file) {
void test_property_vertex_property_value(const char* uri_str) {
printf("------------ Test Vertex property value ------------\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

// value check
printf("------ check value ------\n");
Expand Down Expand Up @@ -473,11 +469,9 @@ void test_property_vertex_property_value(const char* uri_str,
}

void test_property_edge_property_value(const char* uri_str,
const char* schema_file,
const char* bulk_load_file,
GRIN_DIRECTION dir) {
printf("------------ Test Edge property value ------------\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

// value check
printf("------ check value ------\n");
Expand Down Expand Up @@ -632,11 +626,11 @@ void test_property_edge_property_value(const char* uri_str,
}

#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
void test_property_primary_key(const char* uri_str, const char*schema_file, const char* bulk_load_file) {
void test_property_primary_key(const char* uri_str) {
printf(
"+++++++++++++++++++++ Test property/primary key "
"+++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);
GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_types_with_primary_keys(g);
size_t vtl_size = grin_get_vertex_type_list_size(g, vtl);
printf("vertex type num with primary key: %zu\n", vtl_size);
Expand Down Expand Up @@ -689,9 +683,9 @@ void test_property_primary_key(const char* uri_str, const char*schema_file, cons
}
#endif

void test_error_code(const char* uri_str,const char* schema_file, const char* bulk_load_file) {
void test_error_code(const char* uri_str) {
printf("+++++++++++++++++++++ Test error code +++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_by_name(g, "person");
GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "software");
Expand All @@ -706,17 +700,16 @@ void test_error_code(const char* uri_str,const char* schema_file, const char* bu
assert(grin_get_last_error_code() == INVALID_VALUE);
}

void test_property(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
test_property_type(uri_str, schema_file, bulk_load_file);
test_property_vertex_property_value(uri_str, schema_file, bulk_load_file);
test_property_edge_property_value(uri_str, schema_file, bulk_load_file, OUT);
test_property_edge_property_value(uri_str, schema_file, bulk_load_file, IN);
void test_property(const char* uri_str) {
test_property_type(uri_str);
test_property_vertex_property_value(uri_str);
test_property_edge_property_value(uri_str, OUT);
test_property_edge_property_value(uri_str, IN);
#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
test_property_primary_key(uri_str,schema_file, bulk_load_file);
test_property_primary_key(uri_str);
#endif
#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME
test_error_code(uri_str,schema_file, bulk_load_file);
test_error_code(uri_str);
#endif
}
/**
Expand Down Expand Up @@ -834,11 +827,10 @@ void test_partition(const char* uri_str) {
#endif
}
*/
void test_topology_structure(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_topology_structure(const char* uri_str) {
printf(
"+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);
#ifndef GRIN_WITH_VERTEX_PROPERTY
printf("vertex num: %zu\n", grin_get_vertex_num(g));
#endif
Expand All @@ -849,12 +841,11 @@ void test_topology_structure(const char* uri_str, const char* schema_file,
grin_destroy_graph(g);
}

void test_topology_vertex_list(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_topology_vertex_list(const char* uri_str) {
printf(
"+++++++++++++++++++++ Test topology/vertex_list "
"+++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

FOR_VERTEX_LIST_BEGIN(g, vl)
FOR_VERTEX_BEGIN(g, vl, v)
Expand All @@ -869,8 +860,7 @@ void test_topology_vertex_list(const char* uri_str, const char* schema_file,
grin_destroy_graph(g);
}

void test_topology_adjacent_list(const char* uri_str, const char* schema_file,
const char* bulk_load_file, GRIN_DIRECTION dir) {
void test_topology_adjacent_list(const char* uri_str, GRIN_DIRECTION dir) {
if (dir == IN) {
printf(
"+++++++++++++++++++++ Test topology/adjacent_list IN "
Expand All @@ -881,7 +871,7 @@ void test_topology_adjacent_list(const char* uri_str, const char* schema_file,
"+++++++++++++++++++++\n");
}

GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

FOR_VERTEX_LIST_BEGIN(g, vl)
FOR_VERTEX_BEGIN(g, vl, v)
Expand Down Expand Up @@ -948,20 +938,18 @@ void test_topology_adjacent_list(const char* uri_str, const char* schema_file,
grin_destroy_graph(g);
}

void test_topology(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
test_topology_structure(uri_str, schema_file, bulk_load_file);
test_topology_vertex_list(uri_str, schema_file, bulk_load_file);
test_topology_adjacent_list(uri_str, schema_file, bulk_load_file, OUT);
test_topology_adjacent_list(uri_str, schema_file, bulk_load_file, IN);
void test_topology(const char* uri_str) {
test_topology_structure(uri_str);
test_topology_vertex_list(uri_str);
test_topology_adjacent_list(uri_str, OUT);
test_topology_adjacent_list(uri_str, IN);
}

#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && \
defined(GRIN_ENABLE_VERTEX_LIST_ARRAY)
void test_index_order(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_index_order(const char* uri_str) {
printf("+++++++++++++++++++++ Test index order +++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

FOR_VERTEX_LIST_BEGIN(g, vl)
FOR_VERTEX_BEGIN(g, vl, v)
Expand Down Expand Up @@ -1008,11 +996,10 @@ void test_index_order(const char* uri_str, const char* schema_file,
}
#endif

void test_index_internal_id(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_index_internal_id(const char* uri_str) {
printf(
"+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
GRIN_GRAPH g = get_graph(uri_str, 0);

FOR_VERTEX_LIST_BEGIN(g, vl)
long long int min = grin_get_vertex_internal_id_lower_bound_by_type(g, __vt);
Expand All @@ -1031,19 +1018,18 @@ void test_index_internal_id(const char* uri_str, const char* schema_file,
grin_destroy_graph(g);
}

void test_index(const char* uri_str, const char* schema_file,
const char* bulk_load_file) {
void test_index(const char* uri_str) {
#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && \
defined(GRIN_ENABLE_VERTEX_LIST_ARRAY)
test_index_order(uri_str, schema_file, bulk_load_file);
test_index_order(uri_str);
#endif
#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX
test_index_internal_id(uri_str, schema_file, bulk_load_file);
test_index_internal_id(uri_str);
#endif
}

void test_vertex_property_value(const char* uri_str, const char* schema_file,const char* bulk_load_file) {
GRIN_GRAPH g = get_graph(uri_str, schema_file,bulk_load_file, 0);
void test_vertex_property_value(const char* uri_str) {
GRIN_GRAPH g = get_graph(uri_str, 0);
GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person");
GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt, "age");
GRIN_VERTEX v = get_one_person(g);
Expand All @@ -1063,23 +1049,23 @@ void test_vertex_property_value(const char* uri_str, const char* schema_file,con
grin_destroy_graph(g);
}

void test_perf(const char* uri_str,const char* schema_file,const char* bulk_load_file) { test_vertex_property_value(uri_str, schema_file, bulk_load_file); }
void test_perf(const char* uri_str) { test_vertex_property_value(uri_str); }
// uri_str =
//"flex://"
// "../../../../storages/rt_mutable_graph/modern_graph/";
// "../../../../storages/rt_mutable_graph/modern_graph/?schema_file={schema_file}&bulk_load_file={bulk_load_file}";
int main(int argc, char** argv) {
if (argc != 4) {
printf("Usage: %s <uri> <schema> <bulk_load_file>\n", argv[0]);
if (argc != 2) {
printf("Usage: %s <uri>\n", argv[0]);
return 1;
}
const char* uri_str = argv[1];
const char* schema_file = argv[2];
const char* bulk_load_file = argv[3];
//print uri
printf("uri: %s\n", uri_str);

test_index(uri_str, schema_file, bulk_load_file);
test_property(uri_str, schema_file, bulk_load_file);
test_index(uri_str);
test_property(uri_str);
// test_partition(uri_str);
test_topology(uri_str, schema_file, bulk_load_file);
test_perf(uri_str, schema_file, bulk_load_file);
test_topology(uri_str);
test_perf(uri_str);
return 0;
}

0 comments on commit c776861

Please sign in to comment.