Ekaterina Lebedeva
a685fcdc96
All checks were successful
DCO action / DCO (pull_request) Successful in 2m41s
Tests and linters / Run gofumpt (pull_request) Successful in 2m32s
Vulncheck / Vulncheck (pull_request) Successful in 2m38s
Build / Build Components (1.23) (pull_request) Successful in 3m0s
Build / Build Components (1.22) (pull_request) Successful in 3m3s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m33s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m34s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m36s
Tests and linters / Staticcheck (pull_request) Successful in 3m35s
Tests and linters / Lint (pull_request) Successful in 4m18s
Tests and linters / Tests with -race (pull_request) Successful in 4m20s
Tests and linters / gopls check (pull_request) Successful in 4m25s
Since Go 1.22 a "for" statement with a "range" clause is able to iterate through integer values from zero to an upper limit. gopatch script: @@ var i, e expression @@ -for i := 0; i <= e - 1; i++ { +for i := range e { ... } @@ var i, e expression @@ -for i := 0; i <= e; i++ { +for i := range e + 1 { ... } @@ var i, e expression @@ -for i := 0; i < e; i++ { +for i := range e { ... } Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package meta
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
|
"github.com/stretchr/testify/require"
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
type epochState struct{ e uint64 }
|
|
|
|
func (s epochState) CurrentEpoch() uint64 {
|
|
return s.e
|
|
}
|
|
|
|
func TestResetDropsContainerBuckets(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
db := New(
|
|
[]Option{
|
|
WithPath(filepath.Join(t.TempDir(), "metabase")),
|
|
WithPermissions(0o600),
|
|
WithEpochState(epochState{}),
|
|
}...,
|
|
)
|
|
|
|
require.NoError(t, db.Open(context.Background(), mode.ReadWrite))
|
|
require.NoError(t, db.Init())
|
|
|
|
defer func() { require.NoError(t, db.Close()) }()
|
|
|
|
for idx := range 100 {
|
|
var putPrm PutPrm
|
|
putPrm.SetObject(testutil.GenerateObject())
|
|
putPrm.SetStorageID([]byte(fmt.Sprintf("0/%d", idx)))
|
|
_, err := db.Put(context.Background(), putPrm)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
require.NoError(t, db.Reset())
|
|
|
|
var bucketCount int
|
|
require.NoError(t, db.boltDB.Update(func(tx *bbolt.Tx) error {
|
|
return tx.ForEach(func(name []byte, b *bbolt.Bucket) error {
|
|
_, exists := mStaticBuckets[string(name)]
|
|
require.True(t, exists, "unexpected bucket:"+string(name))
|
|
bucketCount++
|
|
return nil
|
|
})
|
|
}))
|
|
require.Equal(t, len(mStaticBuckets), bucketCount)
|
|
}
|