@@ -1149,7 +1149,6 @@ TYPED_TEST(CoordinationChangelogTest, TestRotateIntervalChanges)
11491149
11501150TYPED_TEST (CoordinationChangelogTest, ChangelogTestMaxLogSize)
11511151{
1152-
11531152 ChangelogDirTest test (" ./logs" );
11541153 this ->setLogDirectory (" ./logs" );
11551154
@@ -1524,4 +1523,59 @@ TYPED_TEST(CoordinationChangelogTest, ChangelogTestBrokenWriteAt)
15241523 }
15251524}
15261525
1526+ TYPED_TEST (CoordinationChangelogTest, ChangelogLoadingFromInvalidName)
1527+ {
1528+ if (this ->enable_compression )
1529+ return ;
1530+
1531+ ChangelogDirTest test (" ./logs" );
1532+ this ->setLogDirectory (" ./logs" );
1533+
1534+ {
1535+ DB::KeeperLogStore changelog (
1536+ DB::LogFileSettings{
1537+ .force_sync = true , .compress_logs = this ->enable_compression , .rotate_interval = 100'000 , .max_size = 500 },
1538+ DB::FlushSettings (),
1539+ this ->keeper_context );
1540+ changelog.init (1 , 0 );
1541+
1542+ EXPECT_TRUE (fs::exists (" ./logs/changelog_1_100000.bin" ));
1543+ for (size_t i = 0 ; i < 500 ; ++i)
1544+ {
1545+ auto entry = getLogEntry (std::to_string (i) + " _hello_world" , 1 );
1546+ changelog.append (entry);
1547+ }
1548+ changelog.end_of_append_batch (0 , 0 );
1549+
1550+ waitDurableLogs (changelog);
1551+ }
1552+
1553+ // Find file starting with "changelog_1_" (renamed because of file size limit)
1554+ fs::path new_changelog_path;
1555+ for (const auto & entry : fs::directory_iterator (" ./logs" ))
1556+ {
1557+ if (entry.is_regular_file ())
1558+ {
1559+ const auto filename = entry.path ().filename ().string ();
1560+ if (filename.starts_with (" changelog_1_" ))
1561+ new_changelog_path = entry.path ();
1562+ }
1563+ }
1564+
1565+ ASSERT_NE (new_changelog_path, fs::path{});
1566+
1567+ fs::rename (new_changelog_path, " ./logs/changelog_1_100000.bin" );
1568+
1569+ std::cout << new_changelog_path << std::endl;
1570+
1571+ DB::KeeperLogStore changelog (
1572+ DB::LogFileSettings{
1573+ .force_sync = true , .compress_logs = this ->enable_compression , .rotate_interval = 100'000 , .max_size = 500 },
1574+ DB::FlushSettings (),
1575+ this ->keeper_context );
1576+ changelog.init (15 , 0 );
1577+
1578+ ASSERT_EQ (changelog.next_slot (), 501 );
1579+ }
1580+
15271581#endif
0 commit comments