memgraph/tests/unit/commit_log_v2.cpp
Matej Ferencevic 069000a92a Fix CommitLog namespace in storage v2
Reviewers: mtomic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2179
2019-07-05 13:53:32 +02:00

53 lines
1.1 KiB
C++

#include "storage/v2/commit_log.hpp"
#include "gtest/gtest.h"
TEST(CommitLog, Simple) {
storage::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) {
storage::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) {
storage::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);
}
}