From d82567de8534d202427b9e6a0dd1073e9f8a95a7 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 29 Sep 2015 20:17:16 -0700 Subject: [PATCH] Revert "Controller framework test flake fix" --- pkg/controller/framework/controller_test.go | 6 +++--- pkg/controller/framework/fake_controller_source.go | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/controller/framework/controller_test.go b/pkg/controller/framework/controller_test.go index 7adc169b30d..d5fb51871fe 100644 --- a/pkg/controller/framework/controller_test.go +++ b/pkg/controller/framework/controller_test.go @@ -133,7 +133,7 @@ func ExampleInformer() { time.Millisecond*100, framework.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - source.DeleteDropWatch(obj.(runtime.Object)) + source.Delete(obj.(runtime.Object)) }, DeleteFunc: func(obj interface{}) { key, err := framework.DeletionHandlingMetaNamespaceKeyFunc(obj) @@ -327,7 +327,7 @@ func TestUpdate(t *testing.T) { if !allowedTransitions[pair{from, to}] { t.Errorf("observed transition %q -> %q for %v", from, to, n.Name) } - source.DeleteDropWatch(n) + source.Delete(n) }, DeleteFunc: func(obj interface{}) { testDoneWG.Done() @@ -384,7 +384,7 @@ func TestUpdate(t *testing.T) { go func(name string, f func(string)) { defer wg.Done() f(name) - }(fmt.Sprintf("%d-%d", i, j), f) + }(fmt.Sprintf("%v-%v", i, j), f) } } wg.Wait() diff --git a/pkg/controller/framework/fake_controller_source.go b/pkg/controller/framework/fake_controller_source.go index e590e231f98..d4b99bd096d 100644 --- a/pkg/controller/framework/fake_controller_source.go +++ b/pkg/controller/framework/fake_controller_source.go @@ -37,7 +37,7 @@ func NewFakeControllerSource() *FakeControllerSource { // FakeControllerSource implements listing/watching for testing. type FakeControllerSource struct { - sync.RWMutex + lock sync.RWMutex items map[nnu]runtime.Object changes []watch.Event // one change per resourceVersion broadcaster *watch.Broadcaster @@ -95,8 +95,8 @@ func (f *FakeControllerSource) key(meta *api.ObjectMeta) nnu { // Change records the given event (setting the object's resource version) and // sends a watch event with the specified probability. func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) { - f.Lock() - defer f.Unlock() + f.lock.Lock() + defer f.lock.Unlock() objMeta, err := api.ObjectMetaFor(e.Object) if err != nil { @@ -121,8 +121,8 @@ func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) { // List returns a list object, with its resource version set. func (f *FakeControllerSource) List() (runtime.Object, error) { - f.RLock() - defer f.RUnlock() + f.lock.RLock() + defer f.lock.RUnlock() list := make([]runtime.Object, 0, len(f.items)) for _, obj := range f.items { // Must make a copy to allow clients to modify the object. @@ -151,8 +151,8 @@ func (f *FakeControllerSource) List() (runtime.Object, error) { // Watch returns a watch, which will be pre-populated with all changes // after resourceVersion. func (f *FakeControllerSource) Watch(resourceVersion string) (watch.Interface, error) { - f.RLock() - defer f.RUnlock() + f.lock.RLock() + defer f.lock.RUnlock() rc, err := strconv.Atoi(resourceVersion) if err != nil { return nil, err