storagenode/console: ignore untrusted satellite while returning
dashboard data and calculating satellites data Change-Id: I71d596891477e0839863e007689b6e2e6e420a22
This commit is contained in:
parent
081fdcc835
commit
cd2a5484f3
@ -159,7 +159,9 @@ func (s *Service) GetDashboardData(ctx context.Context) (_ *Dashboard, err error
|
||||
for _, rep := range stats {
|
||||
url, err := s.trust.GetNodeURL(ctx, rep.SatelliteID)
|
||||
if err != nil {
|
||||
return nil, SNOServiceErr.Wrap(err)
|
||||
s.log.Warn("unable to get Satellite URL", zap.String("Satellite ID", rep.SatelliteID.String()),
|
||||
zap.Error(SNOServiceErr.Wrap(err)))
|
||||
continue
|
||||
}
|
||||
|
||||
data.Satellites = append(data.Satellites,
|
||||
@ -376,7 +378,9 @@ func (s *Service) GetAllSatellitesData(ctx context.Context) (_ *Satellites, err
|
||||
|
||||
url, err := s.trust.GetNodeURL(ctx, satellitesIDs[i])
|
||||
if err != nil {
|
||||
return nil, SNOServiceErr.Wrap(err)
|
||||
s.log.Warn("unable to get Satellite URL", zap.String("Satellite ID", satellitesIDs[i].String()),
|
||||
zap.Error(SNOServiceErr.Wrap(err)))
|
||||
continue
|
||||
}
|
||||
|
||||
audits = append(audits, Audits{
|
||||
|
60
storagenode/console/service_test.go
Normal file
60
storagenode/console/service_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package console_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/storagenode/reputation"
|
||||
)
|
||||
|
||||
func TestService_GetDashboardData(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 2, StorageNodeCount: 1, UplinkCount: 0,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
|
||||
// to populate SN reputation DB
|
||||
err := planet.StorageNodes[0].NodeStats.Cache.CacheReputationStats(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
{
|
||||
dashboard, err := planet.StorageNodes[0].Console.Service.GetDashboardData(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, dashboard.NodeID, planet.StorageNodes[0].ID())
|
||||
require.Equal(t, 2, len(dashboard.Satellites))
|
||||
}
|
||||
{ // add untrusted satellite
|
||||
stats := reputation.Stats{
|
||||
SatelliteID: testrand.NodeID(),
|
||||
}
|
||||
err := planet.StorageNodes[0].DB.Reputation().Store(ctx, stats)
|
||||
require.NoError(t, err)
|
||||
|
||||
// GetDashboardData shouldn't error if one of SN satellites is untrusted
|
||||
dashboard, err := planet.StorageNodes[0].Console.Service.GetDashboardData(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, dashboard.NodeID, planet.StorageNodes[0].ID())
|
||||
require.Equal(t, 2, len(dashboard.Satellites))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestService_GetAllSatellitesData(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 2, StorageNodeCount: 1, UplinkCount: 0,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
{
|
||||
_, err := planet.StorageNodes[0].Console.Service.GetAllSatellitesData(ctx)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
// TODO figure out how add untrusted satellite to storagenode/trust/service and test GetAllSatellitesData
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user