memgraph/tests/unit/mvcc_parallel_update.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

89 lines
1.6 KiB
C++

#include "mvcc_find_update_common.hpp"
// TODO Gradicek: rename all existing cases
// TODO Gradicek: check validity of all existing cases
// TODO Gradicek: add all other cases (48 in total, discuss with Flor)
// TODO Gradicek: what about command advance testing,
// as opposed to transaction commit/abort?
TEST_F(Mvcc, Case1_InsertWithUpdates) {
T2_UPDATE;
T2_COMMIT;
T3_BEGIN;
T3_REMOVE;
T3_COMMIT;
EXPECT_EXP(v2, 3);
}
TEST_F(Mvcc, RemoveUpdatedRecord) {
T3_BEGIN;
T3_UPDATE;
T3_COMMIT;
EXPECT_THROW(T2_REMOVE, mvcc::SerializationError);
}
TEST_F(Mvcc, UpdateUpdatedRecord) {
T3_BEGIN;
T3_UPDATE;
T3_COMMIT;
EXPECT_THROW(version_list.update(*t2), mvcc::SerializationError);
}
TEST_F(Mvcc, Case2_AbortUpdate_Remove_T10) {
T2_UPDATE;
T2_ABORT;
T3_BEGIN;
T3_REMOVE;
T3_COMMIT;
EXPECT_CRE(v1, 1);
EXPECT_EXP(v1, 3);
EXPECT_CRE(v2, 2);
EXPECT_EXP(v2, 0);
}
TEST_F(Mvcc, Case2_AbortUpdate_Remove_T7) {
T3_BEGIN;
T3_UPDATE;
T3_ABORT;
T2_REMOVE;
T2_COMMIT;
EXPECT_CRE(v1, 1);
EXPECT_EXP(v1, 2);
EXPECT_CRE(v3, 3);
EXPECT_EXP(v3, 0);
}
TEST_F(Mvcc, Case2_AbortUpdate_Update_T10) {
T2_UPDATE;
T2_ABORT;
T3_BEGIN;
T3_UPDATE;
T3_COMMIT;
EXPECT_CRE(v1, 1);
EXPECT_EXP(v1, 3);
EXPECT_CRE(v3, 3);
EXPECT_EXP(v3, 0);
}
TEST_F(Mvcc, Case2_AbortUpdate_Update_T7) {
T3_BEGIN;
T3_UPDATE;
T3_ABORT;
T2_UPDATE;
T2_COMMIT;
EXPECT_CRE(v3, 3);
EXPECT_EXP(v3, 0);
EXPECT_CRE(v2, 2);
EXPECT_EXP(v2, 0);
}
TEST_F(Mvcc, Case1Test3) {
T3_BEGIN;
T3_UPDATE;
T3_COMMIT;
EXPECT_THROW(T2_REMOVE, mvcc::SerializationError);
}