mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-02 02:10:45 +01:00
Normalize and deduplicate master peer addresses
This commit is contained in:
1 parent
ae27e17e6f
commit
15d0a46679
2 files changed
+52
-6
No files matched your search
@@ -43,3 +43,24 @@ func TestCheckPeersCanonicalizesSelfEntry(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckPeersDeduplicatesAliasPeers(t *testing.T) {
|
||||
_, peers := checkPeers("127.0.0.1", 9000, 19000, "127.0.0.1:9002,127.0.0.1:9002.19002,127.0.0.1:9003")
|
||||
|
||||
if len(peers) != 3 {
|
||||
t.Fatalf("expected 3 unique peers after normalization, got %d: %+v", len(peers), peers)
|
||||
}
|
||||
|
||||
count9002 := 0
|
||||
for _, peer := range peers {
|
||||
if peer.ToHttpAddress() == "127.0.0.1:9002" {
|
||||
count9002++
|
||||
if string(peer) != "127.0.0.1:9002.19002" {
|
||||
t.Fatalf("expected canonical peer 127.0.0.1:9002.19002, got %q", peer)
|
||||
}
|
||||
}
|
||||
}
|
||||
if count9002 != 1 {
|
||||
t.Fatalf("expected one peer for 127.0.0.1:9002, got %d in %+v", count9002, peers)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user