var ErrVersionConflict … type VolumeReactor … type ReactorError … // React is a callback called by fake kubeClient from the controller. // In other words, every claim/volume change performed by the controller ends // here. // This callback checks versions of the updated objects and refuse those that // are too old (simulating real etcd). // All updated objects are stored locally to keep track of object versions and // to evaluate test results. // All updated objects are also inserted into changedObjects queue and // optionally sent back to the controller via its watchers. func (r *VolumeReactor) React(ctx context.Context, action core.Action) (handled bool, ret runtime.Object, err error) { … } // Watch watches objects from the VolumeReactor. Watch returns a channel which // will push added / modified / deleted object. func (r *VolumeReactor) Watch(gvr schema.GroupVersionResource, ns string) (watch.Interface, error) { … } func (r *VolumeReactor) getWatches(gvr schema.GroupVersionResource, ns string) []*watch.RaceFreeFakeWatcher { … } // injectReactError returns an error when the test requested given action to // fail. nil is returned otherwise. func (r *VolumeReactor) injectReactError(ctx context.Context, action core.Action) error { … } // CheckVolumes compares all expectedVolumes with set of volumes at the end of // the test and reports differences. func (r *VolumeReactor) CheckVolumes(expectedVolumes []*v1.PersistentVolume) error { … } // CheckClaims compares all expectedClaims with set of claims at the end of the // test and reports differences. func (r *VolumeReactor) CheckClaims(expectedClaims []*v1.PersistentVolumeClaim) error { … } // PopChange returns one recorded updated object, either *v1.PersistentVolume // or *v1.PersistentVolumeClaim. Returns nil when there are no changes. func (r *VolumeReactor) PopChange(ctx context.Context) interface{ … } // SyncAll simulates the controller periodic sync of volumes and claim. It // simply adds all these objects to the internal queue of updates. This method // should be used when the test manually calls syncClaim/syncVolume. Test that // use real controller loop (ctrl.Run()) will get periodic sync automatically. func (r *VolumeReactor) SyncAll() { … } // GetChangeCount returns changes since last sync. func (r *VolumeReactor) GetChangeCount() int { … } // DeleteVolumeEvent simulates that a volume has been deleted in etcd and // the controller receives 'volume deleted' event. func (r *VolumeReactor) DeleteVolumeEvent(volume *v1.PersistentVolume) { … } // DeleteClaimEvent simulates that a claim has been deleted in etcd and the // controller receives 'claim deleted' event. func (r *VolumeReactor) DeleteClaimEvent(claim *v1.PersistentVolumeClaim) { … } // AddClaimEvent simulates that a claim has been deleted in etcd and the // controller receives 'claim added' event. func (r *VolumeReactor) AddClaimEvent(claim *v1.PersistentVolumeClaim) { … } // AddClaims adds PVCs into VolumeReactor. func (r *VolumeReactor) AddClaims(claims []*v1.PersistentVolumeClaim) { … } // AddVolumes adds PVs into VolumeReactor. func (r *VolumeReactor) AddVolumes(volumes []*v1.PersistentVolume) { … } // AddClaim adds a PVC into VolumeReactor. func (r *VolumeReactor) AddClaim(claim *v1.PersistentVolumeClaim) { … } // AddVolume adds a PV into VolumeReactor. func (r *VolumeReactor) AddVolume(volume *v1.PersistentVolume) { … } // DeleteVolume deletes a PV by name. func (r *VolumeReactor) DeleteVolume(name string) { … } // AddClaimBoundToVolume adds a PVC and binds it to corresponding PV. func (r *VolumeReactor) AddClaimBoundToVolume(claim *v1.PersistentVolumeClaim) { … } // MarkVolumeAvailable marks a PV available by name. func (r *VolumeReactor) MarkVolumeAvailable(name string) { … } // NewVolumeReactor creates a volume reactor. func NewVolumeReactor(ctx context.Context, client *fake.Clientset, fakeVolumeWatch, fakeClaimWatch *watch.FakeWatcher, errors []ReactorError) *VolumeReactor { … }