Fix IN_MEMORY_ANALYTICAL storage GC (#1025)
This commit is contained in:
committed by
GitHub
parent
b25e9968ee
commit
5b1ba10183
@@ -57,6 +57,7 @@ add_subdirectory(transaction_queue)
|
||||
add_subdirectory(mock_api)
|
||||
add_subdirectory(load_csv)
|
||||
add_subdirectory(init_file_flags)
|
||||
add_subdirectory(analytical_mode)
|
||||
|
||||
copy_e2e_python_files(pytest_runner pytest_runner.sh "")
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/memgraph-selfsigned.crt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
6
tests/e2e/analytical_mode/CMakeLists.txt
Normal file
6
tests/e2e/analytical_mode/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
function(copy_analytical_mode_e2e_python_files FILE_NAME)
|
||||
copy_e2e_python_files(analytical_mode ${FILE_NAME})
|
||||
endfunction()
|
||||
|
||||
copy_analytical_mode_e2e_python_files(common.py)
|
||||
copy_analytical_mode_e2e_python_files(free_memory.py)
|
||||
30
tests/e2e/analytical_mode/common.py
Normal file
30
tests/e2e/analytical_mode/common.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2023 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 pytest
|
||||
|
||||
|
||||
def execute_and_fetch_all(cursor: mgclient.Cursor, query: str, params: dict = {}) -> typing.List[tuple]:
|
||||
cursor.execute(query, params)
|
||||
return cursor.fetchall()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def connect(**kwargs) -> mgclient.Connection:
|
||||
connection = mgclient.connect(host="localhost", port=7687, **kwargs)
|
||||
connection.autocommit = True
|
||||
yield connection
|
||||
cursor = connection.cursor()
|
||||
execute_and_fetch_all(cursor, "MATCH (n) DETACH DELETE n")
|
||||
execute_and_fetch_all(cursor, "STORAGE MODE IN_MEMORY_TRANSACTIONAL;")
|
||||
63
tests/e2e/analytical_mode/free_memory.py
Normal file
63
tests/e2e/analytical_mode/free_memory.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# Copyright 2023 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 sys
|
||||
|
||||
import pytest
|
||||
from common import connect, execute_and_fetch_all
|
||||
|
||||
|
||||
def check_storage_info(cursor, expected_values):
|
||||
cursor.execute("SHOW STORAGE INFO")
|
||||
config = cursor.fetchall()
|
||||
|
||||
for conf in config:
|
||||
conf_name = conf[0]
|
||||
if conf_name in expected_values:
|
||||
assert expected_values[conf_name] == conf[1]
|
||||
|
||||
|
||||
def test_analytical_mode_objects_are_actually_deleted_when_asked(connect):
|
||||
"""Tests objects are actually freed when deleted in analytical mode."""
|
||||
|
||||
expected_values = {
|
||||
"vertex_count": 0,
|
||||
}
|
||||
|
||||
cursor = connect.cursor()
|
||||
check_storage_info(cursor, expected_values)
|
||||
|
||||
cursor.execute("STORAGE MODE IN_MEMORY_ANALYTICAL;")
|
||||
cursor.execute("MERGE (n) DELETE n;")
|
||||
cursor.execute("FREE MEMORY;")
|
||||
|
||||
check_storage_info(cursor, expected_values)
|
||||
|
||||
|
||||
def test_analytical_mode_objects_are_actually_deleted_when_storage_mode_changes(connect):
|
||||
"""Tests objects are actually freed when deleted in analytical mode."""
|
||||
|
||||
expected_values = {
|
||||
"vertex_count": 0,
|
||||
}
|
||||
|
||||
cursor = connect.cursor()
|
||||
check_storage_info(cursor, expected_values)
|
||||
|
||||
cursor.execute("STORAGE MODE IN_MEMORY_ANALYTICAL;")
|
||||
cursor.execute("MERGE (n) DELETE n;")
|
||||
cursor.execute("STORAGE MODE IN_MEMORY_TRANSACTIONAL;")
|
||||
|
||||
check_storage_info(cursor, expected_values)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main([__file__, "-rA"]))
|
||||
14
tests/e2e/analytical_mode/workloads.yaml
Normal file
14
tests/e2e/analytical_mode/workloads.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
analytical_mode_cluster: &analytical_mode_cluster
|
||||
cluster:
|
||||
main:
|
||||
args: ["--bolt-port", "7687", "--log-level=TRACE"]
|
||||
log_file: "analytical_mode.log"
|
||||
setup_queries: []
|
||||
validation_queries: []
|
||||
|
||||
|
||||
workloads:
|
||||
- name: "Analytical mode checks"
|
||||
binary: "tests/e2e/pytest_runner.sh"
|
||||
args: ["analytical_mode/free_memory.py"]
|
||||
<<: *analytical_mode_cluster
|
||||
Reference in New Issue
Block a user