storagenode/contact: test node info is updated (#3039)
This commit is contained in:
parent
ccbf73ecc7
commit
44bcdd222f
@ -75,7 +75,7 @@ func (chore *Chore) Run(ctx context.Context) (err error) {
|
||||
|
||||
func (chore *Chore) pingSatellites(ctx context.Context) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
chore.log.Sugar().Infof("node disk %d", chore.rt.Local().Capacity.FreeDisk)
|
||||
|
||||
var group errgroup.Group
|
||||
self := chore.rt.Local()
|
||||
satellites := chore.trust.GetSatellites(ctx)
|
||||
|
@ -39,3 +39,38 @@ func TestStoragenodeContactEndpoint(t *testing.T) {
|
||||
require.True(t, secondPing.After(firstPing))
|
||||
})
|
||||
}
|
||||
|
||||
func TestContactChore(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 1, UplinkCount: 0,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
satellite := planet.Satellites[0]
|
||||
node := planet.StorageNodes[0]
|
||||
|
||||
node.Contact.Chore.Loop.Pause()
|
||||
|
||||
oldInfo, err := satellite.Overlay.Service.Get(ctx, node.ID())
|
||||
require.NoError(t, err)
|
||||
|
||||
oldCapacity := oldInfo.Capacity
|
||||
|
||||
newCapacity := pb.NodeCapacity{
|
||||
FreeBandwidth: 0,
|
||||
FreeDisk: 0,
|
||||
}
|
||||
require.NotEqual(t, oldCapacity, newCapacity)
|
||||
|
||||
node.Kademlia.RoutingTable.UpdateSelf(&newCapacity)
|
||||
|
||||
node.Contact.Chore.Loop.TriggerWait()
|
||||
|
||||
newInfo, err := satellite.Overlay.Service.Get(ctx, node.ID())
|
||||
require.NoError(t, err)
|
||||
|
||||
firstUptime := oldInfo.Reputation.LastContactSuccess
|
||||
secondUptime := newInfo.Reputation.LastContactSuccess
|
||||
require.True(t, secondUptime.After(firstUptime))
|
||||
|
||||
require.Equal(t, newCapacity, newInfo.Capacity)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user