memgraph/tests/unit/commit_log_v2.cpp
Marin Tomic 6ce8fae54a Implement commit log for storage v2
Reviewers: teon.banek, mferencevic

Reviewed By: teon.banek, mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2148
2019-06-27 13:52:51 +02:00

53 lines
1.1 KiB
C++

#include "storage/v2/commit_log.hpp"
#include "gtest/gtest.h"
TEST(CommitLog, Simple) {
CommitLog log;
EXPECT_EQ(log.OldestActive(), 0);
log.MarkFinished(1);
EXPECT_EQ(log.OldestActive(), 0);
log.MarkFinished(0);
EXPECT_EQ(log.OldestActive(), 2);
}
TEST(CommitLog, Fields) {
CommitLog log;
for (uint64_t i = 0; i < 64; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), i + 1);
}
for (uint64_t i = 128; i < 192; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), 64);
}
for (uint64_t i = 64; i < 128; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), i < 127 ? i + 1 : 192);
}
}
TEST(CommitLog, Blocks) {
CommitLog log;
for (uint64_t i = 0; i < 8192 * 64; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), i + 1);
}
for (uint64_t i = 8192 * 64 * 2; i < 8192 * 64 * 3; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), 8192 * 64);
}
for (uint64_t i = 8192 * 64; i < 8192 * 64; ++i) {
log.MarkFinished(i);
EXPECT_EQ(log.OldestActive(), i < 8192 * 64 - 1 ? i + 1 : 8192 * 64 * 3);
}
}