From 7fbf5857f229053680104595ead1bd892cf5e8d4 Mon Sep 17 00:00:00 2001 From: Aidar Samerkhanov Date: Tue, 10 Oct 2023 09:27:11 +0300 Subject: [PATCH] Add GQL behave tests for on-disk storage (#1238) --- .github/workflows/diff.yaml | 4 +- src/query/db_accessor.hpp | 2 + tests/e2e/run.sh | 2 - tests/gql_behave/README.md | 2 + tests/gql_behave/continuous_integration | 52 ++++++++++++++----------- tests/gql_behave/run.py | 32 +++++++-------- tests/gql_behave/tests/config.yaml | 24 ++++++++++++ tests/setup.sh | 3 +- 8 files changed, 75 insertions(+), 46 deletions(-) diff --git a/.github/workflows/diff.yaml b/.github/workflows/diff.yaml index 08be26907..40ee3e7dd 100644 --- a/.github/workflows/diff.yaml +++ b/.github/workflows/diff.yaml @@ -249,7 +249,9 @@ jobs: - name: Run GQL Behave tests run: | - cd tests/gql_behave + cd tests + ./setup.sh /opt/toolchain-v4/activate + cd gql_behave ./continuous_integration - name: Save quality assurance status diff --git a/src/query/db_accessor.hpp b/src/query/db_accessor.hpp index 4e8c6f220..102fe5d4c 100644 --- a/src/query/db_accessor.hpp +++ b/src/query/db_accessor.hpp @@ -459,6 +459,8 @@ class DbAccessor final { } storage::Result> RemoveVertex(VertexAccessor *vertex_accessor) { + accessor_->PrefetchOutEdges(vertex_accessor->impl_); + accessor_->PrefetchInEdges(vertex_accessor->impl_); auto res = accessor_->DeleteVertex(&vertex_accessor->impl_); if (res.HasError()) { return res.GetError(); diff --git a/tests/e2e/run.sh b/tests/e2e/run.sh index e6a2ec1dc..1aba6a517 100755 --- a/tests/e2e/run.sh +++ b/tests/e2e/run.sh @@ -1,8 +1,6 @@ #!/bin/bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPT_DIR" -# TODO(gitbuda): Setup mgclient and pymgclient properly. -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../libs/mgclient/lib print_help() { echo -e "$0 ["workload name string"]" diff --git a/tests/gql_behave/README.md b/tests/gql_behave/README.md index 4f3a29880..31599881c 100644 --- a/tests/gql_behave/README.md +++ b/tests/gql_behave/README.md @@ -4,7 +4,9 @@ Python script used to run graph query language behavior tests against Memgraph. To run the script please execute: ``` +cd memgraph/tests source ve3/bin/activate +cd gql_behave ./run.py --help ./run.py memgraph_V1 ``` diff --git a/tests/gql_behave/continuous_integration b/tests/gql_behave/continuous_integration index 35efd90a5..655b45bb3 100755 --- a/tests/gql_behave/continuous_integration +++ b/tests/gql_behave/continuous_integration @@ -15,14 +15,14 @@ List of responsibilities: import argparse import atexit import copy -import os -import sys import json +import os import subprocess +import sys import tempfile import time -import yaml +import yaml SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) TESTS_DIR = os.path.join(SCRIPT_DIR, "tests") @@ -66,7 +66,7 @@ def generate_status(suite, result_path, required): if passed == total: msg += " 👍" # +1 emoji else: - msg += " ⛔" # no entry emoji + msg += " ⛔" # no entry emoji return (msg, passed, total) @@ -87,7 +87,7 @@ def generate_result_html(data): return ret -class MemgraphRunner(): +class MemgraphRunner: def __init__(self, build_directory): self.build_directory = build_directory self.proc_mg = None @@ -102,8 +102,7 @@ class MemgraphRunner(): self.data_directory = tempfile.TemporaryDirectory() memgraph_binary = os.path.join(self.build_directory, "memgraph") - args_mg = [memgraph_binary, "--storage-properties-on-edges", - "--data-directory", self.data_directory.name] + args_mg = [memgraph_binary, "--storage-properties-on-edges", "--data-directory", self.data_directory.name] self.proc_mg = subprocess.Popen(args_mg + self.args) wait_for_server(7687, 1) assert self.is_running(), "The Memgraph process died!" @@ -135,7 +134,7 @@ def main(): suites = yaml.safe_load(f) # venv used to run the qa engine - venv_python = os.path.join(SCRIPT_DIR, "ve3", "bin", "python3") + venv_python = os.path.join(BASE_DIR, "tests", "ve3", "bin", "python3") # Temporary directory for suite results output_dir = tempfile.TemporaryDirectory() @@ -153,29 +152,36 @@ def main(): mandatory_fails = [] # Run suites + old_storage_mode = "" for suite in suites: print("Starting suite '{}' scenarios.".format(suite["name"])) - memgraph.start() + suite_storage_mode = suite["storage_mode"] + if old_storage_mode != suite_storage_mode: + memgraph.stop() + memgraph.start(["--storage-mode", suite_storage_mode]) + old_storage_mode = suite_storage_mode - suite["stats_file"] = os.path.join(output_dir.name, - suite["name"] + ".json") - cmd = [venv_python, "-u", - os.path.join(SCRIPT_DIR, "run.py"), - "--stats-file", suite["stats_file"], - suite["test_suite"]] + suite["stats_file"] = os.path.join(output_dir.name, suite["name"] + ".json") + cmd = [ + venv_python, + "-u", + os.path.join(SCRIPT_DIR, "run.py"), + "--stats-file", + suite["stats_file"], + suite["test_suite"], + ] # The exit code isn't checked here because the `behave` framework # returns a non-zero exit code when some tests fail. subprocess.run(cmd) - suite_status, suite_passed, suite_total = \ - generate_status(suite["name"], suite["stats_file"], - suite["must_pass"]) + suite_status, suite_passed, suite_total = generate_status( + suite["name"], suite["stats_file"], suite["must_pass"] + ) status_data.append([suite["name"], suite_status]) - result_csv += generate_result_csv(suite["name"], - suite["stats_file"]) + result_csv += generate_result_csv(suite["name"], suite["stats_file"]) if suite["must_pass"] and suite_passed != suite_total: mandatory_fails.append(suite["name"]) @@ -194,12 +200,12 @@ def main(): with open(result_csv_path, "w") as f: f.write(result_csv) - print(f'CSV status is generated in {result_csv_path}') - print(f'HTML status is generated in {result_html_path}') + print(f"CSV status is generated in {result_csv_path}") + print(f"HTML status is generated in {result_html_path}") # Check if tests failed if mandatory_fails != []: - sys.exit(f'Some tests that must pass have failed: {mandatory_fails}') + sys.exit(f"Some tests that must pass have failed: {mandatory_fails}") if __name__ == "__main__": diff --git a/tests/gql_behave/run.py b/tests/gql_behave/run.py index 50035384a..c2112681a 100755 --- a/tests/gql_behave/run.py +++ b/tests/gql_behave/run.py @@ -15,9 +15,10 @@ import argparse import os import sys -from behave.__main__ import main as behave_main -from behave import configuration +import mgclient +from behave import configuration +from behave.__main__ import main as behave_main SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -55,23 +56,16 @@ def main(): add_config("--test-directory") # Arguments that should be passed on to Behave - add_argument("--db-host", default="127.0.0.1", - help="server host (default is 127.0.0.1)") - add_argument("--db-port", default="7687", - help="server port (default is 7687)") - add_argument("--db-user", default="memgraph", - help="server user (default is memgraph)") - add_argument("--db-pass", default="memgraph", - help="server pass (default is memgraph)") - add_argument("--stop", action="store_true", - help="stop testing after first fail") - add_argument("--single-fail", action="store_true", - help="pause after failed scenario") - add_argument("--single-scenario", action="store_true", - help="pause after every scenario") - add_argument("--single-feature", action="store_true", - help="pause after every feature") + add_argument("--db-host", default="127.0.0.1", help="server host (default is 127.0.0.1)") + add_argument("--db-port", default="7687", help="server port (default is 7687)") + add_argument("--db-user", default="memgraph", help="server user (default is memgraph)") + add_argument("--db-pass", default="memgraph", help="server pass (default is memgraph)") + add_argument("--stop", action="store_true", help="stop testing after first fail") + add_argument("--single-fail", action="store_true", help="pause after failed scenario") + add_argument("--single-scenario", action="store_true", help="pause after every scenario") + add_argument("--single-feature", action="store_true", help="pause after every feature") add_argument("--stats-file", default="", help="statistics output file") + add_argument("--storage-mode", default="in_memory", help="Memgraph storage mode") # Parse arguments parsed_args = argp.parse_args() @@ -96,5 +90,5 @@ def main(): return behave_main(behave_args) -if __name__ == '__main__': +if __name__ == "__main__": sys.exit(main()) diff --git a/tests/gql_behave/tests/config.yaml b/tests/gql_behave/tests/config.yaml index 8fbda1ed7..4efaaaed6 100644 --- a/tests/gql_behave/tests/config.yaml +++ b/tests/gql_behave/tests/config.yaml @@ -1,15 +1,39 @@ - name: memgraph_V1 test_suite: memgraph_V1 + storage_mode: IN_MEMORY_TRANSACTIONAL must_pass: true - name: openCypher_M09 test_suite: openCypher_M09 + storage_mode: IN_MEMORY_TRANSACTIONAL must_pass: false - name: stackoverflow_answers test_suite: stackoverflow_answers + storage_mode: IN_MEMORY_TRANSACTIONAL must_pass: true - name: unstable test_suite: unstable + storage_mode: IN_MEMORY_TRANSACTIONAL + must_pass: false + +- name: memgraph_V1_on_disk + test_suite: memgraph_V1 + storage_mode: ON_DISK_TRANSACTIONAL + must_pass: true + +- name: openCypher_M09_on_disk + test_suite: openCypher_M09 + storage_mode: ON_DISK_TRANSACTIONAL + must_pass: false + +- name: stackoverflow_answers_on_disk + test_suite: stackoverflow_answers + storage_mode: ON_DISK_TRANSACTIONAL + must_pass: true + +- name: unstable_on_disk + test_suite: unstable + storage_mode: ON_DISK_TRANSACTIONAL must_pass: false diff --git a/tests/setup.sh b/tests/setup.sh index a70020778..7cab86db6 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -46,6 +46,7 @@ CFLAGS="-std=c99" python3 setup.py build CFLAGS="-std=c99" python3 setup.py install popd > /dev/null + deactivate "$DIR"/e2e/graphql/setup.sh @@ -58,7 +59,7 @@ if [ $# == 1 ]; then set +u OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH source $toolchain - NEW_LD_LIBRARY_PATH=$LD_LIBRARY_PATH + NEW_LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"../libs/mgclient/lib" deactivate set -u