Pintracker: set Name in operation tracker. Fixes #1212.

This commit is contained in:
Hector Sanjuan 2022-01-28 19:31:13 +01:00
parent 809b7fbda5
commit 5e89c0ba41
5 changed files with 11 additions and 16 deletions

View File

@ -198,7 +198,7 @@ const (
// IPFSPinStatus represents the status of a pin in IPFS (direct, recursive etc.)
type IPFSPinStatus int
// IPFSPinStatusFromString parses a strixng and returns the matching
// IPFSPinStatusFromString parses a string and returns the matching
// IPFSPinStatus.
func IPFSPinStatusFromString(t string) IPFSPinStatus {
// Since indirect statuses are of the form "indirect through <cid>"

View File

@ -34,7 +34,6 @@ var testingClusterCfg = []byte(`{
},
"state_sync_interval": "1m0s",
"pin_recover_interval": "1m0s",
"peer_infos_caching_interval": "500ms",
"replication_factor": -1,
"monitor_ping_interval": "250ms",
"peer_watch_interval": "1s",

View File

@ -973,13 +973,13 @@ func TestClustersStatusAllWithErrors(t *testing.T) {
t.Error("erroring status should be ClusterError:", pinfo.Status)
}
// if pinfo.PeerName != "peer_1" {
// t.Error("peername should have been set in the erroring peer too from the cache")
// }
if pinfo.PeerName != "peer_1" {
t.Error("peername should have been set in the erroring peer too from the cache")
}
// if pinfo.IPFS != test.PeerID1 {
// t.Error("IPFS ID should have been set in the erroring peer too from the cache")
// }
if pinfo.IPFS != test.PeerID1 {
t.Error("IPFS ID should have been set in the erroring peer too from the cache")
}
case "crdt":
// CRDT will not have contacted the offline peer because
// its metric expired and therefore is not in the

View File

@ -145,6 +145,7 @@ func (opt *OperationTracker) unsafePinInfo(ctx context.Context, op *Operation) a
return api.PinInfo{
Cid: cid.Undef,
Peer: opt.pid,
Name: "",
PinInfoShort: api.PinInfoShort{
PeerName: opt.peerName,
IPFS: "",
@ -159,6 +160,7 @@ func (opt *OperationTracker) unsafePinInfo(ctx context.Context, op *Operation) a
return api.PinInfo{
Cid: op.Cid(),
Peer: opt.pid,
Name: op.Pin().Name,
PinInfoShort: api.PinInfoShort{
PeerName: opt.peerName,
IPFS: "",

View File

@ -52,11 +52,7 @@ func NewMockRPCClientWithHost(t testing.TB, h host.Host) *rpc.Client {
if err != nil {
t.Fatal(err)
}
var pid peer.ID
if h != nil {
pid = h.ID()
}
err = s.RegisterName("PeerMonitor", &mockPeerMonitor{pid: pid})
err = s.RegisterName("PeerMonitor", &mockPeerMonitor{})
if err != nil {
t.Fatal(err)
}
@ -68,9 +64,7 @@ type mockCluster struct{}
type mockPinTracker struct{}
type mockIPFSConnector struct{}
type mockConsensus struct{}
type mockPeerMonitor struct {
pid peer.ID
}
type mockPeerMonitor struct{}
func (mock *mockCluster) Pin(ctx context.Context, in *api.Pin, out *api.Pin) error {
if in.Cid.Equals(ErrorCid) {