Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit f91c84b

Browse files
committed
make transaction test more robust
1 parent c7932a3 commit f91c84b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/brain/query_logger_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,26 @@ class QueryLoggerTests : public PelotonTest {
7979

8080
// only check once the the transaction has committed
8181
if (committed) {
82+
// accounting for the select_query that happened before this txn
83+
expected_result.push_back(select_query + "|" + select_query_fingerprint);
84+
8285
expected_result.insert(expected_result.end(),
8386
temporary_expected_result.begin(),
8487
temporary_expected_result.end());
8588
temporary_expected_result.clear();
8689
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query.c_str(),
8790
expected_result, true);
91+
8892
// the select query we used will also be logged for next time
8993
expected_result.push_back(select_query + "|" + select_query_fingerprint);
94+
95+
} else {
96+
// verify that the logging does not happen before the txn commit
97+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(select_query.c_str(),
98+
expected_result, true);
99+
// the select query we used will also be logged for next time
100+
temporary_expected_result.push_back(select_query + "|" +
101+
select_query_fingerprint);
90102
}
91103
}
92104

@@ -105,6 +117,9 @@ TEST_F(QueryLoggerTests, QueriesTest) {
105117
TestSimpleUtil("INSERT INTO test VALUES (1);", expected_result);
106118
TestSimpleUtil("INSERT INTO test VALUES (2);", expected_result);
107119

120+
expected_result.pop_back(); // the select_query done at the end of above test
121+
// won't be logged till the txn below commits
122+
108123
// check if the queries are logged only when the transaction actually commits
109124
TestTransactionUtil("BEGIN;", expected_result, false);
110125
TestTransactionUtil("INSERT INTO test VALUES (1);", expected_result, false);

0 commit comments

Comments
 (0)