mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	make testclient threadsafe by guarding internal state with accessors
This commit is contained in:
		@@ -51,8 +51,8 @@ func (c *FakeEndpoints) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-endpoints", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-endpoints", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeEndpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
 | 
					func (c *FakeEndpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,8 +56,8 @@ func (c *FakeEvents) Get(id string) (*api.Event, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Watch starts watching for events matching the given selectors.
 | 
					// Watch starts watching for events matching the given selectors.
 | 
				
			||||||
func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-events", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-events", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Search returns a list of events matching the specified object.
 | 
					// Search returns a list of events matching the specified object.
 | 
				
			||||||
@@ -72,6 +72,6 @@ func (c *FakeEvents) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
 | 
					func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-field-selector"})
 | 
						c.Fake.Invokes(FakeAction{Action: "get-field-selector"}, nil)
 | 
				
			||||||
	return fields.Everything()
 | 
						return fields.Everything()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,6 @@ func (c *FakeLimitRanges) Update(limitRange *api.LimitRange) (*api.LimitRange, e
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeLimitRanges) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeLimitRanges) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-limitRange", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-limitRange", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, nil
 | 
						return c.Fake.Watch, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,8 +45,8 @@ func (c *FakeNamespaces) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
 | 
					func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-namespace"})
 | 
						c.Fake.Invokes(FakeAction{Action: "create-namespace"}, nil)
 | 
				
			||||||
	return &api.Namespace{}, c.Fake.Err
 | 
						return &api.Namespace{}, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) {
 | 
					func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) {
 | 
				
			||||||
@@ -55,7 +55,7 @@ func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-namespaces", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-namespaces", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, nil
 | 
						return c.Fake.Watch, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,6 @@ func (c *FakeNodes) UpdateStatus(minion *api.Node) (*api.Node, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-nodes", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-nodes", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,6 +59,6 @@ func (c *FakePersistentVolumeClaims) UpdateStatus(claim *api.PersistentVolumeCla
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakePersistentVolumeClaims) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakePersistentVolumeClaims) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-persistentVolumeClaims", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-persistentVolumeClaims", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,6 +59,6 @@ func (c *FakePersistentVolumes) UpdateStatus(pv *api.PersistentVolume) (*api.Per
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakePersistentVolumes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakePersistentVolumes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-persistentVolumes", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-persistentVolumes", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,6 @@ func (c *FakePodTemplates) Update(pod *api.PodTemplate) (*api.PodTemplate, error
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakePodTemplates) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakePodTemplates) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-podTemplates", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-podTemplates", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,12 +56,12 @@ func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakePods) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakePods) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-pods", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-pods", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakePods) Bind(bind *api.Binding) error {
 | 
					func (c *FakePods) Bind(bind *api.Binding) error {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "bind-pod", Value: bind.Name})
 | 
						c.Fake.Invokes(FakeAction{Action: "bind-pod", Value: bind.Name}, nil)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,6 +65,6 @@ func (c *FakeReplicationControllers) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeReplicationControllers) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeReplicationControllers) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: WatchControllerAction, Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: WatchControllerAction, Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, nil
 | 
						return c.Fake.Watch, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,6 +61,6 @@ func (c *FakeResourceQuotas) UpdateStatus(resourceQuota *api.ResourceQuota) (*ap
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeResourceQuotas) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeResourceQuotas) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-resourceQuota", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-resourceQuota", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, nil
 | 
						return c.Fake.Watch, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,6 @@ func (c *FakeSecrets) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeSecrets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeSecrets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-secrets", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-secrets", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,6 @@ func (c *FakeServiceAccounts) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeServiceAccounts) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeServiceAccounts) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-serviceAccounts", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-serviceAccounts", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,6 +56,6 @@ func (c *FakeServices) Delete(name string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *FakeServices) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
					func (c *FakeServices) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "watch-services", Value: resourceVersion})
 | 
						c.Fake.Invokes(FakeAction{Action: "watch-services", Value: resourceVersion}, nil)
 | 
				
			||||||
	return c.Fake.Watch, c.Fake.Err
 | 
						return c.Fake.Watch, c.Fake.Err()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,8 @@ limitations under the License.
 | 
				
			|||||||
package testclient
 | 
					package testclient
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
 | 
				
			||||||
@@ -48,10 +50,11 @@ type ReactionFunc func(FakeAction) (runtime.Object, error)
 | 
				
			|||||||
// Fake implements client.Interface. Meant to be embedded into a struct to get a default
 | 
					// Fake implements client.Interface. Meant to be embedded into a struct to get a default
 | 
				
			||||||
