kubernetes: k8s.io/kubernetes/pkg/controller/volume/persistentvolume/testing Index | Files

package testing

import "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/testing"

Index

Package Files

testing.go

Variables

var ErrVersionConflict = errors.New("VersionError")

ErrVersionConflict is the error returned when resource version of requested object conflicts with the object in storage.

type ReactorError Uses

type ReactorError struct {
    Verb     string
    Resource string
    Error    error
}

ReactorError is an error that is returned by test reactor (=simulated etcd+/API server) when an action performed by the reactor matches given verb ("get", "update", "create", "delete" or "*"") on given resource ("persistentvolumes", "persistentvolumeclaims" or "*").

type VolumeReactor Uses

type VolumeReactor struct {
    // contains filtered or unexported fields
}

VolumeReactor is a core.Reactor that simulates etcd and API server. It stores: - Latest version of claims volumes saved by the controller. - Queue of all saves (to simulate "volume/claim updated" events). This queue

contains all intermediate state of an object - e.g. a claim.VolumeName
is updated first and claim.Phase second. This queue will then contain both
updates as separate entries.

- Number of changes since the last call to VolumeReactor.syncAll(). - Optionally, volume and claim fake watchers which should be the same ones

used by the controller. Any time an event function like deleteVolumeEvent
is called to simulate an event, the reactor's stores are updated and the
controller is sent the event via the fake watcher.

- Optionally, list of error that should be returned by reactor, simulating

etcd / API server failures. These errors are evaluated in order and every
error is returned only once. I.e. when the reactor finds matching
ReactorError, it return appropriate error and removes the ReactorError from
the list.

func NewVolumeReactor Uses

func NewVolumeReactor(client *fake.Clientset, fakeVolumeWatch, fakeClaimWatch *watch.FakeWatcher, errors []ReactorError) *VolumeReactor

NewVolumeReactor creates a volume reactor.

func (*VolumeReactor) AddClaim Uses

func (r *VolumeReactor) AddClaim(claim *v1.PersistentVolumeClaim)

AddClaim adds a PVC into VolumeReactor.

func (*VolumeReactor) AddClaimBoundToVolume Uses

func (r *VolumeReactor) AddClaimBoundToVolume(claim *v1.PersistentVolumeClaim)

AddClaimBoundToVolume adds a PVC and binds it to corresponding PV.

func (*VolumeReactor) AddClaimEvent Uses

func (r *VolumeReactor) AddClaimEvent(claim *v1.PersistentVolumeClaim)

AddClaimEvent simulates that a claim has been deleted in etcd and the controller receives 'claim added' event.

func (*VolumeReactor) AddClaims Uses

func (r *VolumeReactor) AddClaims(claims []*v1.PersistentVolumeClaim)

AddClaims adds PVCs into VolumeReactor.

func (*VolumeReactor) AddVolume Uses

func (r *VolumeReactor) AddVolume(volume *v1.PersistentVolume)

AddVolume adds a PV into VolumeReactor.

func (*VolumeReactor) AddVolumes Uses

func (r *VolumeReactor) AddVolumes(volumes []*v1.PersistentVolume)

AddVolumes adds PVs into VolumeReactor.

func (*VolumeReactor) CheckClaims Uses

func (r *VolumeReactor) CheckClaims(expectedClaims []*v1.PersistentVolumeClaim) error

CheckClaims compares all expectedClaims with set of claims at the end of the test and reports differences.

func (*VolumeReactor) CheckVolumes Uses

func (r *VolumeReactor) CheckVolumes(expectedVolumes []*v1.PersistentVolume) error

CheckVolumes compares all expectedVolumes with set of volumes at the end of the test and reports differences.

func (*VolumeReactor) DeleteClaimEvent Uses

func (r *VolumeReactor) DeleteClaimEvent(claim *v1.PersistentVolumeClaim)

DeleteClaimEvent simulates that a claim has been deleted in etcd and the controller receives 'claim deleted' event.

func (*VolumeReactor) DeleteVolume Uses

func (r *VolumeReactor) DeleteVolume(name string)

DeleteVolume deletes a PV by name.

func (*VolumeReactor) DeleteVolumeEvent Uses

func (r *VolumeReactor) DeleteVolumeEvent(volume *v1.PersistentVolume)

DeleteVolumeEvent simulates that a volume has been deleted in etcd and the controller receives 'volume deleted' event.

func (*VolumeReactor) GetChangeCount Uses

func (r *VolumeReactor) GetChangeCount() int

GetChangeCount returns changes since last sync.

func (*VolumeReactor) MarkVolumeAvaiable Uses

func (r *VolumeReactor) MarkVolumeAvaiable(name string)

MarkVolumeAvaiable marks a PV available by name.

func (*VolumeReactor) PopChange Uses

func (r *VolumeReactor) PopChange() interface{}

PopChange returns one recorded updated object, either *v1.PersistentVolume or *v1.PersistentVolumeClaim. Returns nil when there are no changes.

func (*VolumeReactor) React Uses

func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Object, err error)

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 (*VolumeReactor) SyncAll Uses

func (r *VolumeReactor) SyncAll()

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 (*VolumeReactor) Watch Uses

func (r *VolumeReactor) Watch(gvr schema.GroupVersionResource, ns string) (watch.Interface, error)

Watch watches objects from the VolumeReactor. Watch returns a channel which will push added / modified / deleted object.

Package testing imports 17 packages (graph). Updated 2019-07-23. Refresh now. Tools for package owners.