mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Move locks on watch to allow testing blocking
This commit is contained in:
		@@ -131,7 +131,7 @@ func (f *FakeEtcdClient) Get(key string, sort, recursive bool) (*etcd.Response,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return &etcd.Response{}, EtcdErrorNotFound
 | 
							return &etcd.Response{}, EtcdErrorNotFound
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	f.t.Logf("returning %v: %v %#v", key, result.R, result.E)
 | 
						f.t.Logf("returning %v: %#v %#v", key, result.R, result.E)
 | 
				
			||||||
	return result.R, result.E
 | 
						return result.R, result.E
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -262,6 +262,7 @@ func (f *FakeEtcdClient) WaitForWatchCompletion() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error) {
 | 
					func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error) {
 | 
				
			||||||
 | 
						f.Mutex.Lock()
 | 
				
			||||||
	if f.WatchImmediateError != nil {
 | 
						if f.WatchImmediateError != nil {
 | 
				
			||||||
		return nil, f.WatchImmediateError
 | 
							return nil, f.WatchImmediateError
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -273,6 +274,7 @@ func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool,
 | 
				
			|||||||
	defer close(injectedError)
 | 
						defer close(injectedError)
 | 
				
			||||||
	f.WatchInjectError = injectedError
 | 
						f.WatchInjectError = injectedError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						f.Mutex.Unlock()
 | 
				
			||||||
	if receiver == nil {
 | 
						if receiver == nil {
 | 
				
			||||||
		return f.Get(prefix, false, recursive)
 | 
							return f.Get(prefix, false, recursive)
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user