Skip to content

Commit

Permalink
Merge pull request kubernetes#19010 from wojtek-t/debug_watcher_test
Browse files Browse the repository at this point in the history
Fix etcdWatcher test
  • Loading branch information
mikedanese committed Dec 22, 2015
2 parents b174fc9 + 8cd50dd commit bee5822
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/storage/etcd/etcd_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,15 @@ func TestWatch(t *testing.T) {

watching.Stop()

if _, open := <-watching.ResultChan(); open {
t.Errorf("An injected error did not cause a graceful shutdown")
// There is a race in etcdWatcher so that after calling Stop() one of
// two things can happen:
// - ResultChan() may be closed (triggered by closing userStop channel)
// - an Error "context cancelled" may be emitted (triggered by cancelling request
// to etcd and putting that error to etcdError channel)
// We need to be prepared for both here.
event, open := <-watching.ResultChan()
if open && event.Type != watch.Error {
t.Errorf("Unexpected event from stopped watcher: %#v", event)
}
}

Expand Down

0 comments on commit bee5822

Please sign in to comment.