Include additional info inside storage mode info query (#883)
This commit is contained in:
@@ -4,3 +4,4 @@ endfunction()
|
||||
|
||||
copy_configuration_check_e2e_python_files(default_config.py)
|
||||
copy_configuration_check_e2e_python_files(configuration_check.py)
|
||||
copy_configuration_check_e2e_python_files(storage_info.py)
|
||||
|
||||
109
tests/e2e/configuration/storage_info.py
Normal file
109
tests/e2e/configuration/storage_info.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# 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 sys
|
||||
|
||||
import default_config
|
||||
import mgclient
|
||||
import pytest
|
||||
|
||||
default_storage_info_dict = {
|
||||
"vertex_count": 0,
|
||||
"edge_count": 0,
|
||||
"average_degree": 0,
|
||||
"memory_usage": "", # machine dependent
|
||||
"disk_usage": "", # machine dependent
|
||||
"memory_allocated": "", # machine dependent
|
||||
"allocation_limit": "", # machine dependent
|
||||
"global_isolation_level": "SNAPSHOT_ISOLATION",
|
||||
"session_isolation_level": "",
|
||||
"next_session_isolation_level": "",
|
||||
"storage_mode": "IN_MEMORY_TRANSACTIONAL",
|
||||
}
|
||||
|
||||
|
||||
def apply_queries_and_check_for_storage_info(cursor, setup_query_list, expected_values):
|
||||
for query in setup_query_list:
|
||||
cursor.execute(query)
|
||||
|
||||
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_does_default_config_match():
|
||||
connection = mgclient.connect(host="localhost", port=7687)
|
||||
connection.autocommit = True
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SHOW STORAGE INFO")
|
||||
config = cursor.fetchall()
|
||||
|
||||
# The default value of these is dependent on the given machine.
|
||||
machine_dependent_configurations = ["memory_usage", "disk_usage", "memory_allocated", "allocation_limit"]
|
||||
|
||||
# Number of different data-points returned by SHOW STORAGE INFO
|
||||
assert len(config) == 11
|
||||
|
||||
for conf in config:
|
||||
conf_name = conf[0]
|
||||
if conf_name in machine_dependent_configurations:
|
||||
continue
|
||||
assert default_storage_info_dict[conf_name] == conf[1]
|
||||
|
||||
|
||||
def test_info_change():
|
||||
connection = mgclient.connect(host="localhost", port=7687)
|
||||
connection.autocommit = True
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Check for vertex and edge changes
|
||||
setup_query_list = [
|
||||
"CREATE(n{id: 1}),(m{id: 2})",
|
||||
"MATCH(n),(m) WHERE n.id = 1 AND m.id = 2 CREATE (n)-[r:relation]->(m)",
|
||||
]
|
||||
expected_values = {
|
||||
"vertex_count": 2,
|
||||
"edge_count": 1,
|
||||
}
|
||||
|
||||
apply_queries_and_check_for_storage_info(cursor, setup_query_list, expected_values)
|
||||
|
||||
# Check for isolation level changes
|
||||
setup_query_list = [
|
||||
"SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED",
|
||||
"SET NEXT TRANSACTION ISOLATION LEVEL READ COMMITTED",
|
||||
"SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED",
|
||||
]
|
||||
|
||||
expected_values = {
|
||||
"global_isolation_level": "READ_UNCOMMITTED",
|
||||
"session_isolation_level": "READ_COMMITTED",
|
||||
"next_session_isolation_level": "READ_COMMITTED",
|
||||
}
|
||||
|
||||
apply_queries_and_check_for_storage_info(cursor, setup_query_list, expected_values)
|
||||
|
||||
# Check for storage mode change
|
||||
setup_query_list = ["STORAGE MODE IN_MEMORY_ANALYTICAL"]
|
||||
|
||||
expected_values = {"storage_mode": "IN_MEMORY_ANALYTICAL"}
|
||||
|
||||
apply_queries_and_check_for_storage_info(cursor, setup_query_list, expected_values)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main([__file__, "-rA"]))
|
||||
@@ -18,3 +18,8 @@ workloads:
|
||||
binary: "tests/e2e/pytest_runner.sh"
|
||||
args: ["configuration/configuration_check.py"]
|
||||
<<: *template_cluster
|
||||
|
||||
- name: "SHOW STORAGE INFO check"
|
||||
binary: "tests/e2e/pytest_runner.sh"
|
||||
args: ["configuration/storage_info.py"]
|
||||
<<: *template_cluster
|
||||
|
||||
@@ -18,12 +18,3 @@ size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, mem
|
||||
;
|
||||
return count;
|
||||
}
|
||||
|
||||
std::string_view StorageModeToString(memgraph::storage::StorageMode storage_mode) {
|
||||
switch (storage_mode) {
|
||||
case memgraph::storage::StorageMode::IN_MEMORY_ANALYTICAL:
|
||||
return "IN_MEMORY_ANALYTICAL";
|
||||
case memgraph::storage::StorageMode::IN_MEMORY_TRANSACTIONAL:
|
||||
return "IN_MEMORY_TRANSACTIONAL";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,5 @@
|
||||
|
||||
size_t CountVertices(memgraph::storage::Storage::Accessor &storage_accessor, memgraph::storage::View view);
|
||||
|
||||
std::string_view StorageModeToString(memgraph::storage::StorageMode storage_mode);
|
||||
|
||||
inline constexpr std::array storage_modes{memgraph::storage::StorageMode::IN_MEMORY_ANALYTICAL,
|
||||
memgraph::storage::StorageMode::IN_MEMORY_TRANSACTIONAL};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// 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
|
||||
@@ -28,16 +28,6 @@ inline constexpr std::array isolation_levels{memgraph::storage::IsolationLevel::
|
||||
memgraph::storage::IsolationLevel::READ_COMMITTED,
|
||||
memgraph::storage::IsolationLevel::READ_UNCOMMITTED};
|
||||
|
||||
std::string_view IsolationLevelToString(const memgraph::storage::IsolationLevel isolation_level) {
|
||||
switch (isolation_level) {
|
||||
case memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION:
|
||||
return "SNAPSHOT_ISOLATION";
|
||||
case memgraph::storage::IsolationLevel::READ_COMMITTED:
|
||||
return "READ_COMMITTED";
|
||||
case memgraph::storage::IsolationLevel::READ_UNCOMMITTED:
|
||||
return "READ_UNCOMMITTED";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class StorageIsolationLevelTest : public ::testing::TestWithParam<memgraph::storage::IsolationLevel> {
|
||||
|
||||
Reference in New Issue
Block a user