satellite/{admin,console}: Move tests
Move tests which where related with the `admin` package to the `console` one because it's where the interface for the methods that the tests check is defined. Change-Id: I1bbccfe0badd989ed146a260af8d207d47737ef1
This commit is contained in:
parent
7ebd35337b
commit
821a077f7c
@ -16,11 +16,9 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/macaroon"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite"
|
||||
@ -568,75 +566,3 @@ func TestDeleteProjectWithUsagePreviousMonth(t *testing.T) {
|
||||
require.Equal(t, http.StatusConflict, response.StatusCode)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRateLimit_ProjectRateLimitZero(t *testing.T) {
|
||||
rateLimit := 2
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 1,
|
||||
Reconfigure: testplanet.Reconfigure{
|
||||
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
||||
config.Metainfo.RateLimiter.Rate = float64(rateLimit)
|
||||
// Make limit cache to refresh as quickly as possible
|
||||
// if it starts to become flaky, we can then add sleeps between
|
||||
// the cache update and the API calls
|
||||
config.Metainfo.RateLimiter.CacheExpiration = time.Millisecond
|
||||
},
|
||||
},
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
ul := planet.Uplinks[0]
|
||||
satellite := planet.Satellites[0]
|
||||
|
||||
projects, err := satellite.DB.Console().Projects().GetAll(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, projects, 1)
|
||||
|
||||
zeroRateLimit := 0
|
||||
err = satellite.DB.Console().Projects().UpdateRateLimit(ctx, projects[0].ID, zeroRateLimit)
|
||||
require.NoError(t, err)
|
||||
|
||||
var group errs2.Group
|
||||
for i := 0; i <= rateLimit; i++ {
|
||||
group.Go(func() error {
|
||||
return ul.CreateBucket(ctx, satellite, testrand.BucketName())
|
||||
})
|
||||
}
|
||||
groupErrs := group.Wait()
|
||||
require.Len(t, groupErrs, 3)
|
||||
})
|
||||
}
|
||||
|
||||
func TestBurstLimit_ProjectBurstLimitZero(t *testing.T) {
|
||||
rateLimit := 2
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 1,
|
||||
Reconfigure: testplanet.Reconfigure{
|
||||
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
||||
config.Metainfo.RateLimiter.Rate = float64(rateLimit)
|
||||
// Make limit cache to refresh as quickly as possible
|
||||
// if it starts to become flaky, we can then add sleeps between
|
||||
// the cache update and the API calls
|
||||
config.Metainfo.RateLimiter.CacheExpiration = time.Millisecond
|
||||
},
|
||||
},
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
ul := planet.Uplinks[0]
|
||||
satellite := planet.Satellites[0]
|
||||
|
||||
projects, err := satellite.DB.Console().Projects().GetAll(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, projects, 1)
|
||||
|
||||
zeroRateLimit := 0
|
||||
err = satellite.DB.Console().Projects().UpdateBurstLimit(ctx, projects[0].ID, zeroRateLimit)
|
||||
require.NoError(t, err)
|
||||
|
||||
var group errs2.Group
|
||||
for i := 0; i <= rateLimit; i++ {
|
||||
group.Go(func() error {
|
||||
return ul.CreateBucket(ctx, satellite, testrand.BucketName())
|
||||
})
|
||||
}
|
||||
groupErrs := group.Wait()
|
||||
require.Len(t, groupErrs, 3)
|
||||
})
|
||||
}
|
||||
|
@ -14,10 +14,13 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
@ -326,7 +329,7 @@ func TestProjectsListByOwner(t *testing.T) {
|
||||
}
|
||||
|
||||
// test listing for each
|
||||
var testCases = []struct {
|
||||
testCases := []struct {
|
||||
id uuid.UUID
|
||||
originalProjects []console.Project
|
||||
}{
|
||||
@ -417,8 +420,80 @@ func TestValidateNameAndDescription(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestRateLimit_ProjectRateLimitZero(t *testing.T) {
|
||||
rateLimit := 2
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 1,
|
||||
Reconfigure: testplanet.Reconfigure{
|
||||
Satellite: func(_ *zap.Logger, _ int, config *satellite.Config) {
|
||||
config.Metainfo.RateLimiter.Rate = float64(rateLimit)
|
||||
// Make limit cache to refresh as quickly as possible
|
||||
// if it starts to become flaky, we can then add sleeps between
|
||||
// the cache update and the API calls
|
||||
config.Metainfo.RateLimiter.CacheExpiration = time.Millisecond
|
||||
},
|
||||
},
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
ul := planet.Uplinks[0]
|
||||
satellite := planet.Satellites[0]
|
||||
|
||||
projects, err := satellite.DB.Console().Projects().GetAll(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, projects, 1)
|
||||
|
||||
zeroRateLimit := 0
|
||||
err = satellite.DB.Console().Projects().UpdateRateLimit(ctx, projects[0].ID, zeroRateLimit)
|
||||
require.NoError(t, err)
|
||||
|
||||
var group errs2.Group
|
||||
for i := 0; i <= rateLimit; i++ {
|
||||
group.Go(func() error {
|
||||
return ul.CreateBucket(ctx, satellite, testrand.BucketName())
|
||||
})
|
||||
}
|
||||
groupErrs := group.Wait()
|
||||
require.Len(t, groupErrs, 3)
|
||||
})
|
||||
}
|
||||
|
||||
func TestBurstLimit_ProjectBurstLimitZero(t *testing.T) {
|
||||
rateLimit := 2
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 1,
|
||||
Reconfigure: testplanet.Reconfigure{
|
||||
Satellite: func(_ *zap.Logger, _ int, config *satellite.Config) {
|
||||
config.Metainfo.RateLimiter.Rate = float64(rateLimit)
|
||||
// Make limit cache to refresh as quickly as possible
|
||||
// if it starts to become flaky, we can then add sleeps between
|
||||
// the cache update and the API calls
|
||||
config.Metainfo.RateLimiter.CacheExpiration = time.Millisecond
|
||||
},
|
||||
},
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
ul := planet.Uplinks[0]
|
||||
satellite := planet.Satellites[0]
|
||||
|
||||
projects, err := satellite.DB.Console().Projects().GetAll(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, projects, 1)
|
||||
|
||||
zeroRateLimit := 0
|
||||
err = satellite.DB.Console().Projects().UpdateBurstLimit(ctx, projects[0].ID, zeroRateLimit)
|
||||
require.NoError(t, err)
|
||||
|
||||
var group errs2.Group
|
||||
for i := 0; i <= rateLimit; i++ {
|
||||
group.Go(func() error {
|
||||
return ul.CreateBucket(ctx, satellite, testrand.BucketName())
|
||||
})
|
||||
}
|
||||
groupErrs := group.Wait()
|
||||
require.Len(t, groupErrs, 3)
|
||||
})
|
||||
}
|
||||
|
||||
func randString(n int) string {
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
|
Loading…
Reference in New Issue
Block a user