Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
oncilla committed May 17, 2019
1 parent 2fbaf40 commit 6eb4c35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
16 changes: 3 additions & 13 deletions go/beacon_srv/internal/beaconing/originator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,13 @@ func TestOriginatorRun(t *testing.T) {
intfs.Get(42).Activate(84)
intfs.Get(1129).Activate(82)

failedMtx := sync.Mutex{}
var failed bool
// 1. Initial run where one beacon fails to send. -> 2 calls
// 2. Second run where the beacon is delivered. -> 1 call
// 3. Run where no beacon is sent. -> no call
// 4. Run where beacons are sent on all interfaces. -> 2 calls
conn.EXPECT().WriteTo(gomock.Any(), gomock.Any()).Times(5).DoAndReturn(
func(ipkt, iov interface{}) error {
failedMtx.Lock()
defer failedMtx.Unlock()
if !failed {
failed = true
return errors.New("fail")
}
return nil
},
)
first := conn.EXPECT().WriteTo(gomock.Any(), gomock.Any())
first.Return(errors.New("fail"))
conn.EXPECT().WriteTo(gomock.Any(), gomock.Any()).After(first).Times(4).Return(nil)
// Initial run. Two writes expected, one write will fail.
o.Run(nil)
time.Sleep(1 * time.Second)
Expand Down
19 changes: 5 additions & 14 deletions go/beacon_srv/internal/beaconing/propagator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ func TestPropagatorRun(t *testing.T) {
cfg.Config.Intfs.Get(ifid).Activate(remote)
}
g := graph.NewDefaultGraph(mctrl)
// We call run 4 times in this test
// We call run 4 times in this test, since the interface to 1-ff00:0:120
// will never be beaconed on, because the beacons are filtered for loops.
provider.EXPECT().BeaconsToPropagate(gomock.Any()).Times(4).DoAndReturn(
func(_ interface{}) (<-chan beacon.BeaconOrErr, error) {
res := make(chan beacon.BeaconOrErr, 1)
Expand All @@ -251,23 +252,13 @@ func TestPropagatorRun(t *testing.T) {
return res, nil
},
)
failedMtx := sync.Mutex{}
var failed bool
// 1. Initial run where one beacon fails to send. -> 2 calls
// 2. Second run where the beacon is delivered. -> 1 call
// 3. Run where no beacon is sent. -> no call
// 4. Run where beacons are sent on all interfaces. -> 2 calls
conn.EXPECT().WriteTo(gomock.Any(), gomock.Any()).Times(5).DoAndReturn(
func(ipkt, iov interface{}) error {
failedMtx.Lock()
defer failedMtx.Unlock()
if !failed {
failed = true
return errors.New("fail")
}
return nil
},
)
firstCall := conn.EXPECT().WriteTo(gomock.Any(), gomock.Any())
firstCall.Return(errors.New("fail"))
conn.EXPECT().WriteTo(gomock.Any(), gomock.Any()).After(firstCall).Times(4).Return(nil)
// Initial run. Two writes expected, one write will fail.
p.Run(nil)
time.Sleep(1 * time.Second)
Expand Down

0 comments on commit 6eb4c35

Please sign in to comment.