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 17:05:56 +08:00
|
|
|
#include <vector>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include "mvcc/record.hpp"
|
|
|
|
#include "mvcc/version.hpp"
|
|
|
|
#include "mvcc/version_list.hpp"
|
2018-01-10 22:10:22 +08:00
|
|
|
#include "transactions/engine_single_node.hpp"
|
2017-11-29 23:03:42 +08:00
|
|
|
#include "transactions/transaction.hpp"
|
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 17:05:56 +08:00
|
|
|
|
|
|
|
class TestClass : public mvcc::Record<TestClass> {
|
2017-05-16 18:22:28 +08:00
|
|
|
public:
|
|
|
|
// constructs first version, size should be 0
|
2018-01-10 22:10:22 +08:00
|
|
|
explicit TestClass(int &version_list_size) : version_list_size_(version_list_size) {
|
2017-05-16 18:22:28 +08:00
|
|
|
++version_list_size_;
|
|
|
|
}
|
2017-09-27 20:45:50 +08:00
|
|
|
TestClass *CloneData() { return new TestClass(version_list_size_); }
|
2017-05-16 18:22:28 +08:00
|
|
|
// version constructed in version list update
|
|
|
|
TestClass(TestClass &other) : version_list_size_(other.version_list_size_) {
|
|
|
|
version_list_size_++;
|
|
|
|
}
|
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 17:05:56 +08:00
|
|
|
friend std::ostream &operator<<(std::ostream &stream, TestClass &test_class) {
|
2017-09-27 20:45:50 +08:00
|
|
|
stream << test_class.tx().cre << " " << test_class.tx().exp;
|
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 17:05:56 +08:00
|
|
|
return stream;
|
|
|
|
}
|
2017-05-16 18:22:28 +08:00
|
|
|
// reference to variable version_list_size in test SetUp, increases when new
|
|
|
|
// TestClass is created
|
|
|
|
int &version_list_size_;
|
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 17:05:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Testing mvcc::VersionList::find behavior in
|
|
|
|
* different situations (preceeding update/remove ops
|
|
|
|
* in different transactions).
|
|
|
|
*
|
|
|
|
* The setup for each case is:
|
|
|
|
* - transaction t1 has created a new version_list v1 and commited
|
|
|
|
* - transaction t2 has strated
|
|
|
|
* - *********************
|
|
|
|
* - here the test fixture ends and custom test behavior should be added
|
|
|
|
* - *********************
|
|
|
|
* - tests should check every legal sequence of the following ops
|
|
|
|
* - creation of transaction t3
|
|
|
|
* - [commit/abort] of [t2/t3]
|
|
|
|
* - [removal/update] on version_list by [t2/t3]
|
|
|
|
* - illegal sequences (for example double commit) don't have to be checked
|
|
|
|
*/
|
|
|
|
class Mvcc : public ::testing::Test {
|
|
|
|
protected:
|
|
|
|
virtual void SetUp() {
|
2017-06-12 16:21:19 +08:00
|
|
|
id0 = 0;
|
2017-11-24 21:46:42 +08:00
|
|
|
engine.Advance(t1->id_);
|
2017-06-12 16:21:19 +08:00
|
|
|
id1 = t1->id_;
|
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 17:05:56 +08:00
|
|
|
v1 = version_list.find(*t1);
|
2017-11-29 23:03:42 +08:00
|
|
|
engine.Commit(*t1);
|
2017-06-12 16:21:19 +08:00
|
|
|
t2 = engine.Begin();
|
|
|
|
id2 = t2->id_;
|
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 17:05:56 +08:00
|
|
|
}
|
2017-05-16 18:22:28 +08:00
|
|
|
// variable where number of versions is stored
|
|
|
|
int version_list_size = 0;
|
2018-01-10 22:10:22 +08:00
|
|
|
tx::SingleNodeEngine engine;
|
2017-06-12 16:21:19 +08:00
|
|
|
tx::Transaction *t1 = engine.Begin();
|
2018-07-05 03:32:07 +08:00
|
|
|
mvcc::VersionList<TestClass> version_list{*t1, 0, 0, version_list_size};
|
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 17:05:56 +08:00
|
|
|
TestClass *v1 = nullptr;
|
|
|
|
tx::Transaction *t2 = nullptr;
|
2018-04-19 21:32:41 +08:00
|
|
|
tx::TransactionId id0, id1, id2;
|
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 17:05:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// helper macros. important:
|
|
|
|
// - TX_FIND and TX_UPDATE set the record variable vX
|
|
|
|
// - TX_BEGIN sets the transaction variable tX
|
|
|
|
#define T2_FIND __attribute__((unused)) auto v2 = version_list.find(*t2)
|
|
|
|
#define T3_FIND __attribute__((unused)) auto v3 = version_list.find(*t3)
|
2017-06-02 15:19:23 +08:00
|
|
|
#define T4_FIND __attribute__((unused)) auto v4 = version_list.find(*t4)
|
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 17:05:56 +08:00
|
|
|
#define T2_UPDATE __attribute__((unused)) auto v2 = version_list.update(*t2)
|
|
|
|
#define T3_UPDATE __attribute__((unused)) auto v3 = version_list.update(*t3)
|
2017-11-29 23:03:42 +08:00
|
|
|
#define T2_COMMIT engine.Commit(*t2);
|
|
|
|
#define T3_COMMIT engine.Commit(*t3);
|
|
|
|
#define T2_ABORT engine.Abort(*t2);
|
|
|
|
#define T3_ABORT engine.Abort(*t3);
|
2017-09-27 20:45:50 +08:00
|
|
|
#define T3_BEGIN \
|
|
|
|
auto t3 = engine.Begin(); \
|
|
|
|
__attribute__((unused)) int id3 = t3->id_
|
2017-06-12 16:21:19 +08:00
|
|
|
#define T4_BEGIN auto t4 = engine.Begin();
|
2017-10-17 15:52:13 +08:00
|
|
|
#define T2_REMOVE version_list.remove(version_list.find(*t2), *t2)
|
|
|
|
#define T3_REMOVE version_list.remove(version_list.find(*t3), *t3)
|
2017-09-27 20:45:50 +08:00
|
|
|
#define EXPECT_CRE(record, expected) EXPECT_EQ(record->tx().cre, id##expected)
|
|
|
|
#define EXPECT_EXP(record, expected) EXPECT_EQ(record->tx().exp, id##expected)
|
2017-05-16 18:22:28 +08:00
|
|
|
#define EXPECT_NXT(v1, v2) EXPECT_EQ(v1->next(), v2)
|
|
|
|
#define EXPECT_SIZE(n) EXPECT_EQ(version_list_size, n)
|
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 17:05:56 +08:00
|
|
|
|
|
|
|
// test the fixture
|
|
|
|
TEST_F(Mvcc, Fixture) {
|
|
|
|
EXPECT_CRE(v1, 1);
|
|
|
|
EXPECT_EXP(v1, 0);
|
|
|
|
}
|