mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 15:41:15 +02:00
* filer: keep the existing peer subscription on a repeated add A cluster node add for a peer that is already followed restarted the subscription, dropping the metadata events between the two runs. * master: tell a connecting client the current cluster membership Cluster node updates are only broadcast to the clients connected at that moment. A filer that lost its master stream while a peer came back never learned about the peer, and stopped replicating its metadata for good. * test: a filer joining the master learns about the filers already there * test: a filer resubscribes to a peer that registered while it was disconnected Runs the reported sequence against real processes: filer2 leaves, filer1 is paused and its master stream is broken, filer2 registers again, and filer1 has to replicate from it after reconnecting.
37 lines
954 B
Go
37 lines
954 B
Go
package filer
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
)
|
|
|
|
func TestOnPeerUpdateRepeatedAdd(t *testing.T) {
|
|
peer := pb.ServerAddress("127.0.0.1:1")
|
|
ma := NewMetaAggregator(nil, pb.ServerAddress("127.0.0.1:2"), nil)
|
|
|
|
add := &master_pb.ClusterNodeUpdate{Address: string(peer), IsAdd: true}
|
|
ma.OnPeerUpdate(add, time.Now())
|
|
first, found := ma.peerChans[peer]
|
|
if !found {
|
|
t.Fatal("expecting a subscription after the first add")
|
|
}
|
|
|
|
ma.OnPeerUpdate(add, time.Now())
|
|
if ma.peerChans[peer] != first {
|
|
t.Fatal("expecting the same subscription after a repeated add")
|
|
}
|
|
select {
|
|
case <-first:
|
|
t.Fatal("expecting the subscription to stay alive after a repeated add")
|
|
default:
|
|
}
|
|
|
|
ma.OnPeerUpdate(&master_pb.ClusterNodeUpdate{Address: string(peer)}, time.Now())
|
|
if _, found := ma.peerChans[peer]; found {
|
|
t.Fatal("expecting the subscription to be removed")
|
|
}
|
|
}
|