Skip to content

Commit

Permalink
swarm peering
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindar committed Nov 16, 2017
1 parent 2d908b3 commit d300ffb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion broker/cluster/swarm_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cluster

import (
"github.com/weaveworks/mesh"
"io"
"testing"

Expand Down Expand Up @@ -34,7 +35,7 @@ func TestOnGossipUnicast(t *testing.T) {
assert.Equal(t, 2, count)
}

func TestNewSwarm(t *testing.T) {
func TestNewSwarm_Scenario(t *testing.T) {
cfg := config.ClusterConfig{
NodeName: "00:00:00:00:00:01",
ListenAddr: ":4000",
Expand Down Expand Up @@ -63,6 +64,18 @@ func TestNewSwarm(t *testing.T) {
_, err = s.OnGossipBroadcast(2, []byte{1, 2, 3})
assert.Equal(t, io.EOF, err)

// Find peer
peer := s.FindPeer(123)
assert.NotNil(t, peer)
assert.Equal(t, "00:00:00:00:00:7b", peer.ID())
_, ok := s.members.Load(mesh.PeerName(123))
assert.True(t, ok)

// Remove that peer, it should not be there anymore
s.onPeerOffline(123)
_, ok = s.members.Load(mesh.PeerName(123))
assert.False(t, ok)

// Close the swarm
err = s.Close()
assert.NoError(t, err)
Expand Down

0 comments on commit d300ffb

Please sign in to comment.