Skip to content

Commit 5c95d20

Browse files
committed
add unit test
1 parent 964e574 commit 5c95d20

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

cloud/filestore/libs/storage/tablet/tablet_ut_data.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7452,6 +7452,56 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_Data)
74527452
response->GetErrorReason());
74537453
}
74547454
}
7455+
7456+
7457+
TABLET_TEST_4K_ONLY(ShouldReadCorrectUnalignedTail)
7458+
{
7459+
NProto::TStorageConfig storageConfig;
7460+
TTestEnv env({}, storageConfig);
7461+
env.CreateSubDomain("nfs");
7462+
7463+
ui32 nodeIdx = env.CreateNode("nfs");
7464+
ui64 tabletId = env.BootIndexTablet(nodeIdx);
7465+
7466+
TIndexTabletClient tablet(
7467+
env.GetRuntime(),
7468+
nodeIdx,
7469+
tabletId,
7470+
tabletConfig);
7471+
tablet.InitSession("client", "session");
7472+
7473+
auto id = CreateNode(tablet, TCreateNodeArgs::File(RootNodeId, "test"));
7474+
ui64 handle = CreateHandle(tablet, id);
7475+
7476+
// the numbers were adjusted to have the tail block in
7477+
// the same blob as other blocks from fresh bytes list
7478+
const ui64 requestSize = 16_KB;
7479+
const ui64 unalignedOffset = 100_KB - 1;
7480+
const ui64 fileSize = 1_MB + unalignedOffset;
7481+
const ui64 lastOffset = fileSize - requestSize;
7482+
7483+
auto data1 = GenerateValidateData(requestSize, 1);
7484+
auto data2 = GenerateValidateData(requestSize, 2);
7485+
7486+
for (ui64 offset = unalignedOffset; offset < fileSize;
7487+
offset += requestSize)
7488+
{
7489+
tablet.WriteData(handle, offset, requestSize, data1.c_str());
7490+
}
7491+
tablet.Flush();
7492+
7493+
tablet.WriteData(handle, lastOffset, requestSize, data2.c_str());
7494+
tablet.Flush();
7495+
7496+
// Current FlushBytes implementation can forward commit id for obsolete
7497+
// block if it is located in the same blob as the block from fresh bytes
7498+
// list.
7499+
tablet.FlushBytes();
7500+
7501+
auto response = tablet.ReadData(handle, lastOffset, requestSize);
7502+
const auto& buffer = response->Record.GetBuffer();
7503+
UNIT_ASSERT_VALUES_EQUAL(data2, buffer);
7504+
}
74557505
}
74567506

74577507
} // namespace NCloud::NFileStore::NStorage

0 commit comments

Comments
 (0)