2020-10-28 15:28:06 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
package metabasetest
|
2020-10-28 15:28:06 +00:00
|
|
|
|
|
|
|
import (
|
2021-05-14 09:57:14 +01:00
|
|
|
"bytes"
|
2020-10-29 18:10:46 +00:00
|
|
|
"context"
|
2020-11-03 15:51:03 +00:00
|
|
|
"sort"
|
2020-10-28 15:28:06 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"github.com/google/go-cmp/cmp/cmpopts"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
|
2020-11-02 15:28:51 +00:00
|
|
|
"storj.io/common/storj"
|
2020-10-28 15:28:06 +00:00
|
|
|
"storj.io/common/testcontext"
|
2021-04-21 13:42:57 +01:00
|
|
|
"storj.io/storj/satellite/metabase"
|
2020-10-28 15:28:06 +00:00
|
|
|
)
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// BeginObjectNextVersion is for testing metabase.BeginObjectNextVersion.
|
2020-10-28 15:28:06 +00:00
|
|
|
type BeginObjectNextVersion struct {
|
|
|
|
Opts metabase.BeginObjectNextVersion
|
|
|
|
Version metabase.Version
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step BeginObjectNextVersion) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
got, err := db.BeginObjectNextVersion(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
2022-09-07 16:43:17 +01:00
|
|
|
|
|
|
|
if step.ErrClass == nil {
|
|
|
|
require.Equal(t, step.Version, got.Version)
|
|
|
|
require.WithinDuration(t, time.Now(), got.CreatedAt, 5*time.Second)
|
|
|
|
|
|
|
|
require.Equal(t, step.Opts.ObjectStream.ProjectID, got.ObjectStream.ProjectID)
|
|
|
|
require.Equal(t, step.Opts.ObjectStream.BucketName, got.ObjectStream.BucketName)
|
|
|
|
require.Equal(t, step.Opts.ObjectStream.ObjectKey, got.ObjectStream.ObjectKey)
|
|
|
|
require.Equal(t, step.Opts.ObjectStream.StreamID, got.ObjectStream.StreamID)
|
|
|
|
require.Equal(t, metabase.Pending, got.Status)
|
|
|
|
|
|
|
|
require.Equal(t, step.Opts.ExpiresAt, got.ExpiresAt)
|
|
|
|
|
|
|
|
gotDeadline := got.ZombieDeletionDeadline
|
|
|
|
optsDeadline := step.Opts.ZombieDeletionDeadline
|
|
|
|
if optsDeadline == nil {
|
|
|
|
require.WithinDuration(t, time.Now().Add(24*time.Hour), *gotDeadline, 5*time.Second)
|
|
|
|
} else {
|
|
|
|
require.WithinDuration(t, *optsDeadline, *gotDeadline, 5*time.Second)
|
|
|
|
}
|
|
|
|
require.Equal(t, step.Opts.Encryption, got.Encryption)
|
|
|
|
}
|
2020-10-28 15:28:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// BeginObjectExactVersion is for testing metabase.BeginObjectExactVersion.
|
2020-10-28 15:28:06 +00:00
|
|
|
type BeginObjectExactVersion struct {
|
|
|
|
Opts metabase.BeginObjectExactVersion
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2022-08-01 10:50:46 +01:00
|
|
|
func (step BeginObjectExactVersion) Check(ctx *testcontext.Context, t require.TestingT, db *metabase.DB) {
|
2023-10-02 14:14:52 +01:00
|
|
|
got, err := db.TestingBeginObjectExactVersion(ctx, step.Opts)
|
2020-10-28 15:28:06 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
2021-01-12 11:29:13 +00:00
|
|
|
if step.ErrClass == nil {
|
2023-09-15 17:30:47 +01:00
|
|
|
require.Equal(t, step.Opts.Version, got.Version)
|
2021-01-12 11:29:13 +00:00
|
|
|
require.WithinDuration(t, time.Now(), got.CreatedAt, 5*time.Second)
|
|
|
|
require.Equal(t, step.Opts.ObjectStream, got.ObjectStream)
|
|
|
|
require.Equal(t, step.Opts.ExpiresAt, got.ExpiresAt)
|
2021-05-06 12:42:20 +01:00
|
|
|
|
|
|
|
gotDeadline := got.ZombieDeletionDeadline
|
|
|
|
optsDeadline := step.Opts.ZombieDeletionDeadline
|
|
|
|
if optsDeadline == nil {
|
|
|
|
require.WithinDuration(t, time.Now().Add(24*time.Hour), *gotDeadline, 5*time.Second)
|
|
|
|
} else {
|
|
|
|
require.WithinDuration(t, *optsDeadline, *gotDeadline, 5*time.Second)
|
|
|
|
}
|
2021-01-12 11:29:13 +00:00
|
|
|
require.Equal(t, step.Opts.Encryption, got.Encryption)
|
|
|
|
}
|
2020-10-28 15:28:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// CommitObject is for testing metabase.CommitObject.
|
2020-10-28 15:28:06 +00:00
|
|
|
type CommitObject struct {
|
|
|
|
Opts metabase.CommitObject
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2022-08-01 10:50:46 +01:00
|
|
|
func (step CommitObject) Check(ctx *testcontext.Context, t require.TestingT, db *metabase.DB) metabase.Object {
|
2020-11-02 17:25:58 +00:00
|
|
|
object, err := db.CommitObject(ctx, step.Opts)
|
2020-10-28 15:28:06 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
2020-11-02 17:25:58 +00:00
|
|
|
if err == nil {
|
|
|
|
require.Equal(t, step.Opts.ObjectStream, object.ObjectStream)
|
|
|
|
}
|
|
|
|
return object
|
2020-10-28 15:28:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// CommitObjectWithSegments is for testing metabase.CommitObjectWithSegments.
|
2020-11-12 11:29:19 +00:00
|
|
|
type CommitObjectWithSegments struct {
|
|
|
|
Opts metabase.CommitObjectWithSegments
|
|
|
|
Deleted []metabase.DeletedSegmentInfo
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step CommitObjectWithSegments) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) metabase.Object {
|
2020-11-12 11:29:19 +00:00
|
|
|
object, deleted, err := db.CommitObjectWithSegments(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
if err == nil {
|
|
|
|
require.Equal(t, step.Opts.ObjectStream, object.ObjectStream)
|
|
|
|
}
|
|
|
|
require.Equal(t, step.Deleted, deleted)
|
|
|
|
return object
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// BeginSegment is for testing metabase.BeginSegment.
|
2020-10-28 15:28:06 +00:00
|
|
|
type BeginSegment struct {
|
|
|
|
Opts metabase.BeginSegment
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2022-08-01 10:50:46 +01:00
|
|
|
func (step BeginSegment) Check(ctx *testcontext.Context, t require.TestingT, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
err := db.BeginSegment(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// CommitSegment is for testing metabase.CommitSegment.
|
2020-10-28 15:28:06 +00:00
|
|
|
type CommitSegment struct {
|
|
|
|
Opts metabase.CommitSegment
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2022-08-01 10:50:46 +01:00
|
|
|
func (step CommitSegment) Check(ctx *testcontext.Context, t require.TestingT, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
err := db.CommitSegment(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// CommitInlineSegment is for testing metabase.CommitInlineSegment.
|
2020-10-28 15:28:06 +00:00
|
|
|
type CommitInlineSegment struct {
|
|
|
|
Opts metabase.CommitInlineSegment
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step CommitInlineSegment) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
err := db.CommitInlineSegment(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// DeleteBucketObjects is for testing metabase.DeleteBucketObjects.
|
2020-12-09 12:24:37 +00:00
|
|
|
type DeleteBucketObjects struct {
|
|
|
|
Opts metabase.DeleteBucketObjects
|
|
|
|
Deleted int64
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step DeleteBucketObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-12-09 12:24:37 +00:00
|
|
|
deleted, err := db.DeleteBucketObjects(ctx, step.Opts)
|
|
|
|
require.Equal(t, step.Deleted, deleted)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-07-08 15:50:37 +01:00
|
|
|
// UpdateObjectMetadata is for testing metabase.UpdateObjectMetadata.
|
|
|
|
type UpdateObjectMetadata struct {
|
|
|
|
Opts metabase.UpdateObjectMetadata
|
2020-11-02 16:32:24 +00:00
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-07-08 15:50:37 +01:00
|
|
|
func (step UpdateObjectMetadata) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
err := db.UpdateObjectMetadata(ctx, step.Opts)
|
2020-11-02 16:32:24 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// UpdateSegmentPieces is for testing metabase.UpdateSegmentPieces.
|
2020-12-11 12:09:59 +00:00
|
|
|
type UpdateSegmentPieces struct {
|
|
|
|
Opts metabase.UpdateSegmentPieces
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step UpdateSegmentPieces) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-12-11 12:09:59 +00:00
|
|
|
err := db.UpdateSegmentPieces(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// GetObjectExactVersion is for testing metabase.GetObjectExactVersion.
|
2020-10-28 15:28:06 +00:00
|
|
|
type GetObjectExactVersion struct {
|
|
|
|
Opts metabase.GetObjectExactVersion
|
|
|
|
Result metabase.Object
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step GetObjectExactVersion) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
result, err := db.GetObjectExactVersion(ctx, step.Opts)
|
2021-02-01 18:02:15 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2021-02-01 18:02:15 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:41:00 +01:00
|
|
|
// GetObjectLastCommitted is for testing metabase.GetObjectLastCommitted.
|
|
|
|
type GetObjectLastCommitted struct {
|
|
|
|
Opts metabase.GetObjectLastCommitted
|
|
|
|
Result metabase.Object
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step GetObjectLastCommitted) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.GetObjectLastCommitted(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
diff := cmp.Diff(step.Result, result, cmpopts.EquateApproxTime(5*time.Second))
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// GetSegmentByPosition is for testing metabase.GetSegmentByPosition.
|
2020-10-28 15:28:06 +00:00
|
|
|
type GetSegmentByPosition struct {
|
|
|
|
Opts metabase.GetSegmentByPosition
|
|
|
|
Result metabase.Segment
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step GetSegmentByPosition) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
result, err := db.GetSegmentByPosition(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2020-10-28 15:28:06 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// GetLatestObjectLastSegment is for testing metabase.GetLatestObjectLastSegment.
|
2020-11-03 15:03:20 +00:00
|
|
|
type GetLatestObjectLastSegment struct {
|
|
|
|
Opts metabase.GetLatestObjectLastSegment
|
|
|
|
Result metabase.Segment
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step GetLatestObjectLastSegment) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-11-03 15:03:20 +00:00
|
|
|
result, err := db.GetLatestObjectLastSegment(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2020-11-03 15:03:20 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// BucketEmpty is for testing metabase.BucketEmpty.
|
2020-11-17 17:37:58 +00:00
|
|
|
type BucketEmpty struct {
|
|
|
|
Opts metabase.BucketEmpty
|
|
|
|
Result bool
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step BucketEmpty) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-11-17 17:37:58 +00:00
|
|
|
result, err := db.BucketEmpty(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
require.Equal(t, step.Result, result)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// ListSegments is for testing metabase.ListSegments.
|
2020-11-05 12:59:19 +00:00
|
|
|
type ListSegments struct {
|
|
|
|
Opts metabase.ListSegments
|
|
|
|
Result metabase.ListSegmentsResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step ListSegments) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-11-05 12:59:19 +00:00
|
|
|
result, err := db.ListSegments(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
2022-03-01 12:08:09 +00:00
|
|
|
if len(step.Result.Segments) == 0 && len(result.Segments) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2022-09-12 14:28:24 +01:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListVerifySegments is for testing metabase.ListVerifySegments.
|
|
|
|
type ListVerifySegments struct {
|
|
|
|
Opts metabase.ListVerifySegments
|
|
|
|
Result metabase.ListVerifySegmentsResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step ListVerifySegments) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.ListVerifySegments(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff(), cmpopts.EquateEmpty())
|
2022-06-01 13:44:12 +01:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListObjects is for testing metabase.ListObjects.
|
|
|
|
type ListObjects struct {
|
|
|
|
Opts metabase.ListObjects
|
|
|
|
Result metabase.ListObjectsResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step ListObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.ListObjects(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff(), cmpopts.EquateEmpty())
|
2020-11-05 12:59:19 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// ListStreamPositions is for testing metabase.ListStreamPositions.
|
2021-03-08 12:09:22 +00:00
|
|
|
type ListStreamPositions struct {
|
|
|
|
Opts metabase.ListStreamPositions
|
|
|
|
Result metabase.ListStreamPositionsResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-03-08 12:09:22 +00:00
|
|
|
func (step ListStreamPositions) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.ListStreamPositions(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2021-03-08 12:09:22 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// GetStreamPieceCountByNodeID is for testing metabase.GetStreamPieceCountByNodeID.
|
2021-03-08 13:09:32 +00:00
|
|
|
type GetStreamPieceCountByNodeID struct {
|
|
|
|
Opts metabase.GetStreamPieceCountByNodeID
|
|
|
|
Result map[storj.NodeID]int64
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-03-08 13:09:32 +00:00
|
|
|
func (step GetStreamPieceCountByNodeID) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.GetStreamPieceCountByNodeID(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result)
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-05-14 09:57:14 +01:00
|
|
|
// IterateLoopSegments is for testing metabase.IterateLoopSegments.
|
|
|
|
type IterateLoopSegments struct {
|
|
|
|
Opts metabase.IterateLoopSegments
|
|
|
|
Result []metabase.LoopSegmentEntry
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step IterateLoopSegments) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result := make([]metabase.LoopSegmentEntry, 0, 10)
|
|
|
|
err := db.IterateLoopSegments(ctx, step.Opts,
|
|
|
|
func(ctx context.Context, iterator metabase.LoopSegmentsIterator) error {
|
|
|
|
var entry metabase.LoopSegmentEntry
|
|
|
|
for iterator.Next(ctx, &entry) {
|
|
|
|
result = append(result, entry)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
if len(result) == 0 {
|
|
|
|
result = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(step.Result, func(i, j int) bool {
|
2022-10-06 12:27:08 +01:00
|
|
|
if step.Result[i].StreamID == step.Result[j].StreamID {
|
|
|
|
return step.Result[i].Position.Less(step.Result[j].Position)
|
|
|
|
}
|
2021-05-14 09:57:14 +01:00
|
|
|
return bytes.Compare(step.Result[i].StreamID[:], step.Result[j].StreamID[:]) < 0
|
|
|
|
})
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2021-05-14 09:57:14 +01:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// DeleteObjectExactVersion is for testing metabase.DeleteObjectExactVersion.
|
2020-10-28 15:28:06 +00:00
|
|
|
type DeleteObjectExactVersion struct {
|
|
|
|
Opts metabase.DeleteObjectExactVersion
|
|
|
|
Result metabase.DeleteObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step DeleteObjectExactVersion) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-28 15:28:06 +00:00
|
|
|
result, err := db.DeleteObjectExactVersion(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
2021-05-07 10:36:02 +01:00
|
|
|
sortObjects(result.Objects)
|
|
|
|
sortObjects(step.Result.Objects)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff(), cmpopts.EquateEmpty())
|
2020-10-28 15:28:06 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// DeletePendingObject is for testing metabase.DeletePendingObject.
|
2020-12-01 23:17:05 +00:00
|
|
|
type DeletePendingObject struct {
|
|
|
|
Opts metabase.DeletePendingObject
|
|
|
|
Result metabase.DeleteObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step DeletePendingObject) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-12-01 23:17:05 +00:00
|
|
|
result, err := db.DeletePendingObject(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
2021-05-07 10:36:02 +01:00
|
|
|
sortObjects(result.Objects)
|
|
|
|
sortObjects(step.Result.Objects)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2020-12-01 23:17:05 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2023-08-09 10:19:12 +01:00
|
|
|
// DeletePendingObjectNew is for testing metabase.DeletePendingObjectNew.
|
|
|
|
type DeletePendingObjectNew struct {
|
|
|
|
Opts metabase.DeletePendingObject
|
|
|
|
Result metabase.DeleteObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step DeletePendingObjectNew) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.DeletePendingObjectNew(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
sortObjects(result.Objects)
|
|
|
|
sortObjects(step.Result.Objects)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// DeleteObjectsAllVersions is for testing metabase.DeleteObjectsAllVersions.
|
2020-11-03 15:51:03 +00:00
|
|
|
type DeleteObjectsAllVersions struct {
|
|
|
|
Opts metabase.DeleteObjectsAllVersions
|
|
|
|
Result metabase.DeleteObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step DeleteObjectsAllVersions) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-11-03 15:51:03 +00:00
|
|
|
result, err := db.DeleteObjectsAllVersions(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
2020-11-09 14:55:10 +00:00
|
|
|
sortObjects(result.Objects)
|
|
|
|
sortObjects(step.Result.Objects)
|
2020-11-03 15:51:03 +00:00
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2020-11-03 15:51:03 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// DeleteExpiredObjects is for testing metabase.DeleteExpiredObjects.
|
2020-11-09 14:55:10 +00:00
|
|
|
type DeleteExpiredObjects struct {
|
2021-04-16 10:14:27 +01:00
|
|
|
Opts metabase.DeleteExpiredObjects
|
|
|
|
|
2020-11-09 14:55:10 +00:00
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step DeleteExpiredObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2021-04-16 10:14:27 +01:00
|
|
|
err := db.DeleteExpiredObjects(ctx, step.Opts)
|
2020-11-09 14:55:10 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-29 10:21:29 +01:00
|
|
|
// DeleteZombieObjects is for testing metabase.DeleteZombieObjects.
|
|
|
|
type DeleteZombieObjects struct {
|
|
|
|
Opts metabase.DeleteZombieObjects
|
|
|
|
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step DeleteZombieObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
err := db.DeleteZombieObjects(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2023-08-09 12:25:33 +01:00
|
|
|
// DeleteInactivePendingObjects is for testing metabase.DeleteInactivePendingObjects.
|
|
|
|
type DeleteInactivePendingObjects struct {
|
|
|
|
Opts metabase.DeleteZombieObjects
|
|
|
|
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step DeleteInactivePendingObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
err := db.DeleteInactivePendingObjects(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// IterateCollector is for testing metabase.IterateCollector.
|
2020-10-29 18:10:46 +00:00
|
|
|
type IterateCollector []metabase.ObjectEntry
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Add adds object entries from iterator to the collection.
|
2020-10-29 18:10:46 +00:00
|
|
|
func (coll *IterateCollector) Add(ctx context.Context, it metabase.ObjectsIterator) error {
|
|
|
|
var item metabase.ObjectEntry
|
|
|
|
|
|
|
|
for it.Next(ctx, &item) {
|
|
|
|
*coll = append(*coll, item)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// LoopIterateCollector is for testing metabase.LoopIterateCollector.
|
2021-03-01 14:29:03 +00:00
|
|
|
type LoopIterateCollector []metabase.LoopObjectEntry
|
2021-02-18 12:54:09 +00:00
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Add adds object entries from iterator to the collection.
|
2021-03-01 14:29:03 +00:00
|
|
|
func (coll *LoopIterateCollector) Add(ctx context.Context, it metabase.LoopObjectsIterator) error {
|
|
|
|
var item metabase.LoopObjectEntry
|
2021-02-18 12:54:09 +00:00
|
|
|
|
|
|
|
for it.Next(ctx, &item) {
|
|
|
|
*coll = append(*coll, item)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-31 13:23:19 +01:00
|
|
|
// PendingObjectsCollector is for testing metabase.PendingObjectsCollector.
|
|
|
|
type PendingObjectsCollector []metabase.PendingObjectEntry
|
|
|
|
|
|
|
|
// Add adds object entries from iterator to the collection.
|
|
|
|
func (coll *PendingObjectsCollector) Add(ctx context.Context, it metabase.PendingObjectsIterator) error {
|
|
|
|
var item metabase.PendingObjectEntry
|
|
|
|
|
|
|
|
for it.Next(ctx, &item) {
|
|
|
|
*coll = append(*coll, item)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// IteratePendingObjectsByKey is for testing metabase.IteratePendingObjectsByKey.
|
2021-01-11 12:06:04 +00:00
|
|
|
type IteratePendingObjectsByKey struct {
|
|
|
|
Opts metabase.IteratePendingObjectsByKey
|
|
|
|
|
|
|
|
Result []metabase.ObjectEntry
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-11 12:06:04 +00:00
|
|
|
func (step IteratePendingObjectsByKey) Check(ctx *testcontext.Context, t *testing.T, db *metabase.DB) {
|
|
|
|
var collector IterateCollector
|
|
|
|
|
|
|
|
err := db.IteratePendingObjectsByKey(ctx, step.Opts, collector.Add)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
result := []metabase.ObjectEntry(collector)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2021-01-11 12:06:04 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2023-08-07 11:04:24 +01:00
|
|
|
// IteratePendingObjectsByKeyNew is for testing metabase.IteratePendingObjectsByKeyNew.
|
|
|
|
type IteratePendingObjectsByKeyNew struct {
|
|
|
|
Opts metabase.IteratePendingObjectsByKey
|
|
|
|
|
|
|
|
Result []metabase.PendingObjectEntry
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step IteratePendingObjectsByKeyNew) Check(ctx *testcontext.Context, t *testing.T, db *metabase.DB) {
|
|
|
|
var collector PendingObjectsCollector
|
|
|
|
|
|
|
|
err := db.IteratePendingObjectsByKeyNew(ctx, step.Opts, collector.Add)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
result := []metabase.PendingObjectEntry(collector)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// IterateObjectsWithStatus is for testing metabase.IterateObjectsWithStatus.
|
2020-12-21 15:07:00 +00:00
|
|
|
type IterateObjectsWithStatus struct {
|
|
|
|
Opts metabase.IterateObjectsWithStatus
|
2020-10-29 18:10:46 +00:00
|
|
|
|
|
|
|
Result []metabase.ObjectEntry
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-01-22 17:34:08 +00:00
|
|
|
func (step IterateObjectsWithStatus) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
2020-10-29 18:10:46 +00:00
|
|
|
var result IterateCollector
|
|
|
|
|
2020-12-21 15:07:00 +00:00
|
|
|
err := db.IterateObjectsAllVersionsWithStatus(ctx, step.Opts, result.Add)
|
2020-10-29 18:10:46 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, []metabase.ObjectEntry(result), DefaultTimeDiff())
|
2020-10-29 18:10:46 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
2021-02-18 12:54:09 +00:00
|
|
|
|
2023-07-31 13:23:19 +01:00
|
|
|
// IteratePendingObjects is for testing metabase.IteratePendingObjects.
|
|
|
|
type IteratePendingObjects struct {
|
|
|
|
Opts metabase.IteratePendingObjects
|
|
|
|
|
|
|
|
Result []metabase.PendingObjectEntry
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step IteratePendingObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
var result PendingObjectsCollector
|
|
|
|
|
|
|
|
err := db.IteratePendingObjects(ctx, step.Opts, result.Add)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, []metabase.PendingObjectEntry(result), DefaultTimeDiff())
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// IterateLoopObjects is for testing metabase.IterateLoopObjects.
|
2021-03-01 14:29:03 +00:00
|
|
|
type IterateLoopObjects struct {
|
|
|
|
Opts metabase.IterateLoopObjects
|
2021-02-18 12:54:09 +00:00
|
|
|
|
2021-03-01 14:29:03 +00:00
|
|
|
Result []metabase.LoopObjectEntry
|
2021-02-18 12:54:09 +00:00
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-03-01 14:29:03 +00:00
|
|
|
func (step IterateLoopObjects) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
var result LoopIterateCollector
|
2021-02-18 12:54:09 +00:00
|
|
|
|
2021-03-01 14:29:03 +00:00
|
|
|
err := db.IterateLoopObjects(ctx, step.Opts, result.Add)
|
2021-02-18 12:54:09 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, []metabase.LoopObjectEntry(result), DefaultTimeDiff())
|
2021-02-18 12:54:09 +00:00
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
2020-10-29 18:10:46 +00:00
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// EnsureNodeAliases is for testing metabase.EnsureNodeAliases.
|
2021-02-04 15:12:34 +00:00
|
|
|
type EnsureNodeAliases struct {
|
|
|
|
Opts metabase.EnsureNodeAliases
|
|
|
|
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-02-04 15:12:34 +00:00
|
|
|
func (step EnsureNodeAliases) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
err := db.EnsureNodeAliases(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// ListNodeAliases is for testing metabase.ListNodeAliases.
|
2021-02-04 15:12:34 +00:00
|
|
|
type ListNodeAliases struct {
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
2021-04-26 10:35:44 +01:00
|
|
|
// Check runs the test.
|
2021-02-04 15:12:34 +00:00
|
|
|
func (step ListNodeAliases) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) []metabase.NodeAliasEntry {
|
|
|
|
result, err := db.ListNodeAliases(ctx)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
return result
|
|
|
|
}
|
2021-04-30 12:02:24 +01:00
|
|
|
|
2021-06-07 10:20:06 +01:00
|
|
|
// GetTableStats is for testing metabase.GetTableStats.
|
|
|
|
type GetTableStats struct {
|
|
|
|
Opts metabase.GetTableStats
|
|
|
|
Result metabase.TableStats
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step GetTableStats) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) metabase.TableStats {
|
|
|
|
result, err := db.GetTableStats(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result)
|
|
|
|
require.Zero(t, diff)
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
2021-08-16 13:04:33 +01:00
|
|
|
|
|
|
|
// BeginMoveObject is for testing metabase.BeginMoveObject.
|
|
|
|
type BeginMoveObject struct {
|
|
|
|
Opts metabase.BeginMoveObject
|
|
|
|
Result metabase.BeginMoveObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step BeginMoveObject) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.BeginMoveObject(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result)
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
2021-08-31 12:44:18 +01:00
|
|
|
|
|
|
|
// FinishMoveObject is for testing metabase.FinishMoveObject.
|
|
|
|
type FinishMoveObject struct {
|
|
|
|
Opts metabase.FinishMoveObject
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step FinishMoveObject) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
err := db.FinishMoveObject(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
}
|
2021-11-22 13:56:58 +00:00
|
|
|
|
2022-01-27 00:01:03 +00:00
|
|
|
// BeginCopyObject is for testing metabase.BeginCopyObject.
|
|
|
|
type BeginCopyObject struct {
|
|
|
|
Opts metabase.BeginCopyObject
|
|
|
|
Result metabase.BeginCopyObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step BeginCopyObject) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.BeginCopyObject(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result)
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FinishCopyObject is for testing metabase.FinishCopyObject.
|
|
|
|
type FinishCopyObject struct {
|
|
|
|
Opts metabase.FinishCopyObject
|
2022-02-24 10:54:57 +00:00
|
|
|
Result metabase.Object
|
2022-01-27 00:01:03 +00:00
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
2022-03-16 10:17:27 +00:00
|
|
|
func (step FinishCopyObject) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) metabase.Object {
|
2022-02-24 10:54:57 +00:00
|
|
|
result, err := db.FinishCopyObject(ctx, step.Opts)
|
2022-01-27 00:01:03 +00:00
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
2022-02-24 10:54:57 +00:00
|
|
|
|
satellite/metabase/test: extend default time diff for comparison
Tests are intermittently fail with similar error:
```
--- FAIL: TestDeletePendingObject/Cockroach (15.85s)
test.go:380:
Error Trace: test.go:380
delete_test.go:221
Error: Should be zero, but was metabase.DeleteObjectResult{
Objects: []metabase.Object{
{
ObjectStream: {ProjectID: {0x0f, 0x40, 0x70, 0x41, ...}, BucketName: "txxywyg4", ObjectKey: "\xbb+$\x17\x80\xc6\xcaC\xa3\xdb\xc3z*\xa8\xbe\xaf", Version: 1, ...},
- CreatedAt: s"2022-05-20 14:40:15.995376773 +0200 CEST",
+ CreatedAt: s"2022-05-20 14:40:21.04949 +0200 CEST",
ExpiresAt: nil,
Status: 1,
... // 9 identical fields
},
},
Segments: {{RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}, {RootPieceID: {0x01, 0x00, 0x00, 0x00, ...}, Pieces: {{...}}}},
}
Test: TestDeletePendingObject/Cockroach/with_segments
--- FAIL: TestDeletePendingObject/Cockroach/with_segments (0.68s)
```
Looks like we shouldn't have an assumption that all tests can be finished in 5 seconds, especially not in highly parallel environment.
These tests use `time.Now` at the beginning and compare the time saved in the database (usually filled by the database).
The difference shouldn't be higher than 20 seconds (before this commit: 5 seconds) which assumes that the records are saved in this timeframe...
Change-Id: Ia6f52897d13f88c6857c05d728bf8e72ab863c9b
2022-05-20 13:57:34 +01:00
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff())
|
2022-02-24 10:54:57 +00:00
|
|
|
require.Zero(t, diff)
|
2022-03-16 10:17:27 +00:00
|
|
|
return result
|
2022-01-27 00:01:03 +00:00
|
|
|
}
|
2022-08-31 12:49:30 +01:00
|
|
|
|
|
|
|
// DeleteObjectLastCommitted is for testing metabase.DeleteObjectLastCommitted.
|
|
|
|
type DeleteObjectLastCommitted struct {
|
|
|
|
Opts metabase.DeleteObjectLastCommitted
|
|
|
|
Result metabase.DeleteObjectResult
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step DeleteObjectLastCommitted) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.DeleteObjectLastCommitted(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
sortObjects(result.Objects)
|
|
|
|
sortObjects(step.Result.Objects)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff(), cmpopts.EquateEmpty())
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|
2022-10-05 11:22:23 +01:00
|
|
|
|
|
|
|
// CollectBucketTallies is for testing metabase.CollectBucketTallies.
|
|
|
|
type CollectBucketTallies struct {
|
|
|
|
Opts metabase.CollectBucketTallies
|
|
|
|
Result []metabase.BucketTally
|
|
|
|
ErrClass *errs.Class
|
|
|
|
ErrText string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check runs the test.
|
|
|
|
func (step CollectBucketTallies) Check(ctx *testcontext.Context, t testing.TB, db *metabase.DB) {
|
|
|
|
result, err := db.CollectBucketTallies(ctx, step.Opts)
|
|
|
|
checkError(t, err, step.ErrClass, step.ErrText)
|
|
|
|
|
|
|
|
sortBucketTallies(result)
|
|
|
|
sortBucketTallies(step.Result)
|
|
|
|
|
|
|
|
diff := cmp.Diff(step.Result, result, DefaultTimeDiff(), cmpopts.EquateEmpty())
|
|
|
|
require.Zero(t, diff)
|
|
|
|
}
|