Storage unit tests
This commit is contained in:
@@ -33,7 +33,6 @@ inline void ApplyDeltasForRead(Transaction *transaction, const Delta *delta, Vie
|
||||
const auto commit_timestamp = transaction->commit_timestamp
|
||||
? transaction->commit_timestamp->load(std::memory_order_acquire)
|
||||
: transaction->transaction_id.load(std::memory_order_acquire);
|
||||
spdlog::debug("Delta's commit timestamp: {}", delta->timestamp->load(std::memory_order_acquire));
|
||||
while (delta != nullptr) {
|
||||
auto ts = delta->timestamp->load(std::memory_order_acquire);
|
||||
auto cid = delta->command_id;
|
||||
@@ -82,8 +81,6 @@ template <typename TObj>
|
||||
inline bool PrepareForWrite(Transaction *transaction, TObj *object) {
|
||||
if (object->delta == nullptr) return true;
|
||||
auto ts = object->delta->timestamp->load(std::memory_order_acquire);
|
||||
spdlog::debug("Delta: {} Ts: {} TX id {} TX start {}", object->delta->action, ts,
|
||||
transaction->transaction_id.load(std::memory_order_acquire), transaction->start_timestamp);
|
||||
if (ts == transaction->transaction_id.load(std::memory_order_acquire) || ts < transaction->start_timestamp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
|
||||
for (uint64_t i = 0; i < 1000; ++i) {
|
||||
auto vertex = acc->FindVertex(vertices[i], memgraph::storage::View::OLD);
|
||||
ASSERT_TRUE(vertex);
|
||||
ASSERT_TRUE(vertex.has_value());
|
||||
if (i % 5 == 0) {
|
||||
EXPECT_FALSE(acc->DeleteVertex(&vertex.value()).HasError());
|
||||
}
|
||||
@@ -54,7 +54,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
for (uint64_t i = 0; i < 1000; ++i) {
|
||||
auto vertex_old = acc->FindVertex(vertices[i], memgraph::storage::View::OLD);
|
||||
auto vertex_new = acc->FindVertex(vertices[i], memgraph::storage::View::NEW);
|
||||
EXPECT_TRUE(vertex_old);
|
||||
EXPECT_TRUE(vertex_old.has_value());
|
||||
EXPECT_EQ(vertex_new.has_value(), i % 5 != 0);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
auto vertex = acc->FindVertex(vertices[i], memgraph::storage::View::OLD);
|
||||
EXPECT_EQ(vertex.has_value(), i % 5 != 0);
|
||||
|
||||
if (vertex) {
|
||||
if (vertex.has_value()) {
|
||||
EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i)).HasError());
|
||||
EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i + 1)).HasError());
|
||||
EXPECT_FALSE(vertex->AddLabel(memgraph::storage::LabelId::FromUint(3 * i + 2)).HasError());
|
||||
@@ -83,7 +83,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
auto vertex = acc->FindVertex(vertices[i], memgraph::storage::View::NEW);
|
||||
EXPECT_EQ(vertex.has_value(), i % 5 != 0);
|
||||
|
||||
if (vertex) {
|
||||
if (vertex.has_value()) {
|
||||
auto labels_old = vertex->Labels(memgraph::storage::View::OLD);
|
||||
EXPECT_TRUE(labels_old.HasValue());
|
||||
EXPECT_TRUE(labels_old->empty());
|
||||
@@ -108,7 +108,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
EXPECT_EQ(from_vertex.has_value(), i % 5 != 0);
|
||||
EXPECT_EQ(to_vertex.has_value(), (i + 1) % 5 != 0);
|
||||
|
||||
if (from_vertex && to_vertex) {
|
||||
if (from_vertex.has_value() && to_vertex.has_value()) {
|
||||
EXPECT_FALSE(
|
||||
acc->CreateEdge(&from_vertex.value(), &to_vertex.value(), memgraph::storage::EdgeTypeId::FromUint(i))
|
||||
.HasError());
|
||||
@@ -119,7 +119,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
for (uint64_t i = 0; i < 1000; ++i) {
|
||||
auto vertex = acc->FindVertex(vertices[i], memgraph::storage::View::NEW);
|
||||
EXPECT_EQ(vertex.has_value(), i % 5 != 0);
|
||||
if (vertex) {
|
||||
if (vertex.has_value()) {
|
||||
if (i % 3 == 0) {
|
||||
EXPECT_FALSE(acc->DetachDeleteVertex(&vertex.value()).HasError());
|
||||
}
|
||||
@@ -133,7 +133,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
for (uint64_t i = 0; i < 1000; ++i) {
|
||||
auto vertex = acc->FindVertex(vertices[i], memgraph::storage::View::NEW);
|
||||
EXPECT_EQ(vertex.has_value(), i % 5 != 0 && i % 3 != 0);
|
||||
if (vertex) {
|
||||
if (vertex.has_value()) {
|
||||
auto out_edges = vertex->OutEdges(memgraph::storage::View::NEW);
|
||||
if (i % 5 != 4 && i % 3 != 2) {
|
||||
EXPECT_EQ(out_edges.GetValue().size(), 1);
|
||||
@@ -147,7 +147,7 @@ TEST(StorageV2Gc, Sanity) {
|
||||
if (i % 5 != 1 && i % 3 != 1) {
|
||||
EXPECT_EQ(in_edges.GetValue().size(), 1);
|
||||
EXPECT_EQ(*vertex->InDegree(memgraph::storage::View::NEW), 1);
|
||||
EXPECT_EQ(out_edges.GetValue().at(0).EdgeType().AsUint(), i);
|
||||
EXPECT_EQ(in_edges.GetValue().at(0).EdgeType().AsUint(), (i + 999) % 1000);
|
||||
} else {
|
||||
EXPECT_TRUE(in_edges->empty());
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#include "interpreter_faker.hpp"
|
||||
#include "query/exceptions.hpp"
|
||||
#include "storage/v2/inmemory/storage.hpp"
|
||||
#include "storage/v2/isolation_level.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "storage/v2/storage_mode.hpp"
|
||||
#include "storage/v2/vertex_accessor.hpp"
|
||||
#include "storage_test_utils.hpp"
|
||||
@@ -37,11 +37,12 @@ class StorageModeTest : public ::testing::TestWithParam<memgraph::storage::Stora
|
||||
TEST_P(StorageModeTest, Mode) {
|
||||
const memgraph::storage::StorageMode storage_mode = GetParam();
|
||||
|
||||
memgraph::storage::Storage storage{
|
||||
{.transaction{.isolation_level = memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION}}};
|
||||
storage.SetStorageMode(storage_mode);
|
||||
auto creator = storage.Access();
|
||||
auto other_analytics_mode_reader = storage.Access();
|
||||
auto storage = std::make_unique<memgraph::storage::InMemoryStorage>(memgraph::storage::Config{
|
||||
.transaction{.isolation_level = memgraph::storage::IsolationLevel::SNAPSHOT_ISOLATION}});
|
||||
|
||||
storage->SetStorageMode(storage_mode);
|
||||
auto creator = storage->Access();
|
||||
auto other_analytics_mode_reader = storage->Access();
|
||||
|
||||
ASSERT_EQ(CountVertices(creator, memgraph::storage::View::OLD), 0);
|
||||
ASSERT_EQ(CountVertices(other_analytics_mode_reader, memgraph::storage::View::OLD), 0);
|
||||
|
||||
Reference in New Issue
Block a user