agent: optimize rpc monitor test

This commit is contained in:
Ryan Uber 2014-10-16 10:14:36 -07:00
parent e94627be20
commit b394dff38f
1 changed files with 11 additions and 5 deletions

View File

@ -232,7 +232,7 @@ func TestRPCClientMonitor(t *testing.T) {
found := false
OUTER1:
for {
for i := 0; ; i++ {
select {
case e := <-eventCh:
if strings.Contains(e, "Accepted client") {
@ -240,6 +240,10 @@ OUTER1:
break OUTER1
}
default:
if i > 100 {
break OUTER1
}
time.Sleep(10 * time.Millisecond)
}
}
if !found {
@ -249,19 +253,21 @@ OUTER1:
// Join a bad thing to generate more events
p1.agent.JoinLAN(nil)
time.Sleep(1 * time.Second)
found = false
OUTER2:
for {
for i := 0; ; i++ {
select {
case e := <-eventCh:
if strings.Contains(e, "joining") {
found = true
break OUTER2
}
default:
if i > 100 {
break OUTER2
}
time.Sleep(10 * time.Millisecond)
}
}
if !found {
t.Fatalf("should log joining")