private/testplanet: remove dependency to uplink
Remove direct dependency on uplink.RSConfig, this simplifies moving the config file without introducing weird dependencies. Change-Id: I7fd2a145401e0205d7047631df9d2810241efeec
This commit is contained in:
parent
a35eb8027e
commit
2680bae88c
@ -19,6 +19,7 @@ import (
|
||||
|
||||
"storj.io/common/identity"
|
||||
"storj.io/common/macaroon"
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/peertls/tlsopts"
|
||||
"storj.io/common/rpc"
|
||||
@ -169,28 +170,28 @@ func (client *Uplink) UploadWithExpiration(ctx context.Context, satellite *Satel
|
||||
}
|
||||
|
||||
// UploadWithConfig uploads data to specific satellite with configured values
|
||||
func (client *Uplink) UploadWithConfig(ctx context.Context, satellite *SatelliteSystem, redundancy *uplink.RSConfig, bucket string, path storj.Path, data []byte) error {
|
||||
func (client *Uplink) UploadWithConfig(ctx context.Context, satellite *SatelliteSystem, redundancy *storj.RedundancyScheme, bucket string, path storj.Path, data []byte) error {
|
||||
return client.UploadWithExpirationAndConfig(ctx, satellite, redundancy, bucket, path, data, time.Time{})
|
||||
}
|
||||
|
||||
// UploadWithExpirationAndConfig uploads data to specific satellite with configured values and expiration time
|
||||
func (client *Uplink) UploadWithExpirationAndConfig(ctx context.Context, satellite *SatelliteSystem, redundancy *uplink.RSConfig, bucketName string, path storj.Path, data []byte, expiration time.Time) (err error) {
|
||||
func (client *Uplink) UploadWithExpirationAndConfig(ctx context.Context, satellite *SatelliteSystem, redundancy *storj.RedundancyScheme, bucketName string, path storj.Path, data []byte, expiration time.Time) (err error) {
|
||||
config := client.GetConfig(satellite)
|
||||
if redundancy != nil {
|
||||
if redundancy.MinThreshold > 0 {
|
||||
config.RS.MinThreshold = redundancy.MinThreshold
|
||||
if redundancy.RequiredShares > 0 {
|
||||
config.RS.MinThreshold = int(redundancy.RequiredShares)
|
||||
}
|
||||
if redundancy.RepairThreshold > 0 {
|
||||
config.RS.RepairThreshold = redundancy.RepairThreshold
|
||||
if redundancy.RepairShares > 0 {
|
||||
config.RS.RepairThreshold = int(redundancy.RepairShares)
|
||||
}
|
||||
if redundancy.SuccessThreshold > 0 {
|
||||
config.RS.SuccessThreshold = redundancy.SuccessThreshold
|
||||
if redundancy.OptimalShares > 0 {
|
||||
config.RS.SuccessThreshold = int(redundancy.OptimalShares)
|
||||
}
|
||||
if redundancy.MaxThreshold > 0 {
|
||||
config.RS.MaxThreshold = redundancy.MaxThreshold
|
||||
if redundancy.TotalShares > 0 {
|
||||
config.RS.MaxThreshold = int(redundancy.TotalShares)
|
||||
}
|
||||
if redundancy.ErasureShareSize > 0 {
|
||||
config.RS.ErasureShareSize = redundancy.ErasureShareSize
|
||||
if redundancy.ShareSize > 0 {
|
||||
config.RS.ErasureShareSize = memory.Size(redundancy.ShareSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
"storj.io/storj/pkg/server"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/uplink"
|
||||
"storj.io/storj/uplink/metainfo"
|
||||
)
|
||||
|
||||
@ -81,11 +80,12 @@ func TestDownloadWithSomeNodesOffline(t *testing.T) {
|
||||
|
||||
testData := testrand.Bytes(memory.MiB)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 5,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 5,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -198,11 +198,12 @@ func TestDownloadFromUnresponsiveNode(t *testing.T) {
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
expectedData := testrand.Bytes(memory.MiB)
|
||||
|
||||
err := planet.Uplinks[0].UploadWithConfig(ctx, planet.Satellites[0], &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 5,
|
||||
err := planet.Uplinks[0].UploadWithConfig(ctx, planet.Satellites[0], &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 5,
|
||||
}, "testbucket", "test/path", expectedData)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite/audit"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
// TestAuditPathCollector does the following:
|
||||
@ -43,11 +42,12 @@ func TestAuditPathCollector(t *testing.T) {
|
||||
for i := 0; i < 5; i++ {
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
path := "/some/remote/path/" + string(i)
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 4,
|
||||
SuccessThreshold: 5,
|
||||
MaxThreshold: 5,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 4,
|
||||
OptimalShares: 5,
|
||||
TotalShares: 5,
|
||||
}, "testbucket", path, testData)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
"storj.io/storj/satellite/audit"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestReverifySuccess(t *testing.T) {
|
||||
@ -504,11 +503,12 @@ func TestReverifyDeletedSegment(t *testing.T) {
|
||||
|
||||
ul := planet.Uplinks[0]
|
||||
testData1 := testrand.Bytes(8 * memory.KiB)
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testData1)
|
||||
@ -592,11 +592,12 @@ func TestReverifyModifiedSegment(t *testing.T) {
|
||||
|
||||
ul := planet.Uplinks[0]
|
||||
testData1 := testrand.Bytes(8 * memory.KiB)
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testData1)
|
||||
require.NoError(t, err)
|
||||
@ -683,11 +684,12 @@ func TestReverifyDifferentShare(t *testing.T) {
|
||||
testData1 := testrand.Bytes(8 * memory.KiB)
|
||||
testData2 := testrand.Bytes(8 * memory.KiB)
|
||||
// upload to three nodes so there is definitely at least one node overlap between the two files
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 3,
|
||||
MaxThreshold: 3,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 3,
|
||||
TotalShares: 3,
|
||||
}
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testData1)
|
||||
require.NoError(t, err)
|
||||
@ -843,11 +845,12 @@ func TestReverifyExpired2(t *testing.T) {
|
||||
testData1 := testrand.Bytes(8 * memory.KiB)
|
||||
testData2 := testrand.Bytes(8 * memory.KiB)
|
||||
// upload to three nodes so there is definitely at least one node overlap between the two files
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 3,
|
||||
MaxThreshold: 3,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 3,
|
||||
TotalShares: 3,
|
||||
}
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testData1)
|
||||
require.NoError(t, err)
|
||||
@ -977,11 +980,12 @@ func TestReverifySlowDownload(t *testing.T) {
|
||||
ul := planet.Uplinks[0]
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -1069,11 +1073,12 @@ func TestReverifyUnknownError(t *testing.T) {
|
||||
ul := planet.Uplinks[0]
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"storj.io/storj/satellite/audit"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
// TestDownloadSharesHappyPath checks that the Share.Error field of all shares
|
||||
@ -753,11 +752,12 @@ func TestVerifierSlowDownload(t *testing.T) {
|
||||
ul := planet.Uplinks[0]
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -811,11 +811,12 @@ func TestVerifierUnknownError(t *testing.T) {
|
||||
ul := planet.Uplinks[0]
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -23,7 +23,6 @@ import (
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestChore(t *testing.T) {
|
||||
@ -44,11 +43,12 @@ func TestChore(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 4,
|
||||
RepairThreshold: 6,
|
||||
SuccessThreshold: 8,
|
||||
MaxThreshold: 8,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 4,
|
||||
RepairShares: 6,
|
||||
OptimalShares: 8,
|
||||
TotalShares: 8,
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
@ -148,11 +148,12 @@ func TestDurabilityRatio(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
@ -222,7 +223,7 @@ func TestDurabilityRatio(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, incompleteTransfers, 1)
|
||||
for _, incomplete := range incompleteTransfers {
|
||||
require.Equal(t, float64(rs.SuccessThreshold-1)/float64(rs.SuccessThreshold), incomplete.DurabilityRatio)
|
||||
require.Equal(t, float64(rs.OptimalShares-1)/float64(rs.OptimalShares), incomplete.DurabilityRatio)
|
||||
require.NotNil(t, incomplete.RootPieceID)
|
||||
}
|
||||
})
|
||||
|
@ -35,7 +35,6 @@ import (
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/storagenode/gracefulexit"
|
||||
"storj.io/storj/storagenode/pieces"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
const numObjects = 6
|
||||
@ -158,11 +157,12 @@ func TestConcurrentConnections(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
@ -261,11 +261,12 @@ func TestRecvTimeout(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
@ -970,11 +971,12 @@ func TestPointerChangedOrDeleted(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path0", testrand.Bytes(5*memory.KiB))
|
||||
@ -1237,11 +1239,12 @@ func TestFailureStorageNodeIgnoresTransferMessages(t *testing.T) {
|
||||
nodeFullIDs[node.ID()] = node.Identity
|
||||
}
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path", testrand.Bytes(5*memory.KiB))
|
||||
@ -1367,11 +1370,12 @@ func TestIneligibleNodeAge(t *testing.T) {
|
||||
nodeFullIDs[node.ID()] = node.Identity
|
||||
}
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 4,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 4,
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path", testrand.Bytes(5*memory.KiB))
|
||||
@ -1427,11 +1431,12 @@ func testTransfers(t *testing.T, objects int, verifier func(ctx *testcontext.Con
|
||||
nodeFullIDs[node.ID()] = node.Identity
|
||||
}
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
for i := 0; i < objects; i++ {
|
||||
|
@ -28,7 +28,6 @@ import (
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/uplink"
|
||||
"storj.io/storj/uplink/eestream"
|
||||
"storj.io/storj/uplink/metainfo"
|
||||
)
|
||||
@ -1742,28 +1741,29 @@ func TestValidateRS(t *testing.T) {
|
||||
satellite := planet.Satellites[0]
|
||||
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 3,
|
||||
MaxThreshold: 3,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 2,
|
||||
OptimalShares: 3,
|
||||
TotalShares: 3,
|
||||
}
|
||||
// test below permitted total value
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path/below", testData)
|
||||
require.Error(t, err)
|
||||
|
||||
// test above permitted total value
|
||||
rs.MaxThreshold = 6
|
||||
rs.TotalShares = 6
|
||||
err = ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path/above", testData)
|
||||
require.Error(t, err)
|
||||
|
||||
// test minimum permitted total value
|
||||
rs.MaxThreshold = 4
|
||||
rs.TotalShares = 4
|
||||
err = ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path/min", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
// test maximum permitted total value
|
||||
rs.MaxThreshold = 5
|
||||
rs.TotalShares = 5
|
||||
err = ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path/max", testData)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite/metainfo"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestIterate(t *testing.T) {
|
||||
@ -67,11 +66,12 @@ func TestUpdatePiecesCheckDuplicates(t *testing.T) {
|
||||
uplinkPeer := planet.Uplinks[0]
|
||||
path := "test/path"
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 1,
|
||||
SuccessThreshold: 2,
|
||||
MaxThreshold: 2,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 1,
|
||||
OptimalShares: 2,
|
||||
TotalShares: 2,
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, rs, "test1", path, testrand.Bytes(5*memory.KiB))
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/pkg/storj"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestCounterInlineAndRemote(t *testing.T) {
|
||||
@ -38,11 +38,12 @@ func TestCounterInlineAndRemote(t *testing.T) {
|
||||
for i := 0; i < 2; i++ {
|
||||
testData := testrand.Bytes(segmentSize)
|
||||
path := "/some/remote/path/" + string(i)
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 4,
|
||||
SuccessThreshold: 5,
|
||||
MaxThreshold: 5,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 4,
|
||||
OptimalShares: 5,
|
||||
TotalShares: 5,
|
||||
}, "testbucket", path, testData)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
@ -91,11 +92,12 @@ func TestCounterRemoteOnly(t *testing.T) {
|
||||
for i := 0; i < 2; i++ {
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
path := "/some/remote/path/" + string(i)
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 4,
|
||||
SuccessThreshold: 5,
|
||||
MaxThreshold: 5,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 4,
|
||||
OptimalShares: 5,
|
||||
TotalShares: 5,
|
||||
}, "testbucket", path, testData)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import (
|
||||
"storj.io/storj/satellite/orders"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
snorders "storj.io/storj/storagenode/orders"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestSendingReceivingOrders(t *testing.T) {
|
||||
@ -235,9 +234,9 @@ func TestUploadDownloadBandwidth(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func noLongTailRedundancy(planet *testplanet.Planet) uplink.RSConfig {
|
||||
redundancy := planet.Uplinks[0].GetConfig(planet.Satellites[0]).RS
|
||||
redundancy.SuccessThreshold = redundancy.MaxThreshold
|
||||
func noLongTailRedundancy(planet *testplanet.Planet) storj.RedundancyScheme {
|
||||
redundancy := planet.Uplinks[0].GetConfig(planet.Satellites[0]).GetRedundancyScheme()
|
||||
redundancy.OptimalShares = redundancy.TotalShares
|
||||
return redundancy
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import (
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
// TestDataRepair does the following:
|
||||
@ -63,11 +62,12 @@ func TestDataRepair(t *testing.T) {
|
||||
minThreshold = 3
|
||||
successThreshold = 7
|
||||
)
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: minThreshold,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: 9,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: int16(minThreshold),
|
||||
RepairShares: 5,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: 9,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -188,11 +188,12 @@ func TestCorruptDataRepair_Failed(t *testing.T) {
|
||||
|
||||
var testData = testrand.Bytes(8 * memory.KiB)
|
||||
// first, upload some remote data
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: 7,
|
||||
MaxThreshold: 9,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 5,
|
||||
OptimalShares: 7,
|
||||
TotalShares: 9,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -304,11 +305,12 @@ func TestCorruptDataRepair_Succeed(t *testing.T) {
|
||||
|
||||
var testData = testrand.Bytes(8 * memory.KiB)
|
||||
// first, upload some remote data
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: 7,
|
||||
MaxThreshold: 9,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 5,
|
||||
OptimalShares: 7,
|
||||
TotalShares: 9,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -416,11 +418,12 @@ func TestRemoveDeletedSegmentFromQueue(t *testing.T) {
|
||||
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: 7,
|
||||
MaxThreshold: 7,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 5,
|
||||
OptimalShares: 7,
|
||||
TotalShares: 7,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -496,11 +499,12 @@ func TestRemoveIrreparableSegmentFromQueue(t *testing.T) {
|
||||
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: 7,
|
||||
MaxThreshold: 7,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 5,
|
||||
OptimalShares: 7,
|
||||
TotalShares: 7,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -576,11 +580,12 @@ func TestRepairMultipleDisqualified(t *testing.T) {
|
||||
|
||||
testData := testrand.Bytes(8 * memory.KiB)
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 5,
|
||||
SuccessThreshold: 7,
|
||||
MaxThreshold: 7,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 5,
|
||||
OptimalShares: 7,
|
||||
TotalShares: 7,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -686,11 +691,12 @@ func TestDataRepairOverride_HigherLimit(t *testing.T) {
|
||||
|
||||
var testData = testrand.Bytes(8 * memory.KiB)
|
||||
// first, upload some remote data
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 4,
|
||||
SuccessThreshold: 9,
|
||||
MaxThreshold: 9,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 4,
|
||||
OptimalShares: 9,
|
||||
TotalShares: 9,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -771,11 +777,12 @@ func TestDataRepairOverride_LowerLimit(t *testing.T) {
|
||||
|
||||
var testData = testrand.Bytes(8 * memory.KiB)
|
||||
// first, upload some remote data
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: 6,
|
||||
SuccessThreshold: 9,
|
||||
MaxThreshold: 9,
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: 6,
|
||||
OptimalShares: 9,
|
||||
TotalShares: 9,
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -897,11 +904,12 @@ func TestDataRepairUploadLimit(t *testing.T) {
|
||||
testData = testrand.Bytes(8 * memory.KiB)
|
||||
)
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, &uplink.RSConfig{
|
||||
MinThreshold: 3,
|
||||
RepairThreshold: repairThreshold,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: maxThreshold,
|
||||
err := ul.UploadWithConfig(ctx, satellite, &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 3,
|
||||
RepairShares: int16(repairThreshold),
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(maxThreshold),
|
||||
}, "testbucket", "test/path", testData)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
@ -33,11 +32,12 @@ func TestCollector(t *testing.T) {
|
||||
// upload some data to exactly 2 nodes that expires in 8 days
|
||||
err := planet.Uplinks[0].UploadWithExpirationAndConfig(ctx,
|
||||
planet.Satellites[0],
|
||||
&uplink.RSConfig{
|
||||
MinThreshold: 1,
|
||||
RepairThreshold: 1,
|
||||
SuccessThreshold: 2,
|
||||
MaxThreshold: 2,
|
||||
&storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 1,
|
||||
RepairShares: 1,
|
||||
OptimalShares: 2,
|
||||
TotalShares: 2,
|
||||
},
|
||||
"testbucket", "test/path",
|
||||
expectedData, time.Now().Add(8*24*time.Hour))
|
||||
|
@ -19,7 +19,6 @@ import (
|
||||
"storj.io/storj/satellite/overlay"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestChore(t *testing.T) {
|
||||
@ -34,11 +33,12 @@ func TestChore(t *testing.T) {
|
||||
|
||||
satellite1.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := uplinkPeer.UploadWithConfig(ctx, satellite1, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testblobs"
|
||||
@ -20,7 +21,6 @@ import (
|
||||
"storj.io/storj/storagenode"
|
||||
"storj.io/storj/storagenode/gracefulexit"
|
||||
"storj.io/storj/storagenode/pieces"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestWorkerSuccess(t *testing.T) {
|
||||
@ -35,11 +35,12 @@ func TestWorkerSuccess(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
@ -113,11 +114,12 @@ func TestWorkerTimeout(t *testing.T) {
|
||||
|
||||
satellite.GracefulExit.Chore.Loop.Pause()
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: successThreshold,
|
||||
MaxThreshold: successThreshold,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: int16(successThreshold),
|
||||
TotalShares: int16(successThreshold),
|
||||
}
|
||||
|
||||
err := ul.UploadWithConfig(ctx, satellite, rs, "testbucket", "test/path1", testrand.Bytes(5*memory.KiB))
|
||||
|
@ -12,11 +12,11 @@ import (
|
||||
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/uplink"
|
||||
)
|
||||
|
||||
func TestInspectorStats(t *testing.T) {
|
||||
@ -43,11 +43,12 @@ func TestInspectorStats(t *testing.T) {
|
||||
|
||||
expectedData := testrand.Bytes(100 * memory.KiB)
|
||||
|
||||
rs := &uplink.RSConfig{
|
||||
MinThreshold: 2,
|
||||
RepairThreshold: 3,
|
||||
SuccessThreshold: 4,
|
||||
MaxThreshold: 5,
|
||||
rs := &storj.RedundancyScheme{
|
||||
Algorithm: storj.ReedSolomon,
|
||||
RequiredShares: 2,
|
||||
RepairShares: 3,
|
||||
OptimalShares: 4,
|
||||
TotalShares: 5,
|
||||
}
|
||||
|
||||
err := planet.Uplinks[0].UploadWithConfig(ctx, planet.Satellites[0], rs, "testbucket", "test/path", expectedData)
|
||||
@ -93,7 +94,7 @@ func TestInspectorStats(t *testing.T) {
|
||||
assert.Equal(t, availableSpace, response.AvailableSpace)
|
||||
}
|
||||
}
|
||||
assert.True(t, downloaded >= rs.MinThreshold, "downloaded=%v, rs.MinThreshold=%v", downloaded, rs.MinThreshold)
|
||||
assert.True(t, downloaded >= int(rs.RequiredShares), "downloaded=%v, rs.RequiredShares=%v", downloaded, rs.RequiredShares)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user