forked from TrueCloudLab/frostfs-node
[#242] node: Add tracing spans
Add tracing spans for PUT requests. Add tracing spans for DELETE requests. Add tracing spans for SELECT requests. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
200fc8b882
commit
d62c6e4ce6
122 changed files with 863 additions and 417 deletions
|
@ -1,6 +1,7 @@
|
|||
package meta_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
|
@ -20,8 +21,8 @@ func TestDB_Lock(t *testing.T) {
|
|||
db := newDB(t)
|
||||
|
||||
t.Run("empty locked list", func(t *testing.T) {
|
||||
require.Panics(t, func() { _ = db.Lock(cnr, oid.ID{}, nil) })
|
||||
require.Panics(t, func() { _ = db.Lock(cnr, oid.ID{}, []oid.ID{}) })
|
||||
require.Panics(t, func() { _ = db.Lock(context.Background(), cnr, oid.ID{}, nil) })
|
||||
require.Panics(t, func() { _ = db.Lock(context.Background(), cnr, oid.ID{}, []oid.ID{}) })
|
||||
})
|
||||
|
||||
t.Run("(ir)regular", func(t *testing.T) {
|
||||
|
@ -44,7 +45,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
id, _ := obj.ID()
|
||||
|
||||
// try to lock it
|
||||
err = db.Lock(cnr, oidtest.ID(), []oid.ID{id})
|
||||
err = db.Lock(context.Background(), cnr, oidtest.ID(), []oid.ID{id})
|
||||
if typ == object.TypeRegular {
|
||||
require.NoError(t, err, typ)
|
||||
} else {
|
||||
|
@ -65,27 +66,27 @@ func TestDB_Lock(t *testing.T) {
|
|||
// check locking relation
|
||||
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err := db.Inhume(inhumePrm)
|
||||
_, err := db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
// try to remove lock object
|
||||
inhumePrm.SetAddresses(lockAddr)
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.Error(t, err)
|
||||
|
||||
// check that locking relation has not been
|
||||
// dropped
|
||||
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
})
|
||||
|
||||
|
@ -105,7 +106,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
inhumePrm.SetForceGCMark()
|
||||
inhumePrm.SetLockObjectHandling()
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
res, err := db.Inhume(context.Background(), inhumePrm)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.DeletedLockObjects(), 1)
|
||||
require.Equal(t, objectcore.AddressOf(lockObj), res.DeletedLockObjects()[0])
|
||||
|
@ -117,7 +118,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
inhumePrm.SetGCMark()
|
||||
|
||||
// now we can inhume the object
|
||||
_, err = db.Inhume(inhumePrm)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
@ -134,7 +135,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
|
||||
inhumePrm.SetLockObjectHandling()
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
res, err := db.Inhume(context.Background(), inhumePrm)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.DeletedLockObjects(), 1)
|
||||
require.Equal(t, objectcore.AddressOf(lockObj), res.DeletedLockObjects()[0])
|
||||
|
@ -151,7 +152,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
for i := 0; i < objsNum; i++ {
|
||||
inhumePrm.SetAddresses(objectcore.AddressOf(objs[i]))
|
||||
|
||||
res, err = db.Inhume(inhumePrm)
|
||||
res, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.DeletedLockObjects(), 0)
|
||||
}
|
||||
|
@ -164,7 +165,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
inhumePrm.SetForceGCMark()
|
||||
inhumePrm.SetAddresses(objectcore.AddressOf(lockObj))
|
||||
|
||||
res, err := db.Inhume(inhumePrm)
|
||||
res, err := db.Inhume(context.Background(), inhumePrm)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res.DeletedLockObjects(), 0)
|
||||
})
|
||||
|
@ -184,7 +185,7 @@ func TestDB_Lock_Expired(t *testing.T) {
|
|||
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
|
||||
|
||||
// lock the obj
|
||||
require.NoError(t, db.Lock(addr.Container(), oidtest.ID(), []oid.ID{addr.Object()}))
|
||||
require.NoError(t, db.Lock(context.Background(), addr.Container(), oidtest.ID(), []oid.ID{addr.Object()}))
|
||||
|
||||
// object is expired but locked, thus, must be available
|
||||
_, err = metaGet(db, addr, false)
|
||||
|
@ -202,7 +203,7 @@ func TestDB_IsLocked(t *testing.T) {
|
|||
for _, obj := range objs {
|
||||
prm.SetAddress(objectcore.AddressOf(obj))
|
||||
|
||||
res, err := db.IsLocked(prm)
|
||||
res, err := db.IsLocked(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.True(t, res.Locked())
|
||||
|
@ -212,7 +213,7 @@ func TestDB_IsLocked(t *testing.T) {
|
|||
|
||||
prm.SetAddress(oidtest.Address())
|
||||
|
||||
res, err := db.IsLocked(prm)
|
||||
res, err := db.IsLocked(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.False(t, res.Locked())
|
||||
|
@ -224,12 +225,12 @@ func TestDB_IsLocked(t *testing.T) {
|
|||
var putPrm meta.PutPrm
|
||||
putPrm.SetObject(obj)
|
||||
|
||||
_, err = db.Put(putPrm)
|
||||
_, err = db.Put(context.Background(), putPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
prm.SetAddress(objectcore.AddressOf(obj))
|
||||
|
||||
res, err = db.IsLocked(prm)
|
||||
res, err = db.IsLocked(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.False(t, res.Locked())
|
||||
|
@ -260,7 +261,7 @@ func putAndLockObj(t *testing.T, db *meta.DB, numOfLockedObjs int) ([]*object.Ob
|
|||
err := putBig(db, lockObj)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = db.Lock(cnr, lockID, lockedObjIDs)
|
||||
err = db.Lock(context.Background(), cnr, lockID, lockedObjIDs)
|
||||
require.NoError(t, err)
|
||||
|
||||
return lockedObjs, lockObj
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue