Merge branch 'project-pineapples' into T1079-MG-add-simple-query-to-benchmark_v2

This commit is contained in:
Jeremy B 2022-10-19 08:47:13 +02:00 committed by GitHub
commit 1707ee648e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 0 deletions

View File

@ -40,6 +40,7 @@ add_subdirectory(write_procedures)
add_subdirectory(magic_functions)
add_subdirectory(module_file_manager)
add_subdirectory(monitoring_server)
add_subdirectory(distributed_queries)
copy_e2e_python_files(pytest_runner pytest_runner.sh "")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/memgraph-selfsigned.crt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -0,0 +1,5 @@
function(distributed_queries_e2e_python_files FILE_NAME)
copy_e2e_python_files(distributed_queries ${FILE_NAME})
endfunction()
distributed_queries_e2e_python_files(distributed_queries.py)

View File

@ -0,0 +1,63 @@
# Copyright 2022 Memgraph Ltd.
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
# License, and you may not use this file except in compliance with the Business Source License.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.
import typing
import mgclient
import sys
import pytest
import time
@pytest.fixture(autouse=True)
def connection():
connection = connect()
return connection
def connect(**kwargs) -> mgclient.Connection:
connection = mgclient.connect(host="localhost", port=7687, **kwargs)
connection.autocommit = True
return connection
def execute_and_fetch_all(cursor: mgclient.Cursor, query: str, params: dict = {}) -> typing.List[tuple]:
cursor.execute(query, params)
return cursor.fetchall()
def has_n_result_row(cursor: mgclient.Cursor, query: str, n: int):
results = execute_and_fetch_all(cursor, query)
return len(results) == n
def wait_for_shard_manager_to_initialize():
# The ShardManager in memgraph takes some time to initialize
# the shards, thus we cannot just run the queries right away
time.sleep(3)
def test_vertex_creation_and_scanall(connection):
wait_for_shard_manager_to_initialize()
cursor = connection.cursor()
assert has_n_result_row(cursor, "CREATE (n :label {property:1, asd:2})", 0)
assert has_n_result_row(cursor, "CREATE (n :label {property:2, asd:2})", 0)
assert has_n_result_row(cursor, "CREATE (n :label {property:3, asd:2})", 0)
assert has_n_result_row(cursor, "CREATE (n :label {property:4, asd:2})", 0)
assert has_n_result_row(cursor, "CREATE (n :label {property:5, asd:2})", 0)
assert has_n_result_row(cursor, "MATCH (n) RETURN n", 5)
assert has_n_result_row(cursor, "MATCH (n) RETURN *", 5)
assert has_n_result_row(cursor, "MATCH (n :label) RETURN *", 5)
if __name__ == "__main__":
sys.exit(pytest.main([__file__, "-rA"]))

View File

@ -0,0 +1,13 @@
template_cluster: &template_cluster
cluster:
main:
args: ["--bolt-port", "7687", "--log-level=TRACE"]
log_file: "distributed-queries-e2e.log"
setup_queries: []
validation_queries: []
workloads:
- name: "Distributed queries"
binary: "tests/e2e/pytest_runner.sh"
args: ["distributed_queries/distributed_queries.py"]
<<: *template_cluster