diff --git a/satellite/accounting/db_test.go b/satellite/accounting/db_test.go index 553dae779..a8d013aa2 100644 --- a/satellite/accounting/db_test.go +++ b/satellite/accounting/db_test.go @@ -24,10 +24,7 @@ import ( ) func TestSaveBucketTallies(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // Setup: create bucket storage tallies projectID := testrand.UUID() @@ -50,10 +47,7 @@ func TestSaveBucketTallies(t *testing.T) { } func TestStorageNodeUsage(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { const days = 30 now := time.Now().UTC() @@ -141,10 +135,7 @@ func TestStorageNodeUsage(t *testing.T) { } func TestProjectLimits(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { proj, err := db.Console().Projects().Insert(ctx, &console.Project{Name: "test", OwnerID: testrand.UUID()}) require.NoError(t, err) diff --git a/satellite/accounting/projectusage_test.go b/satellite/accounting/projectusage_test.go index c2d9073da..601071fce 100644 --- a/satellite/accounting/projectusage_test.go +++ b/satellite/accounting/projectusage_test.go @@ -229,10 +229,7 @@ func createBucketBandwidthRollups(ctx *testcontext.Context, satelliteDB satellit } func TestProjectBandwidthTotal(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { pdb := db.ProjectAccounting() projectID := testrand.UUID() @@ -311,10 +308,7 @@ func TestUsageRollups(t *testing.T) { tallyInterval = time.Hour ) - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { now := time.Now() start := now.Add(tallyInterval * time.Duration(-tallyIntervals)) diff --git a/satellite/attribution/db_test.go b/satellite/attribution/db_test.go index b9ef1a209..0009fa692 100644 --- a/satellite/attribution/db_test.go +++ b/satellite/attribution/db_test.go @@ -62,12 +62,8 @@ func (testData *AttributionTestData) init() { } func TestDB(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { attributionDB := db.Attribution() - project1, project2 := testrand.UUID(), testrand.UUID() partner1, partner2 := testrand.UUID(), testrand.UUID() @@ -95,10 +91,7 @@ func TestDB(t *testing.T) { } func TestQueryAttribution(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { now := time.Now().UTC() projectID := testrand.UUID() diff --git a/satellite/console/apikeys_test.go b/satellite/console/apikeys_test.go index 3a3d299d4..0767cb271 100644 --- a/satellite/console/apikeys_test.go +++ b/satellite/console/apikeys_test.go @@ -17,10 +17,7 @@ import ( ) func TestApiKeysRepository(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { projects := db.Console().Projects() apikeys := db.Console().APIKeys() diff --git a/satellite/console/consoleweb/consoleql/mutation_test.go b/satellite/console/consoleweb/consoleql/mutation_test.go index b2d0b8c9b..22f0a7eb8 100644 --- a/satellite/console/consoleweb/consoleql/mutation_test.go +++ b/satellite/console/consoleweb/consoleql/mutation_test.go @@ -44,10 +44,7 @@ func (*discardSender) FromAddress() post.Address { } func TestGrapqhlMutation(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { log := zaptest.NewLogger(t) partnersService := rewards.NewPartnersService( diff --git a/satellite/console/consoleweb/consoleql/query_test.go b/satellite/console/consoleweb/consoleql/query_test.go index 00a86f8cb..013090891 100644 --- a/satellite/console/consoleweb/consoleql/query_test.go +++ b/satellite/console/consoleweb/consoleql/query_test.go @@ -29,10 +29,7 @@ import ( ) func TestGraphqlQuery(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { log := zaptest.NewLogger(t) partnersService := rewards.NewPartnersService( diff --git a/satellite/console/projectmembers_test.go b/satellite/console/projectmembers_test.go index 033de3265..36bc953a7 100644 --- a/satellite/console/projectmembers_test.go +++ b/satellite/console/projectmembers_test.go @@ -18,11 +18,7 @@ import ( ) func TestProjectMembersRepository(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - - // repositories + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // repositories users := db.Console().Users() projects := db.Console().Projects() projectMembers := db.Console().ProjectMembers() diff --git a/satellite/console/projects_test.go b/satellite/console/projects_test.go index fd2353814..eeffedba7 100644 --- a/satellite/console/projects_test.go +++ b/satellite/console/projects_test.go @@ -32,11 +32,7 @@ func TestProjectsRepository(t *testing.T) { newDescription = "some new description" ) - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - - // repositories + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // repositories users := db.Console().Users() projects := db.Console().Projects() var project *console.Project diff --git a/satellite/console/resetpasswordtoken_test.go b/satellite/console/resetpasswordtoken_test.go index 429c27738..fc3904903 100644 --- a/satellite/console/resetpasswordtoken_test.go +++ b/satellite/console/resetpasswordtoken_test.go @@ -25,10 +25,7 @@ func TestNewRegistrationSecret(t *testing.T) { userFullName = "name" ) - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { users := db.Console().Users() rptokens := db.Console().ResetPasswordTokens() diff --git a/satellite/console/usercredits_test.go b/satellite/console/usercredits_test.go index 26488ad6a..2cc3d66c1 100644 --- a/satellite/console/usercredits_test.go +++ b/satellite/console/usercredits_test.go @@ -21,10 +21,7 @@ import ( func TestUserCredits(t *testing.T) { t.Skip("Skip until usercredits.Create method is cockroach compatible. https://github.com/cockroachdb/cockroach/issues/42881") - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { consoleDB := db.Console() user, referrer, activeOffer, defaultOffer := setupData(ctx, t, db) diff --git a/satellite/console/users_test.go b/satellite/console/users_test.go index 828f92502..37b09aa9f 100644 --- a/satellite/console/users_test.go +++ b/satellite/console/users_test.go @@ -30,10 +30,7 @@ const ( ) func TestUserRepository(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { repository := db.Console().Users() partnerID := testrand.UUID() @@ -62,10 +59,7 @@ func TestUserRepository(t *testing.T) { } func TestUserEmailCase(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { for _, testCase := range []struct { email string }{ diff --git a/satellite/downtime/db_test.go b/satellite/downtime/db_test.go index e6e8728af..d074a5545 100644 --- a/satellite/downtime/db_test.go +++ b/satellite/downtime/db_test.go @@ -17,10 +17,7 @@ import ( func TestDowntime(t *testing.T) { // test basic downtime functionality - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { downtimeDB := db.DowntimeTracking() now := time.Now() diff --git a/satellite/downtime/estimation_chore_test.go b/satellite/downtime/estimation_chore_test.go index 84ef10ab2..abf7665cc 100644 --- a/satellite/downtime/estimation_chore_test.go +++ b/satellite/downtime/estimation_chore_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" + "storj.io/common/testcontext" "storj.io/storj/private/testplanet" diff --git a/satellite/gracefulexit/db_test.go b/satellite/gracefulexit/db_test.go index 50761e0de..215b745d0 100644 --- a/satellite/gracefulexit/db_test.go +++ b/satellite/gracefulexit/db_test.go @@ -20,10 +20,7 @@ import ( func TestProgress(t *testing.T) { // test basic graceful exit progress crud - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { geDB := db.GracefulExit() testData := []struct { @@ -59,10 +56,7 @@ func TestProgress(t *testing.T) { func TestTransferQueueItem(t *testing.T) { // test basic graceful exit transfer queue crud - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { geDB := db.GracefulExit() nodeID1 := testrand.NodeID() diff --git a/satellite/gracefulexit/getnodes_test.go b/satellite/gracefulexit/getnodes_test.go index afb4c1aba..4705d7a6f 100644 --- a/satellite/gracefulexit/getnodes_test.go +++ b/satellite/gracefulexit/getnodes_test.go @@ -19,10 +19,7 @@ import ( ) func TestGetExitingNodes(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { cache := db.OverlayCache() exiting := make(map[storj.NodeID]bool) exitingCount := 0 @@ -90,10 +87,7 @@ func TestGetExitingNodes(t *testing.T) { } func TestGetGracefulExitNodesByTimeframe(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { cache := db.OverlayCache() exitingToday := make(map[storj.NodeID]bool) exitingLastWeek := make(map[storj.NodeID]bool) diff --git a/satellite/metainfo/db_test.go b/satellite/metainfo/db_test.go index 1b0124bf1..4bb7a9c0d 100644 --- a/satellite/metainfo/db_test.go +++ b/satellite/metainfo/db_test.go @@ -41,10 +41,7 @@ func newTestBucket(name string, projectID uuid.UUID) storj.Bucket { } func TestBasicBucketOperations(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { consoleDB := db.Console() project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"}) require.NoError(t, err) @@ -89,10 +86,7 @@ func TestListBucketsAllAllowed(t *testing.T) { {"non matching cursor, more", "ccc", 3, 3, true}, {"first bucket cursor, more", "0test", 5, 5, true}, } - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { consoleDB := db.Console() project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"}) require.NoError(t, err) @@ -152,10 +146,7 @@ func TestListBucketsNotAllowed(t *testing.T) { {"last bucket cursor, allow all", "zzz", 2, 1, false, true, map[string]struct{}{"zzz": {}}, []string{"zzz"}}, {"empty string cursor, allow all, more", "", 5, 5, true, true, map[string]struct{}{"": {}}, []string{"123", "0test", "999", "aaa", "bbb"}}, } - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { consoleDB := db.Console() project, err := consoleDB.Projects().Insert(ctx, &console.Project{Name: "testproject1"}) require.NoError(t, err) diff --git a/satellite/orders/orders_test.go b/satellite/orders/orders_test.go index 3e9aa74d3..6f05293c8 100644 --- a/satellite/orders/orders_test.go +++ b/satellite/orders/orders_test.go @@ -283,9 +283,7 @@ func buildBenchmarkData(ctx context.Context, b *testing.B, db satellite.DB, stor } func TestProcessOrders(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { ordersDB := db.Orders() serialNum := storj.SerialNumber{1} serialNum2 := storj.SerialNumber{2} diff --git a/satellite/orders/orders_write_cache_test.go b/satellite/orders/orders_write_cache_test.go index 1149762b5..e9ad2b761 100644 --- a/satellite/orders/orders_write_cache_test.go +++ b/satellite/orders/orders_write_cache_test.go @@ -39,10 +39,7 @@ func getTotalBandwidthInGB(ctx context.Context, accountingDB accounting.ProjectA // TestOrdersWriteCacheBatchLimitReached makes sure bandwidth rollup values are not written to the // db until the batch size is reached. func TestOrdersWriteCacheBatchLimitReached(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { useBatchSize := 10 amount := (memory.MB * 500).Int64() projectID := testrand.UUID() diff --git a/satellite/orders/serials_test.go b/satellite/orders/serials_test.go index 3e42ac5de..373a0f4bf 100644 --- a/satellite/orders/serials_test.go +++ b/satellite/orders/serials_test.go @@ -17,10 +17,7 @@ import ( ) func TestSerialNumbers(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { ordersDB := db.Orders() expectedBucket := []byte("bucketID") diff --git a/satellite/overlay/peeridentities_test.go b/satellite/overlay/peeridentities_test.go index 0b83879ff..f4f2d8932 100644 --- a/satellite/overlay/peeridentities_test.go +++ b/satellite/overlay/peeridentities_test.go @@ -17,10 +17,7 @@ import ( ) func TestPeerIdentities(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { encode := identity.EncodePeerIdentity idents := db.PeerIdentities() diff --git a/satellite/overlay/piececount_test.go b/satellite/overlay/piececount_test.go index edbe1e571..0ec29a2e5 100644 --- a/satellite/overlay/piececount_test.go +++ b/satellite/overlay/piececount_test.go @@ -19,10 +19,7 @@ import ( ) func TestDB_PieceCounts(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { overlaydb := db.OverlayCache() type TestNode struct { diff --git a/satellite/overlay/service_test.go b/satellite/overlay/service_test.go index 6a9aef5f2..e1cc8766b 100644 --- a/satellite/overlay/service_test.go +++ b/satellite/overlay/service_test.go @@ -28,10 +28,7 @@ import ( func TestCache_Database(t *testing.T) { t.Parallel() - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { testCache(ctx, t, db.OverlayCache()) }) } @@ -174,10 +171,7 @@ func TestRandomizedSelection(t *testing.T) { numNodesToSelect := 100 minSelectCount := 3 // TODO: compute this limit better - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { cache := db.OverlayCache() allIDs := make(storj.NodeIDList, totalNodes) nodeCounts := make(map[storj.NodeID]int) @@ -347,11 +341,7 @@ func TestKnownReliable(t *testing.T) { } func TestUpdateCheckIn(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - - // setup + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // setup nodeID := storj.NodeID{1, 2, 3} expectedEmail := "test@email.com" expectedAddress := "1.2.4.4" @@ -499,10 +489,7 @@ func TestUpdateCheckIn(t *testing.T) { } func TestCache_DowntimeTracking(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { cache := db.OverlayCache() defaults := overlay.NodeSelectionConfig{ AuditReputationAlpha0: 1, @@ -559,11 +546,7 @@ func TestCache_DowntimeTracking(t *testing.T) { } func TestGetSuccesfulNodesNotCheckedInSince(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - - // setup + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { // setup info1 := getNodeInfo(testrand.NodeID()) info2 := getNodeInfo(testrand.NodeID()) diff --git a/satellite/overlay/statdb_test.go b/satellite/overlay/statdb_test.go index 565735423..0cc3e0487 100644 --- a/satellite/overlay/statdb_test.go +++ b/satellite/overlay/statdb_test.go @@ -20,16 +20,10 @@ import ( ) func TestStatDB(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { testDatabase(ctx, t, db.OverlayCache()) }) - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { testDatabase(ctx, t, overlay.NewCombinedCache(db.OverlayCache())) }) } diff --git a/satellite/payments/stripecoinpayments/coupons_test.go b/satellite/payments/stripecoinpayments/coupons_test.go index 0068ed10d..38ea13771 100644 --- a/satellite/payments/stripecoinpayments/coupons_test.go +++ b/satellite/payments/stripecoinpayments/coupons_test.go @@ -21,10 +21,7 @@ import ( ) func TestCouponRepository(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { couponsRepo := db.StripeCoinPayments().Coupons() coupon := payments.Coupon{ Duration: 2, @@ -105,10 +102,7 @@ func TestCouponRepository(t *testing.T) { // 8. Populating coupons again. For 6 users above. Only 1 new coupon should be added. // Three new coupons total should be added by 2 runs of PopulatePromotionalCoupons method. func TestPopulatePromotionalCoupons(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { usersRepo := db.Console().Users() projectsRepo := db.Console().Projects() couponsRepo := db.StripeCoinPayments().Coupons() diff --git a/satellite/payments/stripecoinpayments/customers_test.go b/satellite/payments/stripecoinpayments/customers_test.go index 5b82a8c4d..e1e58f0da 100644 --- a/satellite/payments/stripecoinpayments/customers_test.go +++ b/satellite/payments/stripecoinpayments/customers_test.go @@ -19,10 +19,7 @@ import ( ) func TestCustomersRepository(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { customers := db.StripeCoinPayments().Customers() customerID := "customerID" @@ -48,10 +45,7 @@ func TestCustomersRepository(t *testing.T) { } func TestCustomersRepositoryList(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { customersDB := db.StripeCoinPayments().Customers() const custLen = 5 diff --git a/satellite/payments/stripecoinpayments/projectrecords_test.go b/satellite/payments/stripecoinpayments/projectrecords_test.go index da7dac305..7c2e3e00f 100644 --- a/satellite/payments/stripecoinpayments/projectrecords_test.go +++ b/satellite/payments/stripecoinpayments/projectrecords_test.go @@ -18,10 +18,7 @@ import ( ) func TestProjectRecords(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { utc := time.Now().UTC() prjID, err := uuid.New() @@ -70,10 +67,7 @@ func TestProjectRecords(t *testing.T) { } func TestProjectRecordsList(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { utc := time.Now().UTC() start := time.Date(utc.Year(), utc.Month(), 1, 0, 0, 0, 0, time.UTC) diff --git a/satellite/payments/stripecoinpayments/transactions_test.go b/satellite/payments/stripecoinpayments/transactions_test.go index d99bdab3e..097925e01 100644 --- a/satellite/payments/stripecoinpayments/transactions_test.go +++ b/satellite/payments/stripecoinpayments/transactions_test.go @@ -23,10 +23,7 @@ import ( ) func TestTransactionsDB(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { transactions := db.StripeCoinPayments().Transactions() amount, ok := new(big.Float).SetPrec(1000).SetString("2.0000000000000000005") @@ -151,7 +148,7 @@ func TestTransactionsDBList(t *testing.T) { } t.Run("pending transactions", func(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { for _, tx := range txs { _, err := db.StripeCoinPayments().Transactions().Insert(ctx, tx) require.NoError(t, err) @@ -173,7 +170,7 @@ func TestTransactionsDBList(t *testing.T) { }) t.Run("unapplied transaction", func(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { var updatedTxs []stripecoinpayments.Transaction var updates []stripecoinpayments.TransactionUpdate var applies coinpayments.TransactionIDList @@ -216,10 +213,7 @@ func TestTransactionsDBList(t *testing.T) { } func TestTransactionsDBRates(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { transactions := db.StripeCoinPayments().Transactions() val, ok := new(big.Float).SetPrec(1000).SetString("4.0000000000000000005") diff --git a/satellite/repair/irreparable/irreparable_test.go b/satellite/repair/irreparable/irreparable_test.go index 5e3bdc874..da5c592a3 100644 --- a/satellite/repair/irreparable/irreparable_test.go +++ b/satellite/repair/irreparable/irreparable_test.go @@ -18,10 +18,7 @@ import ( ) func TestIrreparable(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { irrdb := db.Irreparable() // Create and insert test segment infos into DB diff --git a/satellite/repair/queue/queue2_test.go b/satellite/repair/queue/queue2_test.go index b66667ed4..9c76ca5c2 100644 --- a/satellite/repair/queue/queue2_test.go +++ b/satellite/repair/queue/queue2_test.go @@ -20,10 +20,7 @@ import ( ) func TestUntilEmpty(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { repairQueue := db.RepairQueue() // insert a bunch of segments @@ -53,10 +50,7 @@ func TestUntilEmpty(t *testing.T) { } func TestOrder(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { repairQueue := db.RepairQueue() nullPath := []byte("/path/null") @@ -120,10 +114,7 @@ func TestOrder(t *testing.T) { } func TestCount(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { repairQueue := db.RepairQueue() // insert a bunch of segments diff --git a/satellite/repair/queue/queue_test.go b/satellite/repair/queue/queue_test.go index a784ea434..9d5272f18 100644 --- a/satellite/repair/queue/queue_test.go +++ b/satellite/repair/queue/queue_test.go @@ -19,10 +19,7 @@ import ( ) func TestInsertSelect(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { q := db.RepairQueue() seg := &pb.InjuredSegment{ @@ -40,10 +37,7 @@ func TestInsertSelect(t *testing.T) { } func TestInsertDuplicate(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { q := db.RepairQueue() seg := &pb.InjuredSegment{ @@ -58,10 +52,7 @@ func TestInsertDuplicate(t *testing.T) { } func TestDequeueEmptyQueue(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { q := db.RepairQueue() _, err := q.Select(ctx) @@ -71,10 +62,7 @@ func TestDequeueEmptyQueue(t *testing.T) { } func TestSequential(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { q := db.RepairQueue() const N = 100 @@ -112,10 +100,7 @@ func TestSequential(t *testing.T) { } func TestParallel(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { q := db.RepairQueue() const N = 100 entries := make(chan *pb.InjuredSegment, N) diff --git a/satellite/satellitedb/attribution_test.go b/satellite/satellitedb/attribution_test.go index ebdc8dbc2..db402138f 100644 --- a/satellite/satellitedb/attribution_test.go +++ b/satellite/satellitedb/attribution_test.go @@ -19,10 +19,7 @@ import ( ) func TestUsers(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { consoleDB := db.Console() // create user diff --git a/satellite/satellitedb/consoledb_test.go b/satellite/satellitedb/consoledb_test.go index 794bd6c81..4312e02c8 100644 --- a/satellite/satellitedb/consoledb_test.go +++ b/satellite/satellitedb/consoledb_test.go @@ -17,10 +17,7 @@ import ( ) func TestConsoleTx(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { - ctx := testcontext.New(t) - defer ctx.Cleanup() - + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { dbConsole := db.Console() t.Run("WithTx with success", func(t *testing.T) { diff --git a/satellite/satellitedb/satellitedbtest/run.go b/satellite/satellitedb/satellitedbtest/run.go index 2d1308896..8de9c7120 100644 --- a/satellite/satellitedb/satellitedbtest/run.go +++ b/satellite/satellitedb/satellitedbtest/run.go @@ -14,6 +14,7 @@ import ( "github.com/zeebo/errs" "go.uber.org/zap" "go.uber.org/zap/zaptest" + "storj.io/common/testcontext" "storj.io/storj/private/dbutil" @@ -161,7 +162,7 @@ func CreatePointerDBOnTopOf(ctx context.Context, log *zap.Logger, tempDB *dbutil // Run method will iterate over all supported databases. Will establish // connection and will create tables for each DB. -func Run(t *testing.T, test func(t *testing.T, db satellite.DB)) { +func Run(t *testing.T, test func(ctx *testcontext.Context, t *testing.T, db satellite.DB)) { for _, dbInfo := range Databases() { dbInfo := dbInfo t.Run(dbInfo.MasterDB.Name+"/"+dbInfo.PointerDB.Name, func(t *testing.T) { @@ -191,7 +192,7 @@ func Run(t *testing.T, test func(t *testing.T, db satellite.DB)) { } // TODO: pass the ctx down - test(t, db) + test(ctx, t, db) }) } } diff --git a/satellite/satellitedb/satellitedbtest/run_test.go b/satellite/satellitedb/satellitedbtest/run_test.go index 30b443c09..ec8fe7a0d 100644 --- a/satellite/satellitedb/satellitedbtest/run_test.go +++ b/satellite/satellitedb/satellitedbtest/run_test.go @@ -6,11 +6,12 @@ package satellitedbtest_test import ( "testing" + "storj.io/common/testcontext" "storj.io/storj/satellite" "storj.io/storj/satellite/satellitedb/satellitedbtest" ) func TestDatabase(t *testing.T) { - satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) { + satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { }) } diff --git a/storagenode/storagenodedb/schema.go b/storagenode/storagenodedb/schema.go index 36ef54190..c7ffb9290 100644 --- a/storagenode/storagenodedb/schema.go +++ b/storagenode/storagenodedb/schema.go @@ -510,4 +510,3 @@ func Schema() map[string]*dbschema.Schema { }, } } -