Skip to content

Commit

Permalink
fix: Handle edge case of remainder records after sharding
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Chen <[email protected]>
  • Loading branch information
Nahemah1022 committed Jul 5, 2024
1 parent 658058e commit 4ec9c90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/ishard/ishard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
}
})
}
Expand Down

0 comments on commit 4ec9c90

Please sign in to comment.