testutils

package
v1.0.0-beta.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDataVolumeAPI added in v0.20.0

func AddDataVolumeAPI(crdInformer cache.SharedIndexInformer)

func AddPrometheusRuleAPI added in v1.0.0

func AddPrometheusRuleAPI(crdInformer cache.SharedIndexInformer)

func AddServiceMonitorAPI added in v1.0.0

func AddServiceMonitorAPI(crdInformer cache.SharedIndexInformer)

func ExpectEvent added in v0.0.4

func ExpectEvent(recorder *record.FakeRecorder, reason string)

func ExpectEvents added in v0.0.4

func ExpectEvents(recorder *record.FakeRecorder, reasons ...string)

ExpectEvents checks for given reasons in arbitrary order

func ExpectVirtioTransitionalOnly added in v0.36.1

func ExpectVirtioTransitionalOnly(dom *api.DomainSpec)

func HaveStatusCode

func HaveStatusCode(expected interface{}) types.GomegaMatcher

func IgnoreEvents added in v0.7.0

func IgnoreEvents(recorder *record.FakeRecorder)

In case we don't care about emitted events, we simply consume all of them and return.

func NewFakeClusterConfigUsingKV added in v0.31.0

func NewFakeClusterConfigUsingKVWithCPUArch added in v0.44.1

func NewFakeClusterConfigUsingKVWithCPUArch(kv *KVv1.KubeVirt, CPUArch string) (*virtconfig.ClusterConfig, cache.SharedIndexInformer, cache.SharedIndexInformer)

func NewFakeContainerDiskSource added in v0.42.0

func NewFakeContainerDiskSource() *KVv1.ContainerDiskSource

func NewFakeInformerFor added in v0.0.4

func NewFakeInformerWithIndexersFor added in v0.16.0

func NewFakeInformerWithIndexersFor(obj runtime.Object, indexers cache.Indexers) (cache.SharedIndexInformer, *framework.FakeControllerSource)

func NewFakeMemoryDumpSource added in v0.54.0

func NewFakeMemoryDumpSource(name string) *KVv1.MemoryDumpVolumeSource

func NewFakePersistentVolumeSource added in v1.0.0

func NewFakePersistentVolumeSource() *KVv1.PersistentVolumeClaimVolumeSource

func RemoveDataVolumeAPI added in v0.20.0

func RemoveDataVolumeAPI(crdInformer cache.SharedIndexInformer)

func RemovePrometheusRuleAPI added in v1.0.0

func RemovePrometheusRuleAPI(crdInformer cache.SharedIndexInformer)

func RemoveServiceMonitorAPI added in v1.0.0

func RemoveServiceMonitorAPI(crdInformer cache.SharedIndexInformer)

func SatisfyAnyRegexp added in v0.18.0

func SatisfyAnyRegexp(regexps []string) types.GomegaMatcher

func UpdateFakeKubeVirtClusterConfig added in v0.34.0

func UpdateFakeKubeVirtClusterConfig(kubeVirtInformer cache.SharedIndexInformer, kv *KVv1.KubeVirt)

Types

type DataVolumeFeeder added in v0.8.0

type DataVolumeFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewDataVolumeFeeder added in v0.8.0

func NewDataVolumeFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *DataVolumeFeeder

func (*DataVolumeFeeder) Add added in v0.8.0

func (v *DataVolumeFeeder) Add(dataVolume *cdiv1.DataVolume)

func (*DataVolumeFeeder) Delete added in v0.8.0

func (v *DataVolumeFeeder) Delete(dataVolume *cdiv1.DataVolume)

func (*DataVolumeFeeder) Modify added in v0.8.0

func (v *DataVolumeFeeder) Modify(dataVolume *cdiv1.DataVolume)

type DomainFeeder added in v0.0.4

type DomainFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewDomainFeeder added in v0.0.4

func NewDomainFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *DomainFeeder

func (*DomainFeeder) Add added in v0.0.4

func (v *DomainFeeder) Add(vmi *api.Domain)

func (*DomainFeeder) Delete added in v0.0.4

func (v *DomainFeeder) Delete(vmi *api.Domain)

func (*DomainFeeder) Modify added in v0.0.4

func (v *DomainFeeder) Modify(vmi *api.Domain)

type MigrationFeeder added in v0.16.0

type MigrationFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewMigrationFeeder added in v0.16.0

func NewMigrationFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *MigrationFeeder

func (*MigrationFeeder) Add added in v0.16.0

func (*MigrationFeeder) Delete added in v0.16.0

func (v *MigrationFeeder) Delete(migration *v1.VirtualMachineInstanceMigration)

func (*MigrationFeeder) Modify added in v0.16.0

func (v *MigrationFeeder) Modify(migration *v1.VirtualMachineInstanceMigration)

type MockInstancetypeMethods added in v0.56.0

