Wrong method call to watch service endpoints key

This commit is contained in:
derekwaynecarr 2014-10-17 13:18:18 -04:00
parent b01126322b
commit 1d6c937183
2 changed files with 30 additions and 5 deletions

View File

@ -575,11 +575,7 @@ func (r *Registry) WatchEndpoints(ctx api.Context, label, field labels.Selector,
return r.Watch(key, version), nil
}
if field.Empty() {
key, err := makeServiceEndpointsKey(ctx, "")
if err != nil {
return nil, err
}
return r.WatchList(key, version, tools.Everything)
return r.WatchList(makeServiceEndpointsListKey(ctx), version, tools.Everything)
}
return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported")
}

View File

@ -1327,6 +1327,35 @@ func TestEtcdWatchEndpoints(t *testing.T) {
watching.Stop()
}
func TestEtcdWatchEndpointsAcrossNamespaces(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient)
watching, err := registry.WatchEndpoints(
ctx,
labels.Everything(),
labels.Everything(),
"1",
)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
fakeClient.WaitForWatchCompletion()
select {
case _, ok := <-watching.ResultChan():
if !ok {
t.Errorf("watching channel should be open")
}
default:
}
fakeClient.WatchInjectError <- nil
if _, ok := <-watching.ResultChan(); ok {
t.Errorf("watching channel should be closed")
}
watching.Stop()
}
func TestEtcdWatchEndpointsBadSelector(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)