[#633] shard/test: Fix TestCounters()
All checks were successful
DCO action / DCO (pull_request) Successful in 5m3s
Vulncheck / Vulncheck (pull_request) Successful in 5m45s
Build / Build Components (1.21) (pull_request) Successful in 6m15s
Build / Build Components (1.20) (pull_request) Successful in 6m24s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m40s
Tests and linters / Staticcheck (pull_request) Successful in 7m29s
Tests and linters / Lint (pull_request) Successful in 8m1s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m52s
Tests and linters / Tests with -race (pull_request) Successful in 9m17s
All checks were successful
DCO action / DCO (pull_request) Successful in 5m3s
Vulncheck / Vulncheck (pull_request) Successful in 5m45s
Build / Build Components (1.21) (pull_request) Successful in 6m15s
Build / Build Components (1.20) (pull_request) Successful in 6m24s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m40s
Tests and linters / Staticcheck (pull_request) Successful in 7m29s
Tests and linters / Lint (pull_request) Successful in 8m1s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m52s
Tests and linters / Tests with -race (pull_request) Successful in 9m17s
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
ac51de9230
commit
93da4ed617
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.SetContainerID(cnr)
|
||||||
obj.SetVersion(&ver)
|
obj.SetVersion(&ver)
|
||||||
obj.SetPayload(data)
|
obj.SetPayload(data)
|
||||||
|
obj.SetPayloadSize(uint64(len(data)))
|
||||||
obj.SetPayloadChecksum(csum)
|
obj.SetPayloadChecksum(csum)
|
||||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
|
||||||
|
@ -151,11 +152,11 @@ func TestCounters(t *testing.T) {
|
||||||
|
|
||||||
var totalPayload int64
|
var totalPayload int64
|
||||||
|
|
||||||
expectedSizes := make(map[string]int64)
|
expectedLogicalSizes := make(map[string]int64)
|
||||||
for i := range oo {
|
for i := range oo {
|
||||||
cnr, _ := oo[i].ContainerID()
|
cnr, _ := oo[i].ContainerID()
|
||||||
oSize := int64(oo[i].PayloadSize())
|
oSize := int64(oo[i].PayloadSize())
|
||||||
expectedSizes[cnr.EncodeToString()] += oSize
|
expectedLogicalSizes[cnr.EncodeToString()] += oSize
|
||||||
totalPayload += 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(physical))
|
||||||
require.Equal(t, uint64(objNumber), mm.getObjectCounter(logical))
|
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())
|
require.Equal(t, totalPayload, mm.payloadSize())
|
||||||
|
|
||||||
t.Run("inhume_GC", func(t *testing.T) {
|
t.Run("inhume_GC", func(t *testing.T) {
|
||||||
|
@ -182,11 +183,15 @@ func TestCounters(t *testing.T) {
|
||||||
|
|
||||||
_, err := sh.Inhume(context.Background(), prm)
|
_, err := sh.Inhume(context.Background(), prm)
|
||||||
require.NoError(t, err)
|
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), mm.getObjectCounter(physical))
|
||||||
require.Equal(t, uint64(objNumber-inhumedNumber), mm.getObjectCounter(logical))
|
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())
|
require.Equal(t, totalPayload, mm.payloadSize())
|
||||||
|
|
||||||
oo = oo[inhumedNumber:]
|
oo = oo[inhumedNumber:]
|
||||||
|
@ -205,9 +210,15 @@ func TestCounters(t *testing.T) {
|
||||||
_, err := sh.Inhume(context.Background(), prm)
|
_, err := sh.Inhume(context.Background(), prm)
|
||||||
require.NoError(t, err)
|
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, phy, mm.getObjectCounter(physical))
|
||||||
require.Equal(t, logic-uint64(inhumedNumber), mm.getObjectCounter(logical))
|
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())
|
require.Equal(t, totalPayload, mm.payloadSize())
|
||||||
|
|
||||||
oo = oo[inhumedNumber:]
|
oo = oo[inhumedNumber:]
|
||||||
|
@ -233,9 +244,9 @@ func TestCounters(t *testing.T) {
|
||||||
totalRemovedpayload += removedPayload
|
totalRemovedpayload += removedPayload
|
||||||
|
|
||||||
cnr, _ := oo[i].ContainerID()
|
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())
|
require.Equal(t, totalPayload-int64(totalRemovedpayload), mm.payloadSize())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue