2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-06-13 19:22:32 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-19 14:40:01 +00:00
|
|
|
package overlay_test
|
2018-06-13 19:22:32 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2018-12-17 18:47:26 +00:00
|
|
|
"math/rand"
|
2018-06-13 19:22:32 +01:00
|
|
|
"testing"
|
2019-04-26 13:15:06 +01:00
|
|
|
"time"
|
2018-06-13 19:22:32 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-02-09 21:17:49 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-05-30 20:52:33 +01:00
|
|
|
"go.uber.org/zap"
|
2019-03-23 08:06:11 +00:00
|
|
|
"go.uber.org/zap/zaptest"
|
2019-02-06 13:32:42 +00:00
|
|
|
|
2018-11-16 16:31:14 +00:00
|
|
|
"storj.io/storj/internal/testcontext"
|
2019-05-30 20:52:33 +01:00
|
|
|
"storj.io/storj/internal/testplanet"
|
2018-11-19 14:40:01 +00:00
|
|
|
"storj.io/storj/pkg/overlay"
|
2018-12-17 18:47:26 +00:00
|
|
|
"storj.io/storj/pkg/pb"
|
2018-11-30 13:40:13 +00:00
|
|
|
"storj.io/storj/pkg/storj"
|
2018-12-27 09:56:25 +00:00
|
|
|
"storj.io/storj/satellite"
|
2018-12-17 20:14:16 +00:00
|
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
2018-06-13 19:22:32 +01:00
|
|
|
)
|
|
|
|
|
2019-01-15 16:08:45 +00:00
|
|
|
func TestCache_Database(t *testing.T) {
|
2019-02-06 13:32:42 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2019-01-15 16:08:45 +00:00
|
|
|
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
|
|
|
ctx := testcontext.New(t)
|
|
|
|
defer ctx.Cleanup()
|
|
|
|
|
2019-03-25 22:25:09 +00:00
|
|
|
testCache(ctx, t, db.OverlayCache())
|
2019-01-15 16:08:45 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-13 17:06:37 +01:00
|
|
|
// returns a NodeSelectionConfig with sensible test values
|
2019-06-13 22:51:18 +01:00
|
|
|
func testNodeSelectionConfig(auditCount int64, newNodePercentage float64, distinctIP bool) overlay.NodeSelectionConfig {
|
2019-06-13 17:06:37 +01:00
|
|
|
return overlay.NodeSelectionConfig{
|
|
|
|
UptimeCount: 0,
|
2019-06-13 22:51:18 +01:00
|
|
|
AuditCount: auditCount,
|
|
|
|
NewNodePercentage: newNodePercentage,
|
2019-06-13 17:06:37 +01:00
|
|
|
OnlineWindow: time.Hour,
|
2019-06-13 22:51:18 +01:00
|
|
|
DistinctIP: distinctIP,
|
|
|
|
|
2019-06-18 19:17:25 +01:00
|
|
|
AuditReputationRepairWeight: 1,
|
|
|
|
AuditReputationUplinkWeight: 1,
|
|
|
|
AuditReputationAlpha0: 1,
|
|
|
|
AuditReputationBeta0: 0,
|
|
|
|
AuditReputationLambda: 1,
|
|
|
|
AuditReputationWeight: 1,
|
2019-06-20 14:56:04 +01:00
|
|
|
AuditReputationDQ: 0.5,
|
2019-06-18 19:17:25 +01:00
|
|
|
UptimeReputationRepairWeight: 1,
|
|
|
|
UptimeReputationUplinkWeight: 1,
|
|
|
|
UptimeReputationAlpha0: 1,
|
|
|
|
UptimeReputationBeta0: 0,
|
|
|
|
UptimeReputationLambda: 1,
|
|
|
|
UptimeReputationWeight: 1,
|
2019-06-20 14:56:04 +01:00
|
|
|
UptimeReputationDQ: 0.5,
|
2019-06-13 17:06:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-25 22:25:09 +00:00
|
|
|
func testCache(ctx context.Context, t *testing.T, store overlay.DB) {
|
2018-12-17 18:47:26 +00:00
|
|
|
valid1ID := storj.NodeID{}
|
|
|
|
valid2ID := storj.NodeID{}
|
|
|
|
missingID := storj.NodeID{}
|
2019-05-30 18:35:04 +01:00
|
|
|
address := &pb.NodeAddress{Address: "127.0.0.1:0"}
|
2018-12-17 18:47:26 +00:00
|
|
|
|
|
|
|
_, _ = rand.Read(valid1ID[:])
|
|
|
|
_, _ = rand.Read(valid2ID[:])
|
|
|
|
_, _ = rand.Read(missingID[:])
|
|
|
|
|
2019-06-20 14:56:04 +01:00
|
|
|
nodeSelectionConfig := testNodeSelectionConfig(0, 0, false)
|
|
|
|
cache := overlay.NewCache(zaptest.NewLogger(t), store, nodeSelectionConfig)
|
2018-11-16 16:31:14 +00:00
|
|
|
|
2018-11-19 14:40:01 +00:00
|
|
|
{ // Put
|
2019-05-30 18:35:04 +01:00
|
|
|
err := cache.Put(ctx, valid1ID, pb.Node{Id: valid1ID, Address: address})
|
2018-11-16 16:31:14 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-12-17 18:47:26 +00:00
|
|
|
|
2019-05-30 18:35:04 +01:00
|
|
|
err = cache.Put(ctx, valid2ID, pb.Node{Id: valid2ID, Address: address})
|
2018-11-16 16:31:14 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-11-19 14:40:01 +00:00
|
|
|
}
|
2018-11-16 16:31:14 +00:00
|
|
|
|
2018-11-19 14:40:01 +00:00
|
|
|
{ // Get
|
2018-12-17 18:47:26 +00:00
|
|
|
_, err := cache.Get(ctx, storj.NodeID{})
|
2019-06-20 14:56:04 +01:00
|
|
|
require.Error(t, err)
|
|
|
|
require.True(t, err == overlay.ErrEmptyNode)
|
2018-12-17 18:47:26 +00:00
|
|
|
|
|
|
|
valid1, err := cache.Get(ctx, valid1ID)
|
2019-06-20 14:56:04 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, valid1.Id, valid1ID)
|
2018-12-17 18:47:26 +00:00
|
|
|
|
2018-11-29 18:39:27 +00:00
|
|
|
valid2, err := cache.Get(ctx, valid2ID)
|
2019-06-20 14:56:04 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, valid2.Id, valid2ID)
|
2018-11-16 16:31:14 +00:00
|
|
|
|
2018-12-17 18:47:26 +00:00
|
|
|
invalid2, err := cache.Get(ctx, missingID)
|
2019-06-20 14:56:04 +01:00
|
|
|
require.Error(t, err)
|
|
|
|
require.True(t, overlay.ErrNodeNotFound.Has(err))
|
|
|
|
require.Nil(t, invalid2)
|
2018-11-16 16:31:14 +00:00
|
|
|
|
2019-01-15 16:08:45 +00:00
|
|
|
// TODO: add erroring database test
|
2018-11-19 14:40:01 +00:00
|
|
|
}
|
2018-11-16 16:31:14 +00:00
|
|
|
|
2019-01-30 16:29:18 +00:00
|
|
|
{ // Paginate
|
|
|
|
|
|
|
|
// should return two nodes
|
|
|
|
nodes, more, err := cache.Paginate(ctx, 0, 2)
|
|
|
|
assert.NotNil(t, more)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, len(nodes), 2)
|
|
|
|
|
|
|
|
// should return no nodes
|
|
|
|
zero, more, err := cache.Paginate(ctx, 0, 0)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, more)
|
|
|
|
assert.NotEqual(t, len(zero), 0)
|
|
|
|
}
|
2019-06-20 14:56:04 +01:00
|
|
|
|
|
|
|
{ // Reputation
|
|
|
|
valid1, err := cache.Get(ctx, valid1ID)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.EqualValues(t, valid1.Id, valid1ID)
|
|
|
|
require.EqualValues(t, valid1.Reputation.AuditReputationAlpha, nodeSelectionConfig.AuditReputationAlpha0)
|
|
|
|
require.EqualValues(t, valid1.Reputation.AuditReputationBeta, nodeSelectionConfig.AuditReputationBeta0)
|
|
|
|
require.EqualValues(t, valid1.Reputation.UptimeReputationAlpha, nodeSelectionConfig.UptimeReputationAlpha0)
|
|
|
|
require.EqualValues(t, valid1.Reputation.UptimeReputationBeta, nodeSelectionConfig.UptimeReputationBeta0)
|
|
|
|
require.Nil(t, valid1.Reputation.Disqualified)
|
|
|
|
|
|
|
|
stats, err := cache.UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: valid1ID,
|
|
|
|
IsUp: true,
|
|
|
|
AuditSuccess: false,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
newAuditAlpha := 1
|
|
|
|
newAuditBeta := 1
|
|
|
|
newUptimeAlpha := 2
|
|
|
|
newUptimeBeta := 0
|
|
|
|
require.EqualValues(t, stats.AuditReputationAlpha, newAuditAlpha)
|
|
|
|
require.EqualValues(t, stats.AuditReputationBeta, newAuditBeta)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationAlpha, newUptimeAlpha)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationBeta, newUptimeBeta)
|
|
|
|
require.NotNil(t, stats.Disqualified)
|
|
|
|
require.True(t, time.Now().UTC().Sub(*stats.Disqualified) < time.Minute)
|
|
|
|
|
|
|
|
stats, err = cache.UpdateUptime(ctx, valid2ID, false)
|
|
|
|
require.NoError(t, err)
|
|
|
|
newUptimeAlpha = 1
|
|
|
|
newUptimeBeta = 1
|
|
|
|
require.EqualValues(t, stats.AuditReputationAlpha, nodeSelectionConfig.AuditReputationAlpha0)
|
|
|
|
require.EqualValues(t, stats.AuditReputationBeta, nodeSelectionConfig.AuditReputationBeta0)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationAlpha, newUptimeAlpha)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationBeta, newUptimeBeta)
|
|
|
|
require.NotNil(t, stats.Disqualified)
|
|
|
|
require.True(t, time.Now().UTC().Sub(*stats.Disqualified) < time.Minute)
|
|
|
|
dqTime := *stats.Disqualified
|
|
|
|
|
|
|
|
// should not update once already disqualified
|
|
|
|
stats, err = cache.UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: valid2ID,
|
|
|
|
IsUp: false,
|
|
|
|
AuditSuccess: true,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.EqualValues(t, stats.AuditReputationAlpha, nodeSelectionConfig.AuditReputationAlpha0)
|
|
|
|
require.EqualValues(t, stats.AuditReputationBeta, nodeSelectionConfig.AuditReputationBeta0)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationAlpha, newUptimeAlpha)
|
|
|
|
require.EqualValues(t, stats.UptimeReputationBeta, newUptimeBeta)
|
|
|
|
require.NotNil(t, stats.Disqualified)
|
|
|
|
require.Equal(t, *stats.Disqualified, dqTime)
|
|
|
|
|
|
|
|
}
|
2018-11-16 16:31:14 +00:00
|
|
|
}
|
2019-02-09 21:17:49 +00:00
|
|
|
|
|
|
|
func TestRandomizedSelection(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
totalNodes := 1000
|
|
|
|
selectIterations := 100
|
|
|
|
numNodesToSelect := 100
|
2019-02-11 12:04:00 +00:00
|
|
|
minSelectCount := 3 // TODO: compute this limit better
|
2019-02-09 21:17:49 +00:00
|
|
|
|
|
|
|
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
|
|
|
ctx := testcontext.New(t)
|
|
|
|
defer ctx.Cleanup()
|
|
|
|
|
|
|
|
cache := db.OverlayCache()
|
|
|
|
allIDs := make(storj.NodeIDList, totalNodes)
|
|
|
|
nodeCounts := make(map[storj.NodeID]int)
|
2019-06-20 14:56:04 +01:00
|
|
|
defaults := overlay.NodeSelectionConfig{
|
|
|
|
AuditReputationAlpha0: 1,
|
|
|
|
AuditReputationBeta0: 0,
|
|
|
|
UptimeReputationAlpha0: 1,
|
|
|
|
UptimeReputationBeta0: 0,
|
|
|
|
}
|
2019-02-09 21:17:49 +00:00
|
|
|
|
|
|
|
// put nodes in cache
|
|
|
|
for i := 0; i < totalNodes; i++ {
|
|
|
|
newID := storj.NodeID{}
|
|
|
|
_, _ = rand.Read(newID[:])
|
2019-06-20 14:56:04 +01:00
|
|
|
err := cache.UpdateAddress(ctx, &pb.Node{Id: newID}, defaults)
|
2019-04-22 10:07:50 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = cache.UpdateNodeInfo(ctx, newID, &pb.InfoResponse{
|
|
|
|
Type: pb.NodeType_STORAGE,
|
|
|
|
Capacity: &pb.NodeCapacity{},
|
2019-02-09 21:17:49 +00:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2019-06-20 14:56:04 +01:00
|
|
|
|
|
|
|
if i%2 == 0 { // make half of nodes "new" and half "vetted"
|
|
|
|
_, err = cache.UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: newID,
|
|
|
|
IsUp: true,
|
|
|
|
AuditSuccess: true,
|
|
|
|
AuditLambda: 1,
|
|
|
|
AuditWeight: 1,
|
|
|
|
AuditDQ: 0.5,
|
|
|
|
UptimeLambda: 1,
|
|
|
|
UptimeWeight: 1,
|
|
|
|
UptimeDQ: 0.5,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2019-02-09 21:17:49 +00:00
|
|
|
allIDs[i] = newID
|
|
|
|
nodeCounts[newID] = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// select numNodesToSelect nodes selectIterations times
|
|
|
|
for i := 0; i < selectIterations; i++ {
|
2019-02-11 17:10:32 +00:00
|
|
|
var nodes []*pb.Node
|
|
|
|
var err error
|
|
|
|
|
2019-04-24 11:35:50 +01:00
|
|
|
if i%2 == 0 {
|
2019-06-20 14:56:04 +01:00
|
|
|
nodes, err = cache.SelectStorageNodes(ctx, numNodesToSelect, &overlay.NodeCriteria{
|
|
|
|
OnlineWindow: time.Hour,
|
|
|
|
AuditCount: 1,
|
|
|
|
})
|
2019-02-11 17:10:32 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
} else {
|
2019-04-23 21:47:11 +01:00
|
|
|
nodes, err = cache.SelectNewStorageNodes(ctx, numNodesToSelect, &overlay.NodeCriteria{
|
2019-04-26 13:15:06 +01:00
|
|
|
OnlineWindow: time.Hour,
|
|
|
|
AuditCount: 1,
|
2019-02-11 17:10:32 +00:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
2019-02-09 21:17:49 +00:00
|
|
|
require.Len(t, nodes, numNodesToSelect)
|
|
|
|
|
|
|
|
for _, node := range nodes {
|
|
|
|
nodeCounts[node.Id]++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-11 12:04:00 +00:00
|
|
|
belowThreshold := 0
|
|
|
|
|
|
|
|
table := []int{}
|
|
|
|
|
2019-02-09 21:17:49 +00:00
|
|
|
// expect that each node has been selected at least minSelectCount times
|
|
|
|
for _, id := range allIDs {
|
|
|
|
count := nodeCounts[id]
|
2019-02-11 12:04:00 +00:00
|
|
|
if count < minSelectCount {
|
|
|
|
belowThreshold++
|
|
|
|
}
|
|
|
|
if count >= len(table) {
|
|
|
|
table = append(table, make([]int, count-len(table)+1)...)
|
|
|
|
}
|
|
|
|
table[count]++
|
|
|
|
}
|
|
|
|
|
|
|
|
if belowThreshold > totalNodes*1/100 {
|
|
|
|
t.Errorf("%d out of %d were below threshold %d", belowThreshold, totalNodes, minSelectCount)
|
|
|
|
for count, amount := range table {
|
|
|
|
t.Logf("%3d = %4d", count, amount)
|
|
|
|
}
|
2019-02-09 21:17:49 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2019-05-30 20:52:33 +01:00
|
|
|
|
2019-06-03 15:53:30 +01:00
|
|
|
func TestIsVetted(t *testing.T) {
|
2019-05-30 20:52:33 +01:00
|
|
|
testplanet.Run(t, testplanet.Config{
|
2019-06-20 14:56:04 +01:00
|
|
|
SatelliteCount: 1, StorageNodeCount: 3, UplinkCount: 0,
|
2019-05-30 20:52:33 +01:00
|
|
|
Reconfigure: testplanet.Reconfigure{
|
|
|
|
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
|
|
|
config.Overlay.Node.AuditCount = 1
|
|
|
|
config.Overlay.Node.UptimeCount = 1
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
var err error
|
|
|
|
satellite := planet.Satellites[0]
|
2019-06-20 14:56:04 +01:00
|
|
|
satellite.Audit.Service.Loop.Pause()
|
|
|
|
satellite.Repair.Checker.Loop.Pause()
|
2019-05-30 20:52:33 +01:00
|
|
|
service := satellite.Overlay.Service
|
|
|
|
|
|
|
|
_, err = satellite.DB.OverlayCache().UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: planet.StorageNodes[0].ID(),
|
|
|
|
IsUp: true,
|
|
|
|
AuditSuccess: true,
|
2019-06-20 14:56:04 +01:00
|
|
|
AuditLambda: 1,
|
|
|
|
AuditWeight: 1,
|
|
|
|
AuditDQ: 0.5,
|
|
|
|
UptimeLambda: 1,
|
|
|
|
UptimeWeight: 1,
|
|
|
|
UptimeDQ: 0.5,
|
2019-05-30 20:52:33 +01:00
|
|
|
})
|
2019-06-20 14:56:04 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = satellite.DB.OverlayCache().UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: planet.StorageNodes[1].ID(),
|
|
|
|
IsUp: true,
|
|
|
|
AuditSuccess: true,
|
|
|
|
AuditLambda: 1,
|
|
|
|
AuditWeight: 1,
|
|
|
|
AuditDQ: 0.5,
|
|
|
|
UptimeLambda: 1,
|
|
|
|
UptimeWeight: 1,
|
|
|
|
UptimeDQ: 0.5,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2019-05-30 20:52:33 +01:00
|
|
|
|
2019-06-03 15:53:30 +01:00
|
|
|
reputable, err := service.IsVetted(ctx, planet.StorageNodes[0].ID())
|
2019-05-30 20:52:33 +01:00
|
|
|
require.NoError(t, err)
|
2019-06-20 14:56:04 +01:00
|
|
|
require.True(t, reputable)
|
|
|
|
|
|
|
|
reputable, err = service.IsVetted(ctx, planet.StorageNodes[1].ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, reputable)
|
|
|
|
|
|
|
|
reputable, err = service.IsVetted(ctx, planet.StorageNodes[2].ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, reputable)
|
|
|
|
|
|
|
|
// test dqing for bad uptime
|
|
|
|
_, err = satellite.DB.OverlayCache().UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: planet.StorageNodes[0].ID(),
|
|
|
|
IsUp: false,
|
|
|
|
AuditSuccess: true,
|
|
|
|
AuditLambda: 1,
|
|
|
|
AuditWeight: 1,
|
|
|
|
AuditDQ: 0.5,
|
|
|
|
UptimeLambda: 0,
|
|
|
|
UptimeWeight: 1,
|
|
|
|
UptimeDQ: 0.5,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// test dqing for bad audit
|
|
|
|
_, err = satellite.DB.OverlayCache().UpdateStats(ctx, &overlay.UpdateRequest{
|
|
|
|
NodeID: planet.StorageNodes[1].ID(),
|
|
|
|
IsUp: true,
|
|
|
|
AuditSuccess: false,
|
|
|
|
AuditLambda: 0,
|
|
|
|
AuditWeight: 1,
|
|
|
|
AuditDQ: 0.5,
|
|
|
|
UptimeLambda: 1,
|
|
|
|
UptimeWeight: 1,
|
|
|
|
UptimeDQ: 0.5,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
reputable, err = service.IsVetted(ctx, planet.StorageNodes[0].ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, reputable)
|
2019-05-30 20:52:33 +01:00
|
|
|
|
2019-06-03 15:53:30 +01:00
|
|
|
reputable, err = service.IsVetted(ctx, planet.StorageNodes[1].ID())
|
2019-05-30 20:52:33 +01:00
|
|
|
require.NoError(t, err)
|
2019-06-20 14:56:04 +01:00
|
|
|
require.False(t, reputable)
|
2019-05-30 20:52:33 +01:00
|
|
|
})
|
|
|
|
}
|
2019-06-11 14:30:28 +01:00
|
|
|
|
|
|
|
func TestNodeInfo(t *testing.T) {
|
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0,
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
planet.StorageNodes[0].Storage2.Monitor.Loop.Pause()
|
|
|
|
planet.Satellites[0].Discovery.Service.Refresh.Pause()
|
|
|
|
|
|
|
|
node, err := planet.Satellites[0].Overlay.Service.Get(ctx, planet.StorageNodes[0].ID())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, pb.NodeType_STORAGE, node.Type)
|
|
|
|
assert.NotEmpty(t, node.Operator.Email)
|
|
|
|
assert.NotEmpty(t, node.Operator.Wallet)
|
|
|
|
assert.Equal(t, planet.StorageNodes[0].Local().Operator, node.Operator)
|
|
|
|
assert.NotEmpty(t, node.Capacity.FreeBandwidth)
|
|
|
|
assert.NotEmpty(t, node.Capacity.FreeDisk)
|
|
|
|
assert.Equal(t, planet.StorageNodes[0].Local().Capacity, node.Capacity)
|
|
|
|
assert.NotEmpty(t, node.Version.Version)
|
|
|
|
assert.Equal(t, planet.StorageNodes[0].Local().Version.Version, node.Version.Version)
|
|
|
|
})
|
|
|
|
}
|