Skip to content

Commit 0bef005

Browse files
PS-10281 postfix: Implement logic for search_by_gtid_set mode (#114)
https://perconadev.atlassian.net/browse/PS-10281 'gtid_set_test' (BOOST_TEST_MODULE GtidSetTests) unit test extended with new test case 'GtidSetSimulateSearchByGTIDSet' which simulates the logic of 'search_by_gtid_set' main application operation mode. Updated unit tests 'CMakeLists.txt' file . We now run unit tests with '--no_color_output' command line option which helps with better integration with VS Code.
1 parent d097c00 commit 0bef005

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

tests/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,11 @@ set_target_properties(event_test PROPERTIES
255255
CXX_EXTENSIONS NO
256256
)
257257

258-
add_test(NAME byte_span_encoding_test COMMAND byte_span_encoding_test)
259-
add_test(NAME uuid_test COMMAND uuid_test)
260-
add_test(NAME tag_test COMMAND tag_test)
261-
add_test(NAME gtid_test COMMAND gtid_test)
262-
add_test(NAME gtid_set_test COMMAND gtid_set_test)
263-
add_test(NAME event_test COMMAND event_test)
258+
259+
set(test_run_options --no_color_output)
260+
add_test(NAME byte_span_encoding_test COMMAND byte_span_encoding_test ${test_run_options})
261+
add_test(NAME uuid_test COMMAND uuid_test ${test_run_options})
262+
add_test(NAME tag_test COMMAND tag_test ${test_run_options})
263+
add_test(NAME gtid_test COMMAND gtid_test ${test_run_options})
264+
add_test(NAME gtid_set_test COMMAND gtid_set_test ${test_run_options})
265+
add_test(NAME event_test COMMAND event_test ${test_run_options})

tests/gtid_set_test.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,3 +721,33 @@ BOOST_AUTO_TEST_CASE(GtidSetWhitespaces) {
721721
boost::lexical_cast<binsrv::gtids::gtid_set>(gtids_str)};
722722
BOOST_CHECK_EQUAL(gtids, restored_gtids);
723723
}
724+
725+
BOOST_AUTO_TEST_CASE(GtidSetSimulateSearchByGTIDSet) {
726+
constexpr std::string_view first_random_uuid_sv{
727+
"ae6896b1-2e94-11f1-af82-76efd046f53d"};
728+
constexpr std::string_view second_random_uuid_sv{
729+
"bcd66d18-2e94-11f1-b929-76efd046f53d"};
730+
731+
const std::string first_binlog_file_added_gtids_str{
732+
std::string{first_random_uuid_sv} + ":1-4, " +
733+
std::string{second_random_uuid_sv} + ":1-1103"};
734+
const binsrv::gtids::gtid_set first_binlog_file_added_gtids{
735+
first_binlog_file_added_gtids_str};
736+
BOOST_CHECK(first_binlog_file_added_gtids.str() ==
737+
first_binlog_file_added_gtids_str);
738+
739+
const binsrv::gtids::gtid lookup_gtid{
740+
binsrv::gtids::uuid{second_random_uuid_sv}, 1103ULL};
741+
742+
BOOST_CHECK(first_binlog_file_added_gtids.contains(lookup_gtid));
743+
744+
const binsrv::gtids::gtid_set lookup_gtids{lookup_gtid};
745+
BOOST_CHECK(
746+
binsrv::gtids::intersects(first_binlog_file_added_gtids, lookup_gtids));
747+
BOOST_CHECK(
748+
binsrv::gtids::intersects(lookup_gtids, first_binlog_file_added_gtids));
749+
750+
binsrv::gtids::gtid_set remaining_gtids{lookup_gtids};
751+
remaining_gtids.subtract(first_binlog_file_added_gtids);
752+
BOOST_CHECK(remaining_gtids.is_empty());
753+
}

0 commit comments

Comments
 (0)