2019-06-20 16:38:08 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package audit_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/storj"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/testplanet"
|
2019-06-20 16:38:08 +01:00
|
|
|
"storj.io/storj/storagenode"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getStorageNode(planet *testplanet.Planet, nodeID storj.NodeID) *storagenode.Peer {
|
|
|
|
for _, node := range planet.StorageNodes {
|
|
|
|
if node.ID() == nodeID {
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func stopStorageNode(ctx context.Context, planet *testplanet.Planet, nodeID storj.NodeID) error {
|
|
|
|
node := getStorageNode(planet, nodeID)
|
|
|
|
if node == nil {
|
|
|
|
return fmt.Errorf("no such node: %s", nodeID.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
err := planet.StopPeer(node)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-08-06 17:35:59 +01:00
|
|
|
// mark stopped node as offline in overlay
|
2019-06-20 16:38:08 +01:00
|
|
|
_, err = planet.Satellites[0].Overlay.Service.UpdateUptime(ctx, nodeID, false)
|
|
|
|
return err
|
|
|
|
}
|