diff --git a/pkg/accounting/projectusage_test.go b/pkg/accounting/projectusage_test.go index d5ad3875d..fc75cc520 100644 --- a/pkg/accounting/projectusage_test.go +++ b/pkg/accounting/projectusage_test.go @@ -82,7 +82,6 @@ func TestProjectUsageStorage(t *testing.T) { } func TestProjectUsageBandwidth(t *testing.T) { - t.Skip("flaky") cases := []struct { name string expectedExceeded bool @@ -93,22 +92,21 @@ func TestProjectUsageBandwidth(t *testing.T) { {name: "exceeds bandwidth project limit", expectedExceeded: true, expectedResource: "bandwidth", expectedErrMsg: "segment error: metainfo error: rpc error: code = ResourceExhausted desc = Exceeded Alpha Usage Limit"}, } - testplanet.Run(t, testplanet.Config{ - SatelliteCount: 1, StorageNodeCount: 6, UplinkCount: 1, - }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { - saDB := planet.Satellites[0].DB - orderDB := saDB.Orders() - acctDB := saDB.ProjectAccounting() + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + testplanet.Run(t, testplanet.Config{ + SatelliteCount: 1, StorageNodeCount: 6, UplinkCount: 1, + }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { + saDB := planet.Satellites[0].DB + orderDB := saDB.Orders() + acctDB := saDB.ProjectAccounting() - // Setup: get projectID and create bucketID - projects, err := planet.Satellites[0].DB.Console().Projects().GetAll(ctx) - projectID := projects[0].ID - require.NoError(t, err) - bucketName := "testbucket" - bucketID := createBucketID(projectID, []byte(bucketName)) - - for _, tt := range cases { - t.Run(tt.name, func(t *testing.T) { + // Setup: get projectID and create bucketID + projects, err := planet.Satellites[0].DB.Console().Projects().GetAll(ctx) + projectID := projects[0].ID + require.NoError(t, err) + bucketName := "testbucket" + bucketID := createBucketID(projectID, []byte(bucketName)) // Setup: create a BucketBandwidthRollup record to test exceeding bandwidth project limit if tt.expectedResource == "bandwidth" { @@ -121,7 +119,9 @@ func TestProjectUsageBandwidth(t *testing.T) { expectedData := make([]byte, 50*memory.KiB) _, err = rand.Read(expectedData) require.NoError(t, err) - err := planet.Uplinks[0].Upload(ctx, planet.Satellites[0], bucketName, "test/path", expectedData) + + filePath := "test/path" + err = planet.Uplinks[0].Upload(ctx, planet.Satellites[0], bucketName, filePath, expectedData) require.NoError(t, err) // Setup: This date represents the past 30 days so that we can check @@ -137,16 +137,15 @@ func TestProjectUsageBandwidth(t *testing.T) { require.Equal(t, tt.expectedResource, actualResource) // Execute test: check that the uplink gets an error when they have exceeded bandwidth limits and try to download a file - _, actualErr := planet.Uplinks[0].Download(ctx, planet.Satellites[0], bucketName, "test/path") + _, actualErr := planet.Uplinks[0].Download(ctx, planet.Satellites[0], bucketName, filePath) if tt.expectedResource == "bandwidth" { assert.EqualError(t, actualErr, tt.expectedErrMsg) } else { require.NoError(t, actualErr) } - }) - } - }) + }) + } } func createBucketID(projectID uuid.UUID, bucket []byte) []byte {