type MockInstancetypeMethods struct {
	FindInstancetypeSpecFunc     func(vm *v1.VirtualMachine) (*instancetypev1alpha2.VirtualMachineInstancetypeSpec, error)
	ApplyToVmiFunc               func(field *k8sfield.Path, instancetypespec *instancetypev1alpha2.VirtualMachineInstancetypeSpec, preferenceSpec *instancetypev1alpha2.VirtualMachinePreferenceSpec, vmiSpec *v1.VirtualMachineInstanceSpec) instancetype.Conflicts
	FindPreferenceSpecFunc       func(vm *v1.VirtualMachine) (*instancetypev1alpha2.VirtualMachinePreferenceSpec, error)
	StoreControllerRevisionsFunc func(vm *v1.VirtualMachine) error
	InferDefaultInstancetypeFunc func(vm *v1.VirtualMachine) (*v1.InstancetypeMatcher, error)
	InferDefaultPreferenceFunc   func(vm *v1.VirtualMachine) (*v1.PreferenceMatcher, error)
}

func NewMockInstancetypeMethods added in v0.56.0

func NewMockInstancetypeMethods() *MockInstancetypeMethods

func (*MockInstancetypeMethods) ApplyToVmi added in v0.56.0

func (*MockInstancetypeMethods) FindInstancetypeSpec added in v0.56.0

func (*MockInstancetypeMethods) FindPreferenceSpec added in v0.56.0

func (*MockInstancetypeMethods) InferDefaultInstancetype added in v0.59.0

func (m *MockInstancetypeMethods) InferDefaultInstancetype(vm *v1.VirtualMachine) (*v1.InstancetypeMatcher, error)

func (*MockInstancetypeMethods) InferDefaultPreference added in v0.59.0

func (m *MockInstancetypeMethods) InferDefaultPreference(vm *v1.VirtualMachine) (*v1.PreferenceMatcher, error)

func (*MockInstancetypeMethods) StoreControllerRevisions added in v0.56.0

func (m *MockInstancetypeMethods) StoreControllerRevisions(vm *v1.VirtualMachine) error

type MockWorkQueue added in v0.0.4

type MockWorkQueue struct {
	workqueue.RateLimitingInterface
	// contains filtered or unexported fields
}

MockWorkQueue is a helper workqueue which can be wrapped around any RateLimitingInterface implementing queue. This allows synchronous testing of the controller. The typical pattern is:

MockQueue.ExpectAdd(3)
vmiSource.Add(vmi)
vmiSource.Add(vmi1)
vmiSource.Add(vmi2)
MockQueue.Wait()

This ensures that Source callbacks which are listening on vmiSource enqueued three times an object. Since enqueing is typically the last action in listener callbacks, we can assume that the wanted scenario for a controller is set up, and an execution will process this scenario.

func NewMockWorkQueue added in v0.0.4

func NewMockWorkQueue(queue workqueue.RateLimitingInterface) *MockWorkQueue

func (*MockWorkQueue) Add added in v0.0.4

func (q *MockWorkQueue) Add(obj interface{})

func (*MockWorkQueue) AddAfter added in v0.30.6

func (q *MockWorkQueue) AddAfter(item interface{}, duration time.Duration)

func (*MockWorkQueue) AddRateLimited added in v0.9.0

func (q *MockWorkQueue) AddRateLimited(item interface{})

func (*MockWorkQueue) ExpectAdds added in v0.0.4

func (q *MockWorkQueue) ExpectAdds(diff int)

ExpectAdds allows setting the amount of expected enqueues.

func (*MockWorkQueue) GetAddAfterEnqueueCount added in v0.30.6

func (q *MockWorkQueue) GetAddAfterEnqueueCount() int

func (*MockWorkQueue) GetRateLimitedEnqueueCount added in v0.9.0

func (q *MockWorkQueue) GetRateLimitedEnqueueCount() int

func (*MockWorkQueue) Wait added in v0.0.4

func (q *MockWorkQueue) Wait()

Wait waits until the expected amount of ExpectedAdds has happened. It will not block if there were no expectations set.

type PodDisruptionBudgetFeeder added in v0.16.0

type PodDisruptionBudgetFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewPodDisruptionBudgetFeeder added in v0.16.0

func NewPodDisruptionBudgetFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *PodDisruptionBudgetFeeder

func (*PodDisruptionBudgetFeeder) Add added in v0.16.0

func (*PodDisruptionBudgetFeeder) Delete added in v0.16.0

func (*PodDisruptionBudgetFeeder) Modify added in v0.16.0

type PodFeeder added in v0.5.0

type PodFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewPodFeeder added in v0.5.0

func NewPodFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *PodFeeder

func (*PodFeeder) Add added in v0.5.0

func (v *PodFeeder) Add(pod *k8sv1.Pod)

func (*PodFeeder) Delete added in v0.5.0

func (v *PodFeeder) Delete(pod *k8sv1.Pod)

func (*PodFeeder) Modify added in v0.5.0

func (v *PodFeeder) Modify(pod *k8sv1.Pod)

type VirtualMachineFeeder added in v0.0.4

type VirtualMachineFeeder struct {
	MockQueue *MockWorkQueue
	Source    *framework.FakeControllerSource
}

func NewVirtualMachineFeeder added in v0.0.4

func NewVirtualMachineFeeder(queue *MockWorkQueue, source *framework.FakeControllerSource) *VirtualMachineFeeder

func (*VirtualMachineFeeder) Add added in v0.0.4

func (*VirtualMachineFeeder) Delete added in v0.0.4

func (*VirtualMachineFeeder) Modify added in v0.0.4

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL