diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b3c730b1..b37c40e50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,12 +134,9 @@ foreach(file_path ${__HARDCODED_FILES}) get_filename_component(file_name ${file_path} NAME) configure_file(${file_path} ${CMAKE_BINARY_DIR}/tests/integration/hardcoded_query/${file_name} COPYONLY) endforeach() -file(GLOB __STREAM - ${CMAKE_SOURCE_DIR}/tests/integration/stream/*) -foreach(file_path ${__STREAM}) - get_filename_component(file_name ${file_path} NAME) - configure_file(${file_path} ${CMAKE_BINARY_DIR}/tests/integration/stream/${file_name} COPYONLY) -endforeach() +set(print_record_stream_path ${CMAKE_SOURCE_DIR}/tests/integration/print_record_stream.hpp) +get_filename_component(print_record_stream_file_name ${print_record_stream_path} NAME) +configure_file(${print_record_stream_path} ${CMAKE_BINARY_DIR}/tests/integration/${print_record_stream_file_name} COPYONLY) # ----------------------------------------------------------------------------- # linter setup (clang-tidy) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/integration/crud.py b/tests/integration/crud.py deleted file mode 100644 index f542944d9..000000000 --- a/tests/integration/crud.py +++ /dev/null @@ -1,48 +0,0 @@ -from neo4j.v1 import GraphDatabase, basic_auth, types - -# create session -driver = GraphDatabase.driver("bolt://localhost", - auth=basic_auth("neo4j", "neo4j"), - encrypted=0) -session = driver.session() - -queries = []; - -queries.append((True, "CREATE (n {age: 32}) RETURN n")) -queries.append((True, "CREATE (n {name: \"Max\", age: 21}) RETURN n")) -queries.append((True, "CREATE (n {name: \"Paul\", age: 21}) RETURN n")) -queries.append((True, "CREATE (n:PERSON {name: \"Chris\", age: 20}) RETURN n")) -queries.append((True, "CREATE (n:PERSON:STUDENT {name: \"Marko\", age: 19}) RETURN n")) -queries.append((True, "CREATE (n:TEST {string: \"Properties test\", integer: 100, float: 232.2323, bool: True}) RETURN n")) - -queries.append((True, "MATCH (n) WHERE ID(n)=0 RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=1 RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=2 RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=3 RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=4 RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=5 RETURN n")) -queries.append((True, "MATCH (n) RETURN n")); -queries.append((True, "MATCH (n:PERSON) RETURN n")); - -queries.append((True, "MATCH (n1), (n2) WHERE ID(n1)=0 AND ID(n2)=1 CREATE (n1)-[r:IS]->(n2) RETURN r")) -queries.append((True, "MATCH (n1), (n2) WHERE ID(n1)=1 AND ID(n2)=2 CREATE (n1)-[r:IS {name: \"test\", age: 23}]->(n2) RETURN r")) -queries.append((True, "MATCH (n1), (n2) WHERE ID(n1)=2 AND ID(n2)=0 CREATE (n1)-[r:IS {name: \"test\", age: 23}]->(n2) RETURN r")) -queries.append((True, "MATCH (n1), (n2) WHERE ID(n1)=2 AND ID(n2)=0 CREATE (n1)-[r:ARE {name: \"test\", age: 23}]->(n2) RETURN r")) - -queries.append((True, "MATCH ()-[r]-() WHERE ID(r)=0 RETURN r")) -queries.append((True, "MATCH ()-[r]-() WHERE ID(r)=1 RETURN r")) -queries.append((True, "MATCH ()-[r]-() WHERE ID(r)=2 RETURN r")) -queries.append((True, "MATCH ()-[r:IS]-() RETURN r")) -queries.append((True, "MATCH ()-[r:ARE]-() RETURN r")) -queries.append((True, "MATCH ()-[r]-() RETURN r")) - -queries.append((True, "MATCH (n) WHERE ID(n)=1 SET n.name = \"updated_name\" RETURN n")) -queries.append((True, "MATCH (n) WHERE ID(n)=1 RETURN n")) -queries.append((True, "MATCH ()-[r]-() WHERE ID(r)=1 SET r.name = \"TEST100\" RETURN r")) -queries.append((True, "MATCH ()-[r]-() WHERE ID(r)=1 RETURN r")) - -for i in range(1): - for active, query in queries: - if active: - for record in session.run(query): - print(record) diff --git a/tests/integration/hardcoded_query/using.hpp b/tests/integration/hardcoded_query/using.hpp index 67dc43488..6d267f100 100644 --- a/tests/integration/hardcoded_query/using.hpp +++ b/tests/integration/hardcoded_query/using.hpp @@ -8,7 +8,7 @@ using Stream = communication::bolt::ResultStream<communication::bolt::Encoder< communication::bolt::ChunkedEncoderBuffer<io::network::Socket>>>; #else -#include "../stream/print_record_stream.hpp" +#include "../print_record_stream.hpp" using Stream = PrintRecordStream; #endif #include "data_structures/bitset/static_bitset.hpp" diff --git a/tests/integration/stream/print_record_stream.hpp b/tests/integration/print_record_stream.hpp similarity index 100% rename from tests/integration/stream/print_record_stream.hpp rename to tests/integration/print_record_stream.hpp diff --git a/tests/integration/query_engine_common.hpp b/tests/integration/query_engine_common.hpp index 3db544501..bcdbe3be4 100644 --- a/tests/integration/query_engine_common.hpp +++ b/tests/integration/query_engine_common.hpp @@ -7,11 +7,11 @@ namespace fs = std::experimental::filesystem; #include <gflags/gflags.h> #include <glog/logging.h> -#include "database/graph_db_accessor.hpp" #include "database/dbms.hpp" +#include "database/graph_db_accessor.hpp" +#include "print_record_stream.hpp" #include "query/engine.hpp" #include "query/frontend/stripped.hpp" -#include "stream/print_record_stream.hpp" #include "utils/file.hpp" #include "utils/string.hpp" diff --git a/tests/integration/scenario.py b/tests/integration/scenario.py deleted file mode 100644 index b2f39f119..000000000 --- a/tests/integration/scenario.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import logging - -# TODO: auto import -# TODO: better logging (scenario visibility) -# TODO: result storage -from scenario import no_000001, no_000002 -from neo4j.v1 import GraphDatabase, basic_auth, types, Node - -# scenarios = [no_000001.scenario_1, no_000002.scenario_2] -scenarios = [no_000002.scenario_2] - -# logging init -log = logging.getLogger(__name__) - -# initialize driver and create session -session = GraphDatabase.driver("bolt://localhost", - auth=basic_auth("neo4j", "1234"), - encrypted=0).session() - - -def check(condition, scenario_no, message): - ''' - Checks condition if condition is false the whole test will be stopped and - scenario_no + message will be printed out. - - :param condition: bool - :param scenario_no: int - :param message: assert message - :returns: None - ''' - if not condition: - log.error("Error in scenario: %s" % scenario_no) - assert condition, message - - -if __name__ == "__main__": - - logging.basicConfig(level=logging.DEBUG) - - for scenario in scenarios: - - # iterate through all queries and execute them agains the database - for query, result in scenario.queries: - - # extract count and properties from test entries - count, expected = result - records = [record for record in session.run(query)] - - log.info("%s" % records) - - # check count - check(len(records) == count, scenario.no, - "Number of results for %s isn't good;" \ - " expected: %s, got %s" % (query, count, len(records))) - - # in case that the result is single - if count == 1: - - # extract properties from record - record = records[0] - record_name, = record - data = record[record_name] - - if type(data) is Node: - received = {k: v for (k, v) in data.items()} - else: - received = data - - # get expected elements - expected = expected[0] - - # check properties - check(expected == received, scenario.no, - "Received data for %s isn't OK; expected: %s, " \ - "got %s" % (query, expected, received)) - - elif count > 1: - # TODO: implement the full test - pass diff --git a/tests/integration/scenario/__init__.py b/tests/integration/scenario/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/integration/scenario/no_000001.py b/tests/integration/scenario/no_000001.py deleted file mode 100644 index 0555264ab..000000000 --- a/tests/integration/scenario/no_000001.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -__author__ = "Marko Budiselic" -__date__ = "2016_11_02" - -class Scenario1: - ''' - Create Match Retrun Sequence - ''' - - def __init__(self): - ''' - Constructor - ''' - self.no = 1 - self.desctiption = "Create Match Retrun Sequence" - self.init_graph = [] - self.queries = [ - ("MATCH (n) DETACH DELETE n", (0, None)), - ("MATCH (n) RETURN n", (0, [])), - ("CREATE (n:Label) RETURN n", (1, [{}])), - ("MATCH (n) RETURN n", (1, [{}])), - ("CREATE (n:Label {prop: 0}) RETURN n", (1, [{"prop": 0}])), - ("MATCH (n) RETURN n", (2, [{}, {"prop": 0}])), - ("CREATE (n:Label {prop: 1}) RETURN n", (1, [{"prop": 1}])), - ("MATCH (n) RETURN n", (3, [{}, {"prop": 0}, {"prop": 1}])), - ("CREATE (n {prop: 1}) RETURN n", (1, [{"prop": 1}])), - ("MATCH (n) RETURN n", (4, [{}, {"prop": 0}, {"prop": 1}, {"prop": 0}])), - ("MATCH (n:Label) RETURN n", (3, [{}, {"prop": 0}, {"prop": 1}])), - ("MATCH (n:Label {prop: 0}) RETURN n", (1, [{"prop": 0}])), - ] - self.side_effects = None - -scenario_1 = Scenario1() diff --git a/tests/integration/scenario/no_000002.py b/tests/integration/scenario/no_000002.py deleted file mode 100644 index 8befeed63..000000000 --- a/tests/integration/scenario/no_000002.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -__author__ = "Marko Budiselic" -__date__ = "2016_11_03" - -class Scenario2: - ''' - Create node, edit labels and return all labels for the node. - ''' - - def __init__(self): - ''' - Constructor - ''' - self.no = 2 - self.desctiption = "Create node, edit labels and return all labels for the node." - self.init_graph = [] - self.queries = [ - ("MATCH (n) DETACH DELETE n", (0, None)), - ("CREATE (n:Garment {garment_id: 1234, garment_category_id: 1}) RETURN n", (1, [{"garment_id": 1234, "garment_category_id": 1}])), - ("MATCH (g:Garment {garment_id: 1234}) SET g:FF RETURN labels(g)", (1, [["Garment", "FF"]])), - ("MATCH(g:Garment {garment_id: 1234}) SET g.reveals = 50 RETURN g", (1, [{"garment_id": 1234, "garment_category_id": 1, "reveals": 50}])), - ("MATCH (n) RETURN n", (1, [{"garment_id": 1234, "garment_category_id": 1, "reveals": 50}])), - ] - self.side_effects = None - -scenario_2 = Scenario2()