// implementation. This makes faking out just the method you want to test easier.
 | 
					// implementation. This makes faking out just the method you want to test easier.
 | 
				
			||||||
type Fake struct {
 | 
					type Fake struct {
 | 
				
			||||||
	Actions []FakeAction
 | 
						sync.RWMutex
 | 
				
			||||||
	Watch   watch.Interface
 | 
						actions []FakeAction
 | 
				
			||||||
	Err     error
 | 
						err     error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Watch watch.Interface
 | 
				
			||||||
	// ReactFn is an optional function that will be invoked with the provided action
 | 
						// ReactFn is an optional function that will be invoked with the provided action
 | 
				
			||||||
	// and return a response. It can implement scenario specific behavior. The type
 | 
						// and return a response. It can implement scenario specific behavior. The type
 | 
				
			||||||
	// of object returned must match the expected type from the caller (even if nil).
 | 
						// of object returned must match the expected type from the caller (even if nil).
 | 
				
			||||||
@@ -61,11 +64,47 @@ type Fake struct {
 | 
				
			|||||||
// Invokes records the provided FakeAction and then invokes the ReactFn (if provided).
 | 
					// Invokes records the provided FakeAction and then invokes the ReactFn (if provided).
 | 
				
			||||||
// obj is expected to be of the same type a normal call would return.
 | 
					// obj is expected to be of the same type a normal call would return.
 | 
				
			||||||
func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, error) {
 | 
					func (c *Fake) Invokes(action FakeAction, obj runtime.Object) (runtime.Object, error) {
 | 
				
			||||||
	c.Actions = append(c.Actions, action)
 | 
						c.Lock()
 | 
				
			||||||
 | 
						defer c.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						c.actions = append(c.actions, action)
 | 
				
			||||||
	if c.ReactFn != nil {
 | 
						if c.ReactFn != nil {
 | 
				
			||||||
		return c.ReactFn(action)
 | 
							return c.ReactFn(action)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj, c.Err
 | 
						return obj, c.err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ClearActions clears the history of actions called on the fake client
 | 
				
			||||||
 | 
					func (c *Fake) ClearActions() {
 | 
				
			||||||
 | 
						c.Lock()
 | 
				
			||||||
 | 
						c.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						c.actions = make([]FakeAction, 0)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Actions returns a chronologically ordered slice fake actions called on the fake client
 | 
				
			||||||
 | 
					func (c *Fake) Actions() []FakeAction {
 | 
				
			||||||
 | 
						c.RLock()
 | 
				
			||||||
 | 
						defer c.RUnlock()
 | 
				
			||||||
 | 
						fa := make([]FakeAction, len(c.actions))
 | 
				
			||||||
 | 
						copy(fa, c.actions)
 | 
				
			||||||
 | 
						return fa
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetErr sets the error to return for client calls
 | 
				
			||||||
 | 
					func (c *Fake) SetErr(err error) {
 | 
				
			||||||
 | 
						c.Lock()
 | 
				
			||||||
 | 
						defer c.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						c.err = err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Err returns any a client error or nil
 | 
				
			||||||
 | 
					func (c *Fake) Err() error {
 | 
				
			||||||
 | 
						c.RLock()
 | 
				
			||||||
 | 
						c.RUnlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return c.err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Fake) LimitRanges(namespace string) client.LimitRangeInterface {
 | 
					func (c *Fake) LimitRanges(namespace string) client.LimitRangeInterface {
 | 
				
			||||||
@@ -125,13 +164,13 @@ func (c *Fake) Namespaces() client.NamespaceInterface {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Fake) ServerVersion() (*version.Info, error) {
 | 
					func (c *Fake) ServerVersion() (*version.Info, error) {
 | 
				
			||||||
	c.Actions = append(c.Actions, FakeAction{Action: "get-version", Value: nil})
 | 
						c.Invokes(FakeAction{Action: "get-version", Value: nil}, nil)
 | 
				
			||||||
	versionInfo := version.Get()
 | 
						versionInfo := version.Get()
 | 
				
			||||||
	return &versionInfo, nil
 | 
						return &versionInfo, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) {
 | 
					func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) {
 | 
				
			||||||
	c.Actions = append(c.Actions, FakeAction{Action: "get-apiversions", Value: nil})
 | 
						c.Invokes(FakeAction{Action: "get-apiversions", Value: nil}, nil)
 | 
				
			||||||
	return &api.APIVersions{Versions: registered.RegisteredVersions}, nil
 | 
						return &api.APIVersions{Versions: registered.RegisteredVersions}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -342,7 +342,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		podEvictor.TryEvict(func(nodeName string) { nodeController.deletePods(nodeName) })
 | 
							podEvictor.TryEvict(func(nodeName string) { nodeController.deletePods(nodeName) })
 | 
				
			||||||
		podEvicted := false
 | 
							podEvicted := false
 | 
				
			||||||
		for _, action := range item.fakeNodeHandler.Actions {
 | 
							for _, action := range item.fakeNodeHandler.Actions() {
 | 
				
			||||||
			if action.Action == "delete-pod" {
 | 
								if action.Action == "delete-pod" {
 | 
				
			||||||
				podEvicted = true
 | 
									podEvicted = true
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,19 +94,20 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
 | 
				
			|||||||
		controller := New(cloud, client, "test-cluster")
 | 
							controller := New(cloud, client, "test-cluster")
 | 
				
			||||||
		controller.init()
 | 
							controller.init()
 | 
				
			||||||
		cloud.Calls = nil     // ignore any cloud calls made in init()
 | 
							cloud.Calls = nil     // ignore any cloud calls made in init()
 | 
				
			||||||
		client.Actions = nil // ignore any client calls made in init()
 | 
							client.ClearActions() // ignore any client calls made in init()
 | 
				
			||||||
		err, _ := controller.createLoadBalancerIfNeeded(types.NamespacedName{"foo", "bar"}, item.service, nil)
 | 
							err, _ := controller.createLoadBalancerIfNeeded(types.NamespacedName{"foo", "bar"}, item.service, nil)
 | 
				
			||||||
		if !item.expectErr && err != nil {
 | 
							if !item.expectErr && err != nil {
 | 
				
			||||||
			t.Errorf("unexpected error: %v", err)
 | 
								t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
		} else if item.expectErr && err == nil {
 | 
							} else if item.expectErr && err == nil {
 | 
				
			||||||
			t.Errorf("expected error creating %v, got nil", item.service)
 | 
								t.Errorf("expected error creating %v, got nil", item.service)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							actions := client.Actions()
 | 
				
			||||||
		if !item.expectCreateAttempt {
 | 
							if !item.expectCreateAttempt {
 | 
				
			||||||
			if len(cloud.Calls) > 0 {
 | 
								if len(cloud.Calls) > 0 {
 | 
				
			||||||
				t.Errorf("unexpected cloud provider calls: %v", cloud.Calls)
 | 
									t.Errorf("unexpected cloud provider calls: %v", cloud.Calls)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if len(client.Actions) > 0 {
 | 
								if len(actions) > 0 {
 | 
				
			||||||
				t.Errorf("unexpected client actions: %v", client.Actions)
 | 
									t.Errorf("unexpected client actions: %v", actions)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if len(cloud.Balancers) != 1 {
 | 
								if len(cloud.Balancers) != 1 {
 | 
				
			||||||
@@ -117,13 +118,13 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
 | 
				
			|||||||
				t.Errorf("created load balancer has incorrect parameters: %v", cloud.Balancers[0])
 | 
									t.Errorf("created load balancer has incorrect parameters: %v", cloud.Balancers[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			actionFound := false
 | 
								actionFound := false
 | 
				
			||||||
			for _, action := range client.Actions {
 | 
								for _, action := range actions {
 | 
				
			||||||
				if action.Action == "update-service" {
 | 
									if action.Action == "update-service" {
 | 
				
			||||||
					actionFound = true
 | 
										actionFound = true
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if !actionFound {
 | 
								if !actionFound {
 | 
				
			||||||
				t.Errorf("expected updated service to be sent to client, got these actions instead: %v", client.Actions)
 | 
									t.Errorf("expected updated service to be sent to client, got these actions instead: %v", actions)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -693,7 +693,7 @@ func TestControllerUpdateStatusWithFailure(t *testing.T) {
 | 
				
			|||||||
	numReplicas := 10
 | 
						numReplicas := 10
 | 
				
			||||||
	updateReplicaCount(fakeRCClient, *rc, numReplicas)
 | 
						updateReplicaCount(fakeRCClient, *rc, numReplicas)
 | 
				
			||||||
	updates, gets := 0, 0
 | 
						updates, gets := 0, 0
 | 
				
			||||||
	for _, a := range fakeClient.Actions {
 | 
						for _, a := range fakeClient.Actions() {
 | 
				
			||||||
		switch a.Action {
 | 
							switch a.Action {
 | 
				
			||||||
		case testclient.GetControllerAction:
 | 
							case testclient.GetControllerAction:
 | 
				
			||||||
			gets++
 | 
								gets++
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,19 +74,19 @@ func (c *fakeRc) Get(name string) (*api.ReplicationController, error) {
 | 
				
			|||||||
	if len(c.responses) == 0 {
 | 
						if len(c.responses) == 0 {
 | 
				
			||||||
		return nil, fmt.Errorf("Unexpected Action: %s", action)
 | 
							return nil, fmt.Errorf("Unexpected Action: %s", action)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, action)
 | 
						c.Fake.Invokes(action, nil)
 | 
				
			||||||
	result := c.responses[0]
 | 
						result := c.responses[0]
 | 
				
			||||||
	c.responses = c.responses[1:]
 | 
						c.responses = c.responses[1:]
 | 
				
			||||||
	return result.controller, result.err
 | 
						return result.controller, result.err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *fakeRc) Create(controller *api.ReplicationController) (*api.ReplicationController, error) {
 | 
					func (c *fakeRc) Create(controller *api.ReplicationController) (*api.ReplicationController, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, testclient.FakeAction{Action: "create-controller", Value: controller.ObjectMeta.Name})
 | 
						c.Fake.Invokes(testclient.FakeAction{Action: "create-controller", Value: controller.ObjectMeta.Name}, nil)
 | 
				
			||||||
	return controller, nil
 | 
						return controller, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *fakeRc) Update(controller *api.ReplicationController) (*api.ReplicationController, error) {
 | 
					func (c *fakeRc) Update(controller *api.ReplicationController) (*api.ReplicationController, error) {
 | 
				
			||||||
	c.Fake.Actions = append(c.Fake.Actions, testclient.FakeAction{Action: "update-controller", Value: controller.ObjectMeta.Name})
 | 
						c.Fake.Invokes(testclient.FakeAction{Action: "update-controller", Value: controller.ObjectMeta.Name}, nil)
 | 
				
			||||||
	return controller, nil
 | 
						return controller, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -73,14 +73,15 @@ func TestReplicationControllerScale(t *testing.T) {
 | 
				
			|||||||
	name := "foo"
 | 
						name := "foo"
 | 
				
			||||||
	scaler.Scale("default", name, count, &preconditions, nil, nil)
 | 
						scaler.Scale("default", name, count, &preconditions, nil, nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(fake.Actions) != 2 {
 | 
						actions := fake.Actions()
 | 
				
			||||||
		t.Errorf("unexpected actions: %v, expected 2 actions (get, update)", fake.Actions)
 | 
						if len(actions) != 2 {
 | 
				
			||||||
 | 
							t.Errorf("unexpected actions: %v, expected 2 actions (get, update)", actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if fake.Actions[0].Action != "get-replicationController" || fake.Actions[0].Value != name {
 | 
						if actions[0].Action != "get-replicationController" || actions[0].Value != name {
 | 
				
			||||||
		t.Errorf("unexpected action: %v, expected get-replicationController %s", fake.Actions[0], name)
 | 
							t.Errorf("unexpected action: %v, expected get-replicationController %s", actions[0], name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if fake.Actions[1].Action != "update-replicationController" || fake.Actions[1].Value.(*api.ReplicationController).Spec.Replicas != int(count) {
 | 
						if actions[1].Action != "update-replicationController" || actions[1].Value.(*api.ReplicationController).Spec.Replicas != int(count) {
 | 
				
			||||||
		t.Errorf("unexpected action %v, expected update-replicationController with replicas = %d", fake.Actions[1], count)
 | 
							t.Errorf("unexpected action %v, expected update-replicationController with replicas = %d", actions[1], count)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -96,11 +97,12 @@ func TestReplicationControllerScaleFailsPreconditions(t *testing.T) {
 | 
				
			|||||||
	name := "foo"
 | 
						name := "foo"
 | 
				
			||||||
	scaler.Scale("default", name, count, &preconditions, nil, nil)
 | 
						scaler.Scale("default", name, count, &preconditions, nil, nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(fake.Actions) != 1 {
 | 
						actions := fake.Actions()
 | 
				
			||||||
		t.Errorf("unexpected actions: %v, expected 2 actions (get, update)", fake.Actions)
 | 
						if len(actions) != 1 {
 | 
				
			||||||
 | 
							t.Errorf("unexpected actions: %v, expected 2 actions (get, update)", actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if fake.Actions[0].Action != "get-replicationController" || fake.Actions[0].Value != name {
 | 
						if actions[0].Action != "get-replicationController" || actions[0].Value != name {
 | 
				
			||||||
		t.Errorf("unexpected action: %v, expected get-replicationController %s", fake.Actions[0], name)
 | 
							t.Errorf("unexpected action: %v, expected get-replicationController %s", actions[0], name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,12 +47,13 @@ func TestReplicationControllerStop(t *testing.T) {
 | 
				
			|||||||
	if s != expected {
 | 
						if s != expected {
 | 
				
			||||||
		t.Errorf("expected %s, got %s", expected, s)
 | 
							t.Errorf("expected %s, got %s", expected, s)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(fake.Actions) != 7 {
 | 
						actions := fake.Actions()
 | 
				
			||||||
 | 
						if len(actions) != 7 {
 | 
				
			||||||
		t.Errorf("unexpected actions: %v, expected 6 actions (get, list, get, update, get, get, delete)", fake.Actions)
 | 
							t.Errorf("unexpected actions: %v, expected 6 actions (get, list, get, update, get, get, delete)", fake.Actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, action := range []string{"get", "list", "get", "update", "get", "get", "delete"} {
 | 
						for i, action := range []string{"get", "list", "get", "update", "get", "get", "delete"} {
 | 
				
			||||||
		if fake.Actions[i].Action != action+"-replicationController" {
 | 
							if actions[i].Action != action+"-replicationController" {
 | 
				
			||||||
			t.Errorf("unexpected action: %+v, expected %s-replicationController", fake.Actions[i], action)
 | 
								t.Errorf("unexpected action: %+v, expected %s-replicationController", actions[i], action)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -159,10 +160,11 @@ func TestSimpleStop(t *testing.T) {
 | 
				
			|||||||
				t.Errorf("unexpected return: %s (%s)", s, test.test)
 | 
									t.Errorf("unexpected return: %s (%s)", s, test.test)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if len(test.actions) != len(fake.Actions) {
 | 
							actions := fake.Actions()
 | 
				
			||||||
 | 
							if len(test.actions) != len(actions) {
 | 
				
			||||||
			t.Errorf("unexpected actions: %v; expected %v (%s)", fake.Actions, test.actions, test.test)
 | 
								t.Errorf("unexpected actions: %v; expected %v (%s)", fake.Actions, test.actions, test.test)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i, action := range fake.Actions {
 | 
							for i, action := range actions {
 | 
				
			||||||
			testAction := test.actions[i]
 | 
								testAction := test.actions[i]
 | 
				
			||||||
			if action.Action != testAction {
 | 
								if action.Action != testAction {
 | 
				
			||||||
				t.Errorf("unexpected action: %v; expected %v (%s)", action, testAction, test.test)
 | 
									t.Errorf("unexpected action: %v; expected %v (%s)", action, testAction, test.test)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2322,10 +2322,11 @@ func TestUpdateNewNodeStatus(t *testing.T) {
 | 
				
			|||||||
	if err := kubelet.updateNodeStatus(); err != nil {
 | 
						if err := kubelet.updateNodeStatus(); err != nil {
 | 
				
			||||||
		t.Errorf("unexpected error: %v", err)
 | 
							t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(kubeClient.Actions) != 2 || kubeClient.Actions[1].Action != "update-status-node" {
 | 
						actions := kubeClient.Actions()
 | 
				
			||||||
		t.Fatalf("unexpected actions: %v", kubeClient.Actions)
 | 
						if len(actions) != 2 || actions[1].Action != "update-status-node" {
 | 
				
			||||||
 | 
							t.Fatalf("unexpected actions: %v", actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	updatedNode, ok := kubeClient.Actions[1].Value.(*api.Node)
 | 
						updatedNode, ok := actions[1].Value.(*api.Node)
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
		t.Errorf("unexpected object type")
 | 
							t.Errorf("unexpected object type")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -2419,10 +2420,11 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
 | 
				
			|||||||
	if err := kubelet.updateNodeStatus(); err != nil {
 | 
						if err := kubelet.updateNodeStatus(); err != nil {
 | 
				
			||||||
		t.Errorf("unexpected error: %v", err)
 | 
							t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(kubeClient.Actions) != 2 {
 | 
						actions := kubeClient.Actions()
 | 
				
			||||||
		t.Errorf("unexpected actions: %v", kubeClient.Actions)
 | 
						if len(actions) != 2 {
 | 
				
			||||||
 | 
							t.Errorf("unexpected actions: %v", actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	updatedNode, ok := kubeClient.Actions[1].Value.(*api.Node)
 | 
						updatedNode, ok := actions[1].Value.(*api.Node)
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
		t.Errorf("unexpected object type")
 | 
							t.Errorf("unexpected object type")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -2506,10 +2508,11 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
 | 
				
			|||||||
	if err := kubelet.updateNodeStatus(); err != nil {
 | 
						if err := kubelet.updateNodeStatus(); err != nil {
 | 
				
			||||||
		t.Errorf("unexpected error: %v", err)
 | 
							t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(kubeClient.Actions) != 2 || kubeClient.Actions[1].Action != "update-status-node" {
 | 
						actions := kubeClient.Actions()
 | 
				
			||||||
		t.Fatalf("unexpected actions: %v", kubeClient.Actions)
 | 
						if len(actions) != 2 || actions[1].Action != "update-status-node" {
 | 
				
			||||||
 | 
							t.Fatalf("unexpected actions: %v", actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	updatedNode, ok := kubeClient.Actions[1].Value.(*api.Node)
 | 
						updatedNode, ok := actions[1].Value.(*api.Node)
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
		t.Errorf("unexpected object type")
 | 
							t.Errorf("unexpected object type")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -2536,8 +2539,8 @@ func TestUpdateNodeStatusError(t *testing.T) {
 | 
				
			|||||||
	if err := kubelet.updateNodeStatus(); err == nil {
 | 
						if err := kubelet.updateNodeStatus(); err == nil {
 | 
				
			||||||
		t.Errorf("unexpected non error: %v", err)
 | 
							t.Errorf("unexpected non error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(testKubelet.fakeKubeClient.Actions) != nodeStatusUpdateRetry {
 | 
						if len(testKubelet.fakeKubeClient.Actions()) != nodeStatusUpdateRetry {
 | 
				
			||||||
		t.Errorf("unexpected actions: %v", testKubelet.fakeKubeClient.Actions)
 | 
							t.Errorf("unexpected actions: %v", testKubelet.fakeKubeClient.Actions())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,7 @@ func getRandomPodStatus() api.PodStatus {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func verifyActions(t *testing.T, kubeClient client.Interface, expectedActions []string) {
 | 
					func verifyActions(t *testing.T, kubeClient client.Interface, expectedActions []string) {
 | 
				
			||||||
	actions := kubeClient.(*testclient.Fake).Actions
 | 
						actions := kubeClient.(*testclient.Fake).Actions()
 | 
				
			||||||
	if len(actions) != len(expectedActions) {
 | 
						if len(actions) != len(expectedActions) {
 | 
				
			||||||
		t.Errorf("unexpected actions, got: %s expected: %s", actions, expectedActions)
 | 
							t.Errorf("unexpected actions, got: %s expected: %s", actions, expectedActions)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,13 +53,14 @@ func TestFinalize(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	finalize(mockClient, testNamespace)
 | 
						finalize(mockClient, testNamespace)
 | 
				
			||||||
	if len(mockClient.Actions) != 1 {
 | 
						actions := mockClient.Actions()
 | 
				
			||||||
		t.Errorf("Expected 1 mock client action, but got %v", len(mockClient.Actions))
 | 
						if len(actions) != 1 {
 | 
				
			||||||
 | 
							t.Errorf("Expected 1 mock client action, but got %v", len(actions))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if mockClient.Actions[0].Action != "finalize-namespace" {
 | 
						if actions[0].Action != "finalize-namespace" {
 | 
				
			||||||
		t.Errorf("Expected finalize-namespace action %v", mockClient.Actions[0].Action)
 | 
							t.Errorf("Expected finalize-namespace action %v", actions[0].Action)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	finalizers := mockClient.Actions[0].Value.(*api.Namespace).Spec.Finalizers
 | 
						finalizers := actions[0].Value.(*api.Namespace).Spec.Finalizers
 | 
				
			||||||
	if len(finalizers) != 1 {
 | 
						if len(finalizers) != 1 {
 | 
				
			||||||
		t.Errorf("There should be a single finalizer remaining")
 | 
							t.Errorf("There should be a single finalizer remaining")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -100,8 +101,8 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
 | 
				
			|||||||
		"finalize-namespace",
 | 
							"finalize-namespace",
 | 
				
			||||||
		"delete-namespace")
 | 
							"delete-namespace")
 | 
				
			||||||
	actionSet := util.NewStringSet()
 | 
						actionSet := util.NewStringSet()
 | 
				
			||||||
	for i := range mockClient.Actions {
 | 
						for _, action := range mockClient.Actions() {
 | 
				
			||||||
		actionSet.Insert(mockClient.Actions[i].Action)
 | 
							actionSet.Insert(action.Action)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !actionSet.HasAll(expectedActionSet.List()...) {
 | 
						if !actionSet.HasAll(expectedActionSet.List()...) {
 | 
				
			||||||
		t.Errorf("Expected actions: %v, but got: %v", expectedActionSet, actionSet)
 | 
							t.Errorf("Expected actions: %v, but got: %v", expectedActionSet, actionSet)
 | 
				
			||||||
@@ -127,8 +128,8 @@ func TestSyncNamespaceThatIsActive(t *testing.T) {
 | 
				
			|||||||
		t.Errorf("Unexpected error when synching namespace %v", err)
 | 
							t.Errorf("Unexpected error when synching namespace %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	actionSet := util.NewStringSet()
 | 
						actionSet := util.NewStringSet()
 | 
				
			||||||
	for i := range mockClient.Actions {
 | 
						for _, action := range mockClient.Actions() {
 | 
				
			||||||
		actionSet.Insert(mockClient.Actions[i].Action)
 | 
							actionSet.Insert(action.Action)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(actionSet) != 0 {
 | 
						if len(actionSet) != 0 {
 | 
				
			||||||
		t.Errorf("Expected no action from controller, but got: %v", actionSet)
 | 
							t.Errorf("Expected no action from controller, but got: %v", actionSet)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,7 +158,7 @@ func TestSyncResourceQuota(t *testing.T) {
 | 
				
			|||||||
		t.Fatalf("Unexpected error %v", err)
 | 
							t.Fatalf("Unexpected error %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	usage := kubeClient.Actions[1].Value.(*api.ResourceQuota)
 | 
						usage := kubeClient.Actions()[1].Value.(*api.ResourceQuota)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ensure hard and used limits are what we expected
 | 
						// ensure hard and used limits are what we expected
 | 
				
			||||||
	for k, v := range expectedUsage.Status.Hard {
 | 
						for k, v := range expectedUsage.Status.Hard {
 | 
				
			||||||
@@ -216,7 +216,7 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
 | 
				
			|||||||
		t.Fatalf("Unexpected error %v", err)
 | 
							t.Fatalf("Unexpected error %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	usage := kubeClient.Actions[1].Value.(*api.ResourceQuota)
 | 
						usage := kubeClient.Actions()[1].Value.(*api.ResourceQuota)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ensure hard and used limits are what we expected
 | 
						// ensure hard and used limits are what we expected
 | 
				
			||||||
	for k, v := range expectedUsage.Status.Hard {
 | 
						for k, v := range expectedUsage.Status.Hard {
 | 
				
			||||||
@@ -263,7 +263,8 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
 | 
				
			|||||||
		t.Fatalf("Unexpected error %v", err)
 | 
							t.Fatalf("Unexpected error %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(kubeClient.Actions) != 1 && kubeClient.Actions[0].Action != "list-pods" {
 | 
						actions := kubeClient.Actions()
 | 
				
			||||||
 | 
						if len(actions) != 1 && actions[0].Action != "list-pods" {
 | 
				
			||||||
		t.Errorf("SyncResourceQuota made an unexpected client action when state was not dirty: %v", kubeClient.Actions)
 | 
							t.Errorf("SyncResourceQuota made an unexpected client action when state was not dirty: %v", kubeClient.Actions)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -192,12 +192,13 @@ func TestServiceAccountCreation(t *testing.T) {
 | 
				
			|||||||
			controller.serviceAccountDeleted(tc.DeletedServiceAccount)
 | 
								controller.serviceAccountDeleted(tc.DeletedServiceAccount)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(tc.ExpectCreatedServiceAccounts) != len(client.Actions) {
 | 
							actions := client.Actions()
 | 
				
			||||||
			t.Errorf("%s: Expected to create accounts %#v. Actual actions were: %#v", k, tc.ExpectCreatedServiceAccounts, client.Actions)
 | 
							if len(tc.ExpectCreatedServiceAccounts) != len(actions) {
 | 
				
			||||||
 | 
								t.Errorf("%s: Expected to create accounts %#v. Actual actions were: %#v", k, tc.ExpectCreatedServiceAccounts, actions)
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i, expectedName := range tc.ExpectCreatedServiceAccounts {
 | 
							for i, expectedName := range tc.ExpectCreatedServiceAccounts {
 | 
				
			||||||
			action := client.Actions[i]
 | 
								action := actions[i]
 | 
				
			||||||
			if action.Action != "create-serviceaccount" {
 | 
								if action.Action != "create-serviceaccount" {
 | 
				
			||||||
				t.Errorf("%s: Unexpected action %s", k, action.Action)
 | 
									t.Errorf("%s: Unexpected action %s", k, action.Action)
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -462,9 +462,10 @@ func TestTokenCreation(t *testing.T) {
 | 
				
			|||||||
			controller.secretDeleted(tc.DeletedSecret)
 | 
								controller.secretDeleted(tc.DeletedSecret)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for i, action := range client.Actions {
 | 
							actions := client.Actions()
 | 
				
			||||||
 | 
							for i, action := range actions {
 | 
				
			||||||
			if len(tc.ExpectedActions) < i+1 {
 | 
								if len(tc.ExpectedActions) < i+1 {
 | 
				
			||||||
				t.Errorf("%s: %d unexpected actions: %+v", k, len(client.Actions)-len(tc.ExpectedActions), client.Actions[i:])
 | 
									t.Errorf("%s: %d unexpected actions: %+v", k, len(actions)-len(tc.ExpectedActions), actions[i:])
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -479,8 +480,8 @@ func TestTokenCreation(t *testing.T) {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(tc.ExpectedActions) > len(client.Actions) {
 | 
							if len(tc.ExpectedActions) > len(actions) {
 | 
				
			||||||
			t.Errorf("%s: %d additional expected actions:%+v", k, len(tc.ExpectedActions)-len(client.Actions), tc.ExpectedActions[len(client.Actions):])
 | 
								t.Errorf("%s: %d additional expected actions:%+v", k, len(tc.ExpectedActions)-len(actions), tc.ExpectedActions[len(actions):])
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,10 +45,11 @@ func TestAdmission(t *testing.T) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Errorf("Unexpected error returned from admission handler")
 | 
							t.Errorf("Unexpected error returned from admission handler")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(mockClient.Actions) != 1 {
 | 
						actions := mockClient.Actions()
 | 
				
			||||||
 | 
						if len(actions) != 1 {
 | 
				
			||||||
		t.Errorf("Expected a create-namespace request")
 | 
							t.Errorf("Expected a create-namespace request")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if mockClient.Actions[0].Action != "create-namespace" {
 | 
						if actions[0].Action != "create-namespace" {
 | 
				
			||||||
		t.Errorf("Expected a create-namespace request to be made via the client")
 | 
							t.Errorf("Expected a create-namespace request to be made via the client")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -76,7 +77,7 @@ func TestAdmissionNamespaceExists(t *testing.T) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Errorf("Unexpected error returned from admission handler")
 | 
							t.Errorf("Unexpected error returned from admission handler")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(mockClient.Actions) != 0 {
 | 
						if len(mockClient.Actions()) != 0 {
 | 
				
			||||||
		t.Errorf("No client request should have been made")
 | 
							t.Errorf("No client request should have been made")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -97,7 +98,7 @@ func TestIgnoreAdmission(t *testing.T) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Errorf("Unexpected error returned from admission handler")
 | 
							t.Errorf("Unexpected error returned from admission handler")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(mockClient.Actions) != 0 {
 | 
						if len(mockClient.Actions()) != 0 {
 | 
				
			||||||
		t.Errorf("No client request should have been made")
 | 
							t.Errorf("No client request should have been made")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -105,9 +106,9 @@ func TestIgnoreAdmission(t *testing.T) {
 | 
				
			|||||||
// TestAdmissionNamespaceExistsUnknownToHandler
 | 
					// TestAdmissionNamespaceExistsUnknownToHandler
 | 
				
			||||||
func TestAdmissionNamespaceExistsUnknownToHandler(t *testing.T) {
 | 
					func TestAdmissionNamespaceExistsUnknownToHandler(t *testing.T) {
 | 
				
			||||||
	namespace := "test"
 | 
						namespace := "test"
 | 
				
			||||||
	mockClient := &testclient.Fake{
 | 
						mockClient := &testclient.Fake{}
 | 
				
			||||||
		Err: errors.NewAlreadyExists("namespaces", namespace),
 | 
						mockClient.SetErr(errors.NewAlreadyExists("namespaces", namespace))
 | 
				
			||||||
	}
 | 
					
 | 
				
			||||||
	store := cache.NewStore(cache.MetaNamespaceKeyFunc)
 | 
						store := cache.NewStore(cache.MetaNamespaceKeyFunc)
 | 
				
			||||||
	handler := &provision{
 | 
						handler := &provision{
 | 
				
			||||||
		client: mockClient,
 | 
							client: mockClient,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user