memgraph/tests/unit/mvcc_find.cpp
Florijan Stamenkovic 1333bfeb39 Mvcc - unit test infrastructure setup
Summary:
Gradicek's Mvcc test have seen the following changes:
- provided a test infrastructure (fixture and macros) to facilitate testing and increase readability
- split tests into multi-transaction update, VersionList::find and general Mvcc testing
- multi-transaction update tests have been refactored (i *think* nothing got deleted, but it was a mess so I don't guarantee)
- changed all multithreaded tests to be single-threaded because multiple threads were not necessary
- changed transaction naming from T5, T8, T10 to T1, T2... for consistency with actual transaction indices

What still needs to be done:
- Gleich and Gradicek need to review the infrastructure (possible improvements)
- multi-transaction update tests need to be addressed by Gradicek (see "TODO gradicek" in code, discuss with Flor)
- the wiki/draw.io documentation needs to be updated. it is not imperative that all the tests be drawn in draw.io, only the general infrastructure explained. perhaps only a few examples drawn. Gradicek discuss with Flor
- Gleich see the "TODO Gleich" lines in the diff and discuss with flor

Suggested workflow:
- review this diff, hopefully land (before resolving all the TODOs)
- discard D169
- Gradicek and Gleich address the TODOs
- Flor reviews the results (in following diffs)

Reviewers: dgleich, matej.gradicek, buda

Reviewed By: matej.gradicek, buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D348
2017-05-05 14:46:18 +02:00

107 lines
1.9 KiB
C++

#include "mvcc_find_update_common.hpp"
TEST_F(Mvcc, FindUncommittedHigherTXUpdate) {
T2_FIND;
T3_BEGIN;
T3_UPDATE;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindCommittedHigherTXUpdate) {
T2_FIND;
T3_BEGIN;
T3_UPDATE;
T3_COMMIT;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindAbortedHigherTXUpdate) {
T2_FIND;
T3_BEGIN;
T3_UPDATE;
T3_ABORT;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindCommittedLowerTXUpdate) {
T2_UPDATE;
T3_BEGIN;
T3_FIND;
T2_COMMIT;
EXPECT_EQ(v3, version_list.find(*t3));
}
TEST_F(Mvcc, FindAbortedLowerTXUpdate) {
T2_UPDATE;
T3_BEGIN;
T3_FIND;
T2_ABORT;
EXPECT_EQ(v3, version_list.find(*t3));
}
TEST_F(Mvcc, FindUncommittedHigherTXRemove) {
T2_FIND;
T3_BEGIN;
T3_REMOVE;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindCommittedHigherTXRemove) {
T2_FIND;
T3_BEGIN;
T3_REMOVE;
T3_COMMIT;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindAbortedHigherTXRemove) {
T2_FIND;
T3_BEGIN;
T3_REMOVE;
T3_ABORT;
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, FindCommittedLowerTXRemove) {
T2_REMOVE;
T3_BEGIN;
T3_FIND;
EXPECT_EQ(v3, version_list.find(*t3));
}
TEST_F(Mvcc, FindAbortedLowerTXRemove) {
T2_REMOVE;
T3_BEGIN;
T3_FIND;
T2_ABORT;
EXPECT_EQ(v3, version_list.find(*t3));
}
TEST_F(Mvcc, ReadUncommitedUpdateFromSameTXSameCommand) {
T2_UPDATE;
EXPECT_NE(v2, version_list.find(*t2));
}
TEST_F(Mvcc, ReadUncommitedUpdateFromSameTXNotSameCommand) {
T2_UPDATE;
engine.advance(t2->id);
EXPECT_EQ(v2, version_list.find(*t2));
}
TEST_F(Mvcc, ReadUncommitedRemoveFromSameTXSameCommand) {
T2_UPDATE;
T2_COMMIT;
T3_BEGIN;
T3_REMOVE;
EXPECT_EQ(v2, version_list.find(*t3));
}
TEST_F(Mvcc, ReadUncommitedRemoveFromSameTXNotSameCommand) {
T2_UPDATE;
T2_COMMIT;
T3_BEGIN;
T3_REMOVE;
engine.advance(t3->id);
EXPECT_NE(v2, version_list.find(*t3));
}