From 4ec9c9046d49288f9a87827aa99ac5a7339a5f2c Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Fri, 5 Jul 2024 13:20:54 -0700 Subject: [PATCH] fix: Handle edge case of remainder records after sharding Signed-off-by: Tony Chen --- tools/ishard/ishard_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/ishard/ishard_test.go b/tools/ishard/ishard_test.go index 9585dcdf846..e9516dde9e0 100644 --- a/tools/ishard/ishard_test.go +++ b/tools/ishard/ishard_test.go @@ -107,6 +107,7 @@ func TestMaxShardSize(t *testing.T) { {numRecords: 50, fileSize: 32 * cos.KiB, maxShardSize: 128 * cos.KiB}, {numRecords: 100, fileSize: 96 * cos.KiB, maxShardSize: 256 * cos.KiB}, {numRecords: 200, fileSize: 24 * cos.KiB, maxShardSize: 16 * cos.KiB}, + {numRecords: 2000, fileSize: 24 * cos.KiB, maxShardSize: 160000 * cos.KiB}, } for _, tc := range testCases { @@ -151,8 +152,12 @@ func TestMaxShardSize(t *testing.T) { tarballs, err := api.ListObjects(baseParams, cfg.DstBck, &apc.LsoMsg{}, api.ListArgs{}) tassert.CheckError(t, err) - for _, en := range tarballs.Entries { - tassert.Fatalf(t, en.Size > tc.maxShardSize, "The output shard size doesn't reach to the desired amount") + for i, en := range tarballs.Entries { + // With collapse enabled, all output shards should reach `maxShardSize`, + // except the last one, which may contain only the remaining data. + if i < len(tarballs.Entries)-1 { + tassert.Fatalf(t, en.Size > tc.maxShardSize, "The output shard size doesn't reach to the desired amount. en.Size: %d, tc.maxShardSize: %d, i: %d, len(tarballs.Entries): %d", en.Size, tc.maxShardSize, i, len(tarballs.Entries)) + } } }) }