069000a92a
Reviewers: mtomic Reviewed By: mtomic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2179
53 lines
1.1 KiB
C++
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);
|
|
}
|
|
}
|