forked from TrueCloudLab/frostfs-node
[#633] shard/test: Fix TestCounters()
Introduced in 362f24953a
, forgotten to be changed because test
generator didn't provide payload size.
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
b8f79f4227
commit
00aa6d9749
2 changed files with 19 additions and 7 deletions
|
@ -49,6 +49,7 @@ func GenerateObjectWithCIDWithPayload(cnr cid.ID, data []byte) *objectSDK.Object
|
|||
obj.SetContainerID(cnr)
|
||||
obj.SetVersion(&ver)
|
||||
obj.SetPayload(data)
|
||||
obj.SetPayloadSize(uint64(len(data)))
|
||||
obj.SetPayloadChecksum(csum)
|
||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
|
||||
|
@ -151,11 +152,11 @@ func TestCounters(t *testing.T) {
|
|||
|
||||
var totalPayload int64
|
||||
|
||||
expectedSizes := make(map[string]int64)
|
||||
expectedLogicalSizes := make(map[string]int64)
|
||||
for i := range oo {
|
||||
cnr, _ := oo[i].ContainerID()
|
||||
oSize := int64(oo[i].PayloadSize())
|
||||
expectedSizes[cnr.EncodeToString()] += oSize
|
||||
expectedLogicalSizes[cnr.EncodeToString()] += oSize
|
||||
totalPayload += oSize
|
||||
}
|
||||
|
||||
|
@ -170,7 +171,7 @@ func TestCounters(t *testing.T) {
|
|||
|
||||
require.Equal(t, uint64(objNumber), mm.getObjectCounter(physical))
|
||||
require.Equal(t, uint64(objNumber), mm.getObjectCounter(logical))
|
||||
require.Equal(t, expectedSizes, mm.containerSizes())
|
||||
require.Equal(t, expectedLogicalSizes, mm.containerSizes())
|
||||
require.Equal(t, totalPayload, mm.payloadSize())
|
||||
|
||||
t.Run("inhume_GC", func(t *testing.T) {
|
||||
|
@ -182,11 +183,15 @@ func TestCounters(t *testing.T) {
|
|||
|
||||
_, err := sh.Inhume(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
cid, ok := oo[i].ContainerID()
|
||||
require.True(t, ok)
|
||||
expectedLogicalSizes[cid.EncodeToString()] -= int64(oo[i].PayloadSize())
|
||||
}
|
||||
|
||||
require.Equal(t, uint64(objNumber), mm.getObjectCounter(physical))
|
||||
require.Equal(t, uint64(objNumber-inhumedNumber), mm.getObjectCounter(logical))
|
||||
require.Equal(t, expectedSizes, mm.containerSizes())
|
||||
require.Equal(t, expectedLogicalSizes, mm.containerSizes())
|
||||
require.Equal(t, totalPayload, mm.payloadSize())
|
||||
|
||||
oo = oo[inhumedNumber:]
|
||||
|
@ -205,9 +210,15 @@ func TestCounters(t *testing.T) {
|
|||
_, err := sh.Inhume(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < inhumedNumber; i++ {
|
||||
cid, ok := oo[i].ContainerID()
|
||||
require.True(t, ok)
|
||||
expectedLogicalSizes[cid.EncodeToString()] -= int64(oo[i].PayloadSize())
|
||||
}
|
||||
|
||||
require.Equal(t, phy, mm.getObjectCounter(physical))
|
||||
require.Equal(t, logic-uint64(inhumedNumber), mm.getObjectCounter(logical))
|
||||
require.Equal(t, expectedSizes, mm.containerSizes())
|
||||
require.Equal(t, expectedLogicalSizes, mm.containerSizes())
|
||||
require.Equal(t, totalPayload, mm.payloadSize())
|
||||
|
||||
oo = oo[inhumedNumber:]
|
||||
|
@ -233,9 +244,9 @@ func TestCounters(t *testing.T) {
|
|||
totalRemovedpayload += removedPayload
|
||||
|
||||
cnr, _ := oo[i].ContainerID()
|
||||
expectedSizes[cnr.EncodeToString()] -= int64(removedPayload)
|
||||
expectedLogicalSizes[cnr.EncodeToString()] -= int64(removedPayload)
|
||||
}
|
||||
require.Equal(t, expectedSizes, mm.containerSizes())
|
||||
require.Equal(t, expectedLogicalSizes, mm.containerSizes())
|
||||
require.Equal(t, totalPayload-int64(totalRemovedpayload), mm.payloadSize())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue