Skip to content

Commit e2e46c8

Browse files
committed
Gossip test port changes
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 <[email protected]>
1 parent 7b5c451 commit e2e46c8

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

gossip/comm/comm_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func newCommInstance(port int, sec SecurityProvider) (Comm, error) {
7070
}
7171

7272
func TestHandshake(t *testing.T) {
73+
t.Parallel()
7374
comm1, _ := newCommInstance(9611, naiveSec)
7475
defer comm1.Stop()
7576

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

247248
func TestParallelSend(t *testing.T) {
248249
t.Parallel()
249-
comm1, _ := newCommInstance(5611, naiveSec)
250-
comm2, _ := newCommInstance(5612, naiveSec)
250+
comm1, _ := newCommInstance(5411, naiveSec)
251+
comm2, _ := newCommInstance(5412, naiveSec)
251252
defer comm1.Stop()
252253
defer comm2.Stop()
253254

@@ -260,7 +261,7 @@ func TestParallelSend(t *testing.T) {
260261
emptyMsg := createGossipMsg()
261262
go func() {
262263
defer wg.Done()
263-
comm1.Send(emptyMsg, remotePeer(5612))
264+
comm1.Send(emptyMsg, remotePeer(5412))
264265
}()
265266
}
266267
wg.Wait()

gossip/comm/crypto_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestCertificateGeneration(t *testing.T) {
7878
return
7979
}
8080
s := grpc.NewServer(grpc.Creds(creds))
81-
ll, err = net.Listen("tcp", fmt.Sprintf("%s:%d", "", 5611))
81+
ll, err = net.Listen("tcp", fmt.Sprintf("%s:%d", "", 5511))
8282
assert.NoError(t, err, "%v", err)
8383
if err != nil {
8484
return
@@ -98,7 +98,7 @@ func TestCertificateGeneration(t *testing.T) {
9898
if err != nil {
9999
return
100100
}
101-
conn, err := grpc.Dial("localhost:5611", grpc.WithTransportCredentials(&authCreds{tlsCreds: ta}), grpc.WithBlock(), grpc.WithTimeout(time.Second))
101+
conn, err := grpc.Dial("localhost:5511", grpc.WithTransportCredentials(&authCreds{tlsCreds: ta}), grpc.WithBlock(), grpc.WithTimeout(time.Second))
102102
assert.NoError(t, err, "%v", err)
103103
if err != nil {
104104
return

gossip/discovery/discovery_test.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ func bootPeer(port int) string {
259259
}
260260

261261
func TestUpdate(t *testing.T) {
262+
t.Parallel()
262263
nodeNum := 5
263264
bootPeers := []string{bootPeer(6611), bootPeer(6612)}
264265
instances := []*gossipInstance{}
@@ -308,6 +309,7 @@ func TestUpdate(t *testing.T) {
308309
}
309310

310311
func TestInitiateSync(t *testing.T) {
312+
t.Parallel()
311313
nodeNum := 10
312314
bootPeers := []string{bootPeer(3611), bootPeer(3612)}
313315
instances := []*gossipInstance{}
@@ -334,6 +336,7 @@ func TestInitiateSync(t *testing.T) {
334336
}
335337

336338
func TestExpiration(t *testing.T) {
339+
t.Parallel()
337340
nodeNum := 5
338341
bootPeers := []string{bootPeer(2611), bootPeer(2612)}
339342
instances := []*gossipInstance{}
@@ -373,19 +376,20 @@ func TestExpiration(t *testing.T) {
373376
}
374377

375378
func TestGetFullMembership(t *testing.T) {
379+
t.Parallel()
376380
nodeNum := 15
377-
bootPeers := []string{bootPeer(5611), bootPeer(5612)}
381+
bootPeers := []string{bootPeer(5511), bootPeer(5512)}
378382
instances := []*gossipInstance{}
379383

380-
inst := createDiscoveryInstance(5611, "d1", bootPeers)
384+
inst := createDiscoveryInstance(5511, "d1", bootPeers)
381385
instances = append(instances, inst)
382386

383-
inst = createDiscoveryInstance(5612, "d2", bootPeers)
387+
inst = createDiscoveryInstance(5512, "d2", bootPeers)
384388
instances = append(instances, inst)
385389

386390
for i := 3; i <= nodeNum; i++ {
387391
id := fmt.Sprintf("d%d", i)
388-
inst = createDiscoveryInstance(5610+i, id, bootPeers)
392+
inst = createDiscoveryInstance(5510+i, id, bootPeers)
389393
instances = append(instances, inst)
390394
}
391395

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

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

401406
}
402407

403408
func TestConvergence(t *testing.T) {
409+
t.Parallel()
404410
// scenario:
405411
// {boot peer: [peer list]}
406412
// {d1: d2, d3, d4}

0 commit comments

Comments
 (0)