Skip to content

Commit

Permalink
Gossip test port changes
Browse files Browse the repository at this point in the history
1) Changed gossip ports in some tests to be mutually exclusive.
   We suspect that sometimes the port stays open due to
   previous gossip tests running, so instead of setting port reUseAddress
   I decided to simply change the port numbers.
2) Made discovery tests parallel, reduced time from 12 to 4 seconds.

Change-Id: I8b4bee12d619ee9763e77557675366a06cf86d46
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Dec 1, 2016
1 parent 7b5c451 commit e2e46c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions gossip/comm/comm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func newCommInstance(port int, sec SecurityProvider) (Comm, error) {
}

func TestHandshake(t *testing.T) {
t.Parallel()
comm1, _ := newCommInstance(9611, naiveSec)
defer comm1.Stop()

Expand Down Expand Up @@ -246,8 +247,8 @@ func TestBlackListPKIid(t *testing.T) {

func TestParallelSend(t *testing.T) {
t.Parallel()
comm1, _ := newCommInstance(5611, naiveSec)
comm2, _ := newCommInstance(5612, naiveSec)
comm1, _ := newCommInstance(5411, naiveSec)
comm2, _ := newCommInstance(5412, naiveSec)
defer comm1.Stop()
defer comm2.Stop()

Expand All @@ -260,7 +261,7 @@ func TestParallelSend(t *testing.T) {
emptyMsg := createGossipMsg()
go func() {
defer wg.Done()
comm1.Send(emptyMsg, remotePeer(5612))
comm1.Send(emptyMsg, remotePeer(5412))
}()
}
wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions gossip/comm/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCertificateGeneration(t *testing.T) {
return
}
s := grpc.NewServer(grpc.Creds(creds))
ll, err = net.Listen("tcp", fmt.Sprintf("%s:%d", "", 5611))
ll, err = net.Listen("tcp", fmt.Sprintf("%s:%d", "", 5511))
assert.NoError(t, err, "%v", err)
if err != nil {
return
Expand All @@ -98,7 +98,7 @@ func TestCertificateGeneration(t *testing.T) {
if err != nil {
return
}
conn, err := grpc.Dial("localhost:5611", grpc.WithTransportCredentials(&authCreds{tlsCreds: ta}), grpc.WithBlock(), grpc.WithTimeout(time.Second))
conn, err := grpc.Dial("localhost:5511", grpc.WithTransportCredentials(&authCreds{tlsCreds: ta}), grpc.WithBlock(), grpc.WithTimeout(time.Second))
assert.NoError(t, err, "%v", err)
if err != nil {
return
Expand Down
14 changes: 10 additions & 4 deletions gossip/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func bootPeer(port int) string {
}

func TestUpdate(t *testing.T) {
t.Parallel()
nodeNum := 5
bootPeers := []string{bootPeer(6611), bootPeer(6612)}
instances := []*gossipInstance{}
Expand Down Expand Up @@ -308,6 +309,7 @@ func TestUpdate(t *testing.T) {
}

func TestInitiateSync(t *testing.T) {
t.Parallel()
nodeNum := 10
bootPeers := []string{bootPeer(3611), bootPeer(3612)}
instances := []*gossipInstance{}
Expand All @@ -334,6 +336,7 @@ func TestInitiateSync(t *testing.T) {
}

func TestExpiration(t *testing.T) {
t.Parallel()
nodeNum := 5
bootPeers := []string{bootPeer(2611), bootPeer(2612)}
instances := []*gossipInstance{}
Expand Down Expand Up @@ -373,19 +376,20 @@ func TestExpiration(t *testing.T) {
}

func TestGetFullMembership(t *testing.T) {
t.Parallel()
nodeNum := 15
bootPeers := []string{bootPeer(5611), bootPeer(5612)}
bootPeers := []string{bootPeer(5511), bootPeer(5512)}
instances := []*gossipInstance{}

inst := createDiscoveryInstance(5611, "d1", bootPeers)
inst := createDiscoveryInstance(5511, "d1", bootPeers)
instances = append(instances, inst)

inst = createDiscoveryInstance(5612, "d2", bootPeers)
inst = createDiscoveryInstance(5512, "d2", bootPeers)
instances = append(instances, inst)

for i := 3; i <= nodeNum; i++ {
id := fmt.Sprintf("d%d", i)
inst = createDiscoveryInstance(5610+i, id, bootPeers)
inst = createDiscoveryInstance(5510+i, id, bootPeers)
instances = append(instances, inst)
}

Expand All @@ -394,13 +398,15 @@ func TestGetFullMembership(t *testing.T) {
}

func TestGossipDiscoveryStopping(t *testing.T) {
t.Parallel()
inst := createDiscoveryInstance(9611, "d1", []string{bootPeer(9611)})
time.Sleep(time.Second)
waitUntilOrFailBlocking(t, inst.Stop)

}

func TestConvergence(t *testing.T) {
t.Parallel()
// scenario:
// {boot peer: [peer list]}
// {d1: d2, d3, d4}
Expand Down

0 comments on commit e2e46c8

Please sign in to comment.