|
2 | 2 | #include "hive_proxy_events_private.h" |
3 | 3 |
|
4 | 4 | #include <cloud/storage/core/libs/api/hive_proxy.h> |
| 5 | +#include <cloud/storage/core/libs/hive_proxy/protos/tablet_boot_info_backup.pb.h> |
5 | 6 |
|
6 | 7 | #include <contrib/ydb/core/base/blobstorage.h> |
7 | 8 | #include <contrib/ydb/core/base/hive.h> |
|
13 | 14 | #include <contrib/ydb/core/testlib/basics/helpers.h> |
14 | 15 | #include <contrib/ydb/core/testlib/tablet_helpers.h> |
15 | 16 |
|
| 17 | +#include <library/cpp/protobuf/util/pb_io.h> |
16 | 18 | #include <library/cpp/testing/unittest/registar.h> |
17 | 19 |
|
18 | 20 | namespace NCloud::NStorage { |
@@ -1672,19 +1674,86 @@ Y_UNIT_TEST_SUITE(THiveProxyTest) |
1672 | 1674 | UNIT_ASSERT_VALUES_EQUAL(1, result.TabletBootInfos.size()); |
1673 | 1675 | UNIT_ASSERT_VALUES_EQUAL( |
1674 | 1676 | FakeTablet2, |
1675 | | - result.TabletBootInfos[0].StorageInfo->TabletID); |
| 1677 | + result.TabletBootInfos[0].StorageInfoProto.GetTabletID()); |
1676 | 1678 | TVector<TVector<ui64>> actualGroupIds; |
1677 | | - for (auto& channel: result.TabletBootInfos[0].StorageInfo->Channels) |
| 1679 | + for (auto& channel: |
| 1680 | + result.TabletBootInfos[0].StorageInfoProto.GetChannels()) |
1678 | 1681 | { |
1679 | 1682 | actualGroupIds.emplace_back(); |
1680 | | - for (auto& historyEntry: channel.History) { |
1681 | | - actualGroupIds.back().emplace_back(historyEntry.GroupID); |
| 1683 | + for (auto& historyEntry: channel.GetHistory()) { |
| 1684 | + actualGroupIds.back().emplace_back( |
| 1685 | + historyEntry.GetGroupID()); |
1682 | 1686 | } |
1683 | 1687 | } |
1684 | 1688 |
|
1685 | 1689 | UNIT_ASSERT_VALUES_EQUAL(expectedGroupIds, actualGroupIds); |
1686 | 1690 | } |
1687 | 1691 | } |
| 1692 | + |
| 1693 | + Y_UNIT_TEST(ShouldListCorruptedTabletBootInfoBackupsWithoutCrash) |
| 1694 | + { |
| 1695 | + TString backupFilePath = |
| 1696 | + "BootExternal.tablet_boot_info_backup.txt"; |
| 1697 | + |
| 1698 | + NKikimr::TTabletStorageInfoPtr storageInfo; |
| 1699 | + |
| 1700 | + TVector<TVector<ui64>> expectedGroupIds; |
| 1701 | + { |
| 1702 | + TTestBasicRuntime runtime; |
| 1703 | + TTestEnv env(runtime, backupFilePath, false); |
| 1704 | + |
| 1705 | + TTabletStorageInfoPtr expected = CreateTestTabletInfo( |
| 1706 | + FakeTablet2, |
| 1707 | + TTabletTypes::BlockStorePartition); |
| 1708 | + env.HiveState->StorageInfos[FakeTablet2] = expected; |
| 1709 | + |
| 1710 | + auto sender = runtime.AllocateEdgeActor(); |
| 1711 | + |
| 1712 | + auto result = |
| 1713 | + env.SendBootExternalRequest(sender, FakeTablet2, S_OK); |
| 1714 | + UNIT_ASSERT(result.StorageInfo); |
| 1715 | + UNIT_ASSERT_VALUES_EQUAL(FakeTablet2, result.StorageInfo->TabletID); |
| 1716 | + UNIT_ASSERT_VALUES_EQUAL(1u, result.SuggestedGeneration); |
| 1717 | + |
| 1718 | + // Smoke check for background sync (15 seconds should be enough). |
| 1719 | + runtime.AdvanceCurrentTime(TDuration::Seconds(15)); |
| 1720 | + runtime.DispatchEvents(TDispatchOptions(), TDuration::Seconds(15)); |
| 1721 | + |
| 1722 | + for (auto& channel: result.StorageInfo->Channels) { |
| 1723 | + expectedGroupIds.emplace_back(); |
| 1724 | + for (auto& historyEntry: channel.History) { |
| 1725 | + expectedGroupIds.back().emplace_back( |
| 1726 | + historyEntry.GroupID); |
| 1727 | + } |
| 1728 | + } |
| 1729 | + storageInfo = result.StorageInfo; |
| 1730 | + env.SendBackupTabletBootInfos(sender, S_OK); |
| 1731 | + } |
| 1732 | + |
| 1733 | + // simulate backup corruption |
| 1734 | + { |
| 1735 | + NHiveProxy::NProto::TTabletBootInfoBackup backupProto; |
| 1736 | + MergeFromTextFormat(backupFilePath, backupProto); |
| 1737 | + |
| 1738 | + backupProto.MutableData() |
| 1739 | + ->begin() |
| 1740 | + ->second.MutableStorageInfo() |
| 1741 | + ->MutableChannels(0) |
| 1742 | + ->SetChannelErasureName(""); |
| 1743 | + |
| 1744 | + TFileOutput output(backupFilePath); |
| 1745 | + SerializeToTextFormat(backupProto, output); |
| 1746 | + } |
| 1747 | + |
| 1748 | + { |
| 1749 | + TTestBasicRuntime runtime; |
| 1750 | + TTestEnv env(runtime, backupFilePath, false); |
| 1751 | + |
| 1752 | + auto sender = runtime.AllocateEdgeActor(); |
| 1753 | + |
| 1754 | + env.SendListTabletBootInfoBackups(sender, S_OK); |
| 1755 | + } |
| 1756 | + } |
1688 | 1757 | } |
1689 | 1758 |
|
1690 | 1759 | } // namespace NCloud::NStorage |
0 commit comments