Skip to content

Commit

Permalink
Gossip tests relaxations
Browse files Browse the repository at this point in the history
Made relaxations in the time constraints of pull and batching components
Because of complaints the tests were failing locally on some developers PCs.

Change-Id: I3820d121f35127d98c865c93aa7dd87e4e32fc93
Signed-off-by: Yacov Manevich <[email protected]>
  • Loading branch information
yacovm committed Nov 2, 2016
1 parent 37b1168 commit 5bf0eb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
28 changes: 14 additions & 14 deletions gossip/gossip/algo/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
)

func init() {
requestWaitTime = time.Duration(50) * time.Millisecond
digestWaitTime = time.Duration(20) * time.Millisecond
responseWaitTime = time.Duration(50) * time.Millisecond
requestWaitTime = time.Duration(200) * time.Millisecond
digestWaitTime = time.Duration(100) * time.Millisecond
responseWaitTime = time.Duration(200) * time.Millisecond
}

type messageHook func(interface{})
Expand Down Expand Up @@ -79,7 +79,7 @@ func newPushPullTestInstance(name string, peers map[string]*pullTestInstance) *p
name: name,
}

inst.PullEngine = NewPullEngine(inst, time.Duration(100)*time.Millisecond)
inst.PullEngine = NewPullEngine(inst, time.Duration(500)*time.Millisecond)

peers[name] = inst
go func() {
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestPullEngineAll2AllWithIncrementalSpawning(t *testing.T) {
pID := fmt.Sprintf("p%d", i+1)
peers[pID].setNextPeerSelection(keySet(pID, peers))
}
time.Sleep(time.Duration(500) * time.Millisecond)
time.Sleep(time.Duration(4000) * time.Millisecond)

for i := 0; i < instanceCount; i++ {
pID := fmt.Sprintf("p%d", i+1)
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestPullEngineSelectiveUpdates(t *testing.T) {

inst1.setNextPeerSelection([]string{"p2"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(2000) * time.Millisecond)
assert.Equal(t, len(inst2.state.ToArray()), len(inst1.state.ToArray()))
}

Expand Down Expand Up @@ -309,7 +309,7 @@ func TestByzantineResponder(t *testing.T) {
if dig, isDig := m.(*digestMsg); isDig {
if dig.source == "p3" {
atomic.StoreInt32(&receivedDigestFromInst3, int32(1))
time.AfterFunc(time.Duration(25)*time.Millisecond, func() {
time.AfterFunc(time.Duration(150)*time.Millisecond, func() {
inst3.SendRes([]uint64{uint64(5), uint64(6), uint64(7)}, "p1", 0)
})
}
Expand All @@ -319,14 +319,14 @@ func TestByzantineResponder(t *testing.T) {
// the response is from p3
if util.IndexInSlice(res.items, uint64(6), numericCompare) != -1 {
// inst1 is currently accepting responses
assert.Equal(t, int32(1), atomic.LoadInt32(&(inst1.acceptingResponses)))
assert.Equal(t, int32(1), atomic.LoadInt32(&(inst1.acceptingResponses)), "inst1 is not accepting digests")
}
}
})

inst1.setNextPeerSelection([]string{"p2"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(1000) * time.Millisecond)

assert.Equal(t, int32(1), atomic.LoadInt32(&receivedDigestFromInst3), "inst1 hasn't received a digest from inst3")

Expand Down Expand Up @@ -358,7 +358,7 @@ func TestMultipleInitiators(t *testing.T) {
inst2.setNextPeerSelection([]string{"p4"})
inst3.setNextPeerSelection([]string{"p4"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(2000) * time.Millisecond)

for _, inst := range []*pullTestInstance{inst1, inst2, inst3} {
assert.True(t, util.IndexInSlice(inst.state.ToArray(), uint64(1), numericCompare) != -1)
Expand All @@ -383,11 +383,11 @@ func TestLatePeers(t *testing.T) {
inst2.Add(uint64(1), uint64(2), uint64(3), uint64(4))
inst3.Add(uint64(5), uint64(6), uint64(7), uint64(8))
inst2.hook(func(m interface{}) {
time.Sleep(time.Duration(60) * time.Millisecond)
time.Sleep(time.Duration(600) * time.Millisecond)
})
inst1.setNextPeerSelection([]string{"p2", "p3"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(2000) * time.Millisecond)

assert.True(t, util.IndexInSlice(inst1.state.ToArray(), uint64(1), numericCompare) == -1)
assert.True(t, util.IndexInSlice(inst1.state.ToArray(), uint64(2), numericCompare) == -1)
Expand Down Expand Up @@ -416,7 +416,7 @@ func TestBiDiUpdates(t *testing.T) {
inst1.setNextPeerSelection([]string{"p2"})
inst2.setNextPeerSelection([]string{"p1"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(2000) * time.Millisecond)

assert.True(t, util.IndexInSlice(inst1.state.ToArray(), uint64(0), numericCompare) != -1)
assert.True(t, util.IndexInSlice(inst1.state.ToArray(), uint64(1), numericCompare) != -1)
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestSpread(t *testing.T) {

inst1.setNextPeerSelection([]string{"p2", "p3", "p4"})

time.Sleep(time.Duration(200) * time.Millisecond)
time.Sleep(time.Duration(2000) * time.Millisecond)

lock.Lock()
for pI, counter := range chooseCounters {
Expand Down
14 changes: 7 additions & 7 deletions gossip/gossip/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func TestBatchingEmitterStop(t *testing.T) {
atomic.AddInt32(&disseminationAttempts, int32(1))
}

emitter := newBatchingEmitter(10, 1, time.Duration(10)*time.Millisecond, cb)
emitter := newBatchingEmitter(10, 1, time.Duration(100)*time.Millisecond, cb)
emitter.Add(1)
time.Sleep(time.Duration(10) * time.Millisecond)
emitter.Stop()
time.Sleep(time.Duration(100) * time.Millisecond)
emitter.Stop()
time.Sleep(time.Duration(1000) * time.Millisecond)
assert.True(t, atomic.LoadInt32(&disseminationAttempts) < int32(5))
}

Expand All @@ -57,11 +57,11 @@ func TestBatchingEmitterExpiration(t *testing.T) {
atomic.AddInt32(&disseminationAttempts, int32(1))
}

emitter := newBatchingEmitter(10, 1, time.Duration(1)*time.Millisecond, cb)
emitter := newBatchingEmitter(10, 1, time.Duration(10)*time.Millisecond, cb)
defer emitter.Stop()

emitter.Add(1)
time.Sleep(time.Duration(50) * time.Millisecond)
time.Sleep(time.Duration(500) * time.Millisecond)
assert.Equal(t, int32(10), atomic.LoadInt32(&disseminationAttempts), "Inadaquate amount of dissemination attempts detected")
assert.Equal(t, 0, emitter.Size())
}
Expand All @@ -83,15 +83,15 @@ func TestBatchingEmitterCounter(t *testing.T) {
}
}

emitter := newBatchingEmitter(5, 100, time.Duration(50)*time.Millisecond, cb)
emitter := newBatchingEmitter(5, 100, time.Duration(500)*time.Millisecond, cb)
defer emitter.Stop()

for i := 1; i <= 5; i++ {
emitter.Add(i)
if i == 5 {
break
}
time.Sleep(time.Duration(60) * time.Millisecond)
time.Sleep(time.Duration(600) * time.Millisecond)
}
emitter.Stop()

Expand Down

0 comments on commit 5bf0eb1

Please sign in to comment.