Documentation
¶
Overview ¶
Package builder is a comment just to silence the linter.
Index ¶
- Constants
- func AddDummyInstanceStorageVolume(vm *vmopv1.VirtualMachine)
- func CreateContentLibraryItem(ctx context.Context, libMgr *library.Manager, libraryItem library.Item, ...) string
- func DummyAvailabilityZone() *topologyv1.AvailabilityZone
- func DummyBasicVirtualMachine(name, namespace string) *vmopv1.VirtualMachine
- func DummyClusterContentLibrary(name, uuid string) *imgregv1a1.ClusterContentLibrary
- func DummyClusterVirtualMachineImage(imageName string) *vmopv1.ClusterVirtualMachineImage
- func DummyContentLibrary(name, namespace, uuid string) *imgregv1a1.ContentLibrary
- func DummyImageAndItemObjectsForCdromBacking(name, ns, kind, storageURI, libItemUUID string, imgReady, imgCached bool, ...) []ctrlclient.Object
- func DummyInstanceStorage() vmopv1.InstanceStorage
- func DummyInstanceStorageVirtualMachineVolumes() []vmopv1.VirtualMachineVolume
- func DummyNamedAvailabilityZone(name string) *topologyv1.AvailabilityZone
- func DummyPersistentVolumeClaim() *corev1.PersistentVolumeClaim
- func DummyResourceQuota(namespace string, rlNames ...string) *corev1.ResourceQuota
- func DummyStorageClass() *storagev1.StorageClass
- func DummyStorageClassWithID(policyID string) *storagev1.StorageClass
- func DummyStoragePolicyQuota(name, namespace, policyID string) *spqv1.StoragePolicyQuota
- func DummyVirtualMachine() *vmopv1.VirtualMachine
- func DummyVirtualMachineClass(name string) *vmopv1.VirtualMachineClass
- func DummyVirtualMachineClassGenName() *vmopv1.VirtualMachineClass
- func DummyVirtualMachineImage(imageName string) *vmopv1.VirtualMachineImage
- func DummyVirtualMachinePublishRequest(name, namespace, sourceName, itemName, clName string) *vmopv1.VirtualMachinePublishRequest
- func DummyVirtualMachineReplicaSet() *vmopv1.VirtualMachineReplicaSet
- func DummyVirtualMachineService() *vmopv1.VirtualMachineService
- func DummyVirtualMachineSetResourcePolicy() *vmopv1.VirtualMachineSetResourcePolicy
- func DummyVirtualMachineSetResourcePolicy2(name, namespace string) *vmopv1.VirtualMachineSetResourcePolicy
- func DummyVirtualMachineSnapshot(namespace, name, vmName string) *vmopv1.VirtualMachineSnapshot
- func DummyVirtualMachineWebConsoleRequest(namespace, wcrName, vmName, pubKey string) *vmopv1.VirtualMachineWebConsoleRequest
- func DummyWebConsoleRequest(namespace, wcrName, vmName, pubKey string) *vmopv1a1.WebConsoleRequest
- func DummyZone(namespace string) *topologyv1.Zone
- func GetNsxTLogicalSwitchUUID(idx int) string
- func GetVPCTLogicalSwitchUUID(idx int) string
- func KnownObjectTypes() []client.Object
- func LoadCRDs(rootFilePath string) ([]*apiextensionsv1.CustomResourceDefinition, error)
- func NewFakeClient(objs ...client.Object) client.Client
- func NewFakeClientWithInterceptors(funcs interceptor.Funcs, objs ...client.Object) client.Client
- func NewFakeRecorder() (record.Recorder, chan string)
- func NewScheme() *runtime.Scheme
- func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)
- func WebConsoleRequestKeyPair() (privateKey *rsa.PrivateKey, publicKeyPem string)
- type InitEnvFn
- type InitVCSimEnvFn
- type IntegrationTestContext
- type IntegrationTestContextForVCSim
- type NetworkEnv
- type NewReconcilerFunc
- type Reconciler
- type TestContextForVCSim
- func (c *TestContextForVCSim) AfterEach()
- func (c *TestContextForVCSim) ContentLibraryItemTemplate(srcVMName, templateName string)
- func (c *TestContextForVCSim) CreateVirtualMachineSetResourcePolicy(name string, nsInfo WorkloadNamespaceInfo) (*vmopv1.VirtualMachineSetResourcePolicy, *object.Folder)
- func (c *TestContextForVCSim) CreateWorkloadNamespace() WorkloadNamespaceInfo
- func (c *TestContextForVCSim) GetAZClusterComputes(azName string) []*object.ClusterComputeResource
- func (c *TestContextForVCSim) GetFirstClusterFromFirstZone() *object.ClusterComputeResource
- func (c *TestContextForVCSim) GetFirstZoneName() string
- func (c *TestContextForVCSim) GetResourcePoolForNamespace(namespace, azName, childName string) *object.ResourcePool
- func (c *TestContextForVCSim) GetVMFromMoID(moID string) *object.VirtualMachine
- func (c *TestContextForVCSim) SimulatorContext() *simulator.Context
- type TestSuite
- func NewFunctionalTestSuite(...) *TestSuite
- func NewTestSuite() *TestSuite
- func NewTestSuiteForController(addToManagerFn pkgmgr.AddToManagerFunc, ...) *TestSuite
- func NewTestSuiteForControllerWithContext(ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, ...) *TestSuite
- func NewTestSuiteForControllerWithContextAndInitEnvFuncs(ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, ...) *TestSuite
- func NewTestSuiteForMutatingWebhook(addToManagerFn pkgmgr.AddToManagerFunc, newMutatorFn builder.MutatorFunc, ...) *TestSuite
- func NewTestSuiteForMutatingWebhookWithContext(ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, ...) *TestSuite
- func NewTestSuiteForValidatingWebhook(addToManagerFn pkgmgr.AddToManagerFunc, newValidatorFn builder.ValidatorFunc, ...) *TestSuite
- func NewTestSuiteForValidatingWebhookWithContext(ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, ...) *TestSuite
- func NewTestSuiteWithContext(ctx context.Context) *TestSuite
- func (s *TestSuite) AfterSuite()
- func (s *TestSuite) BeforeSuite()
- func (s *TestSuite) GetEnvTestConfig() *rest.Config
- func (s *TestSuite) GetInstalledCRD(crdName string) *apiextensionsv1.CustomResourceDefinition
- func (s *TestSuite) GetLogger() logr.Logger
- func (s *TestSuite) GetManager() pkgmgr.Manager
- func (s *TestSuite) NewIntegrationTestContext() *IntegrationTestContext
- func (s *TestSuite) NewTestContextForVCSim(config VCSimTestConfig, initObjects ...ctrlclient.Object) *TestContextForVCSim
- func (s *TestSuite) NewTestContextForVCSimWithParentContext(ctx context.Context, config VCSimTestConfig, initObjects ...ctrlclient.Object) *TestContextForVCSim
- func (s *TestSuite) NewUnitTestContextForController(initObjects ...client.Object) *UnitTestContextForController
- func (s *TestSuite) NewUnitTestContextForControllerWithFuncs(funcs interceptor.Funcs, initObjects ...client.Object) *UnitTestContextForController
- func (s *TestSuite) NewUnitTestContextForMutatingWebhook(obj *unstructured.Unstructured) *UnitTestContextForMutatingWebhook
- func (s *TestSuite) NewUnitTestContextForValidatingWebhook(obj, oldObj *unstructured.Unstructured, initObjects ...client.Object) *UnitTestContextForValidatingWebhook
- func (s *TestSuite) Register(t *testing.T, name string, runIntegrationTestsFn, runUnitTestsFn func())
- func (s *TestSuite) SetManagerNewCacheFunc(f ctrlcache.NewCacheFunc)
- func (s *TestSuite) StartErr() error
- func (s *TestSuite) UpdateCRDScope(oldCrd *apiextensionsv1.CustomResourceDefinition, newScope string)
- func (s *TestSuite) UpdateCRDStorage(oldCrd *apiextensionsv1.CustomResourceDefinition)
- type UnitTestContext
- type UnitTestContextForController
- type UnitTestContextForMutatingWebhook
- type UnitTestContextForValidatingWebhook
- type VCSimTestConfig
- type WorkloadNamespaceInfo
Constants ¶
const ( DummyVMIName = "vmi-0123456789" DummyCVMIName = "vmi-9876543210" DummyImageName = "dummy-image-name" DummyClassName = "dummyClassName" DummyVolumeName = "dummy-volume-name" DummyPVCName = "dummyPVCName" DummyDistroVersion = "dummyDistroVersion" DummyOSType = "centosGuest" DummyStorageClassName = "dummy-storage-class" DummyResourceQuotaName = "dummy-resource-quota" DummyZoneName = "dummy-zone" DummyDeletedZoneName = "dummy-zone-deleted" )
const ( NetworkEnvVDS = NetworkEnv("vds") NetworkEnvNSXT = NetworkEnv("nsx-t") NetworkEnvVPC = NetworkEnv("nsx-t-vpc") NetworkEnvNamed = NetworkEnv("named") NsxTLogicalSwitchUUID = "nsxt-dummy-ls-uuid" VPCLogicalSwitchUUID = "vpc-dummy-ls-uuid" )
Variables ¶
This section is empty.
Functions ¶
func AddDummyInstanceStorageVolume ¶
func AddDummyInstanceStorageVolume(vm *vmopv1.VirtualMachine)
func CreateContentLibraryItem ¶ added in v1.9.0
func DummyAvailabilityZone ¶
func DummyAvailabilityZone() *topologyv1.AvailabilityZone
func DummyBasicVirtualMachine ¶
func DummyBasicVirtualMachine(name, namespace string) *vmopv1.VirtualMachine
func DummyClusterContentLibrary ¶
func DummyClusterContentLibrary(name, uuid string) *imgregv1a1.ClusterContentLibrary
func DummyClusterVirtualMachineImage ¶
func DummyClusterVirtualMachineImage(imageName string) *vmopv1.ClusterVirtualMachineImage
func DummyContentLibrary ¶
func DummyContentLibrary(name, namespace, uuid string) *imgregv1a1.ContentLibrary
func DummyImageAndItemObjectsForCdromBacking ¶ added in v1.9.0
func DummyImageAndItemObjectsForCdromBacking( name, ns, kind, storageURI, libItemUUID string, imgReady, imgCached bool, imgSize resource.Quantity, imgHasProviderRef, itemObjExists bool, itemType imgregv1a1.ContentLibraryItemType) []ctrlclient.Object
func DummyInstanceStorage ¶
func DummyInstanceStorage() vmopv1.InstanceStorage
func DummyInstanceStorageVirtualMachineVolumes ¶
func DummyInstanceStorageVirtualMachineVolumes() []vmopv1.VirtualMachineVolume
func DummyNamedAvailabilityZone ¶ added in v1.8.6
func DummyNamedAvailabilityZone(name string) *topologyv1.AvailabilityZone
func DummyPersistentVolumeClaim ¶
func DummyPersistentVolumeClaim() *corev1.PersistentVolumeClaim
func DummyResourceQuota ¶
func DummyResourceQuota(namespace string, rlNames ...string) *corev1.ResourceQuota
func DummyStorageClass ¶
func DummyStorageClass() *storagev1.StorageClass
func DummyStorageClassWithID ¶ added in v1.10.0
func DummyStorageClassWithID(policyID string) *storagev1.StorageClass
func DummyStoragePolicyQuota ¶ added in v1.8.6
func DummyStoragePolicyQuota(name, namespace, policyID string) *spqv1.StoragePolicyQuota
func DummyVirtualMachine ¶
func DummyVirtualMachine() *vmopv1.VirtualMachine
func DummyVirtualMachineClass ¶
func DummyVirtualMachineClass(name string) *vmopv1.VirtualMachineClass
func DummyVirtualMachineClassGenName ¶ added in v1.9.0
func DummyVirtualMachineClassGenName() *vmopv1.VirtualMachineClass
func DummyVirtualMachineImage ¶
func DummyVirtualMachineImage(imageName string) *vmopv1.VirtualMachineImage
func DummyVirtualMachinePublishRequest ¶
func DummyVirtualMachinePublishRequest(name, namespace, sourceName, itemName, clName string) *vmopv1.VirtualMachinePublishRequest
func DummyVirtualMachineReplicaSet ¶ added in v1.9.0
func DummyVirtualMachineReplicaSet() *vmopv1.VirtualMachineReplicaSet
func DummyVirtualMachineService ¶
func DummyVirtualMachineService() *vmopv1.VirtualMachineService
func DummyVirtualMachineSetResourcePolicy ¶
func DummyVirtualMachineSetResourcePolicy() *vmopv1.VirtualMachineSetResourcePolicy
func DummyVirtualMachineSetResourcePolicy2 ¶
func DummyVirtualMachineSetResourcePolicy2(name, namespace string) *vmopv1.VirtualMachineSetResourcePolicy
func DummyVirtualMachineSnapshot ¶ added in v1.10.0
func DummyVirtualMachineSnapshot(namespace, name, vmName string) *vmopv1.VirtualMachineSnapshot
func DummyVirtualMachineWebConsoleRequest ¶ added in v1.8.5
func DummyVirtualMachineWebConsoleRequest(namespace, wcrName, vmName, pubKey string) *vmopv1.VirtualMachineWebConsoleRequest
func DummyWebConsoleRequest ¶
func DummyWebConsoleRequest(namespace, wcrName, vmName, pubKey string) *vmopv1a1.WebConsoleRequest
func DummyZone ¶ added in v1.9.0
func DummyZone(namespace string) *topologyv1.Zone
DummyZone uses the same name with AZ.
func GetNsxTLogicalSwitchUUID ¶ added in v1.10.0
func GetVPCTLogicalSwitchUUID ¶ added in v1.10.0
func KnownObjectTypes ¶ added in v1.8.5
KnownObjectTypes has the known VM operator types that will be status enabled when initializing the fake client. Add any types here if the fake client needs to patch the Status sub-resource of that resource type.
func LoadCRDs ¶ added in v1.8.5
func LoadCRDs(rootFilePath string) ([]*apiextensionsv1.CustomResourceDefinition, error)
func NewFakeClientWithInterceptors ¶ added in v1.9.0
func NewFakeRecorder ¶
func ToUnstructured ¶
func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)
func WebConsoleRequestKeyPair ¶
func WebConsoleRequestKeyPair() (privateKey *rsa.PrivateKey, publicKeyPem string)
Types ¶
type InitEnvFn ¶ added in v1.9.0
InitEnvFn is used to initialize an environment prior to the manager starting.
type InitVCSimEnvFn ¶ added in v1.9.0
type InitVCSimEnvFn func(ctx *IntegrationTestContextForVCSim)
InitVCSimEnvFn is used to initialize an environment prior to the manager starting.
type IntegrationTestContext ¶
type IntegrationTestContext struct {
context.Context
Client client.Client
Namespace string
PodNamespace string
}
IntegrationTestContext is used for integration testing. Each IntegrationTestContext contains one separate namespace.
func (*IntegrationTestContext) AfterEach ¶
func (ctx *IntegrationTestContext) AfterEach()
AfterEach should be invoked by ginkgo.AfterEach to destroy the test namespace.
type IntegrationTestContextForVCSim ¶ added in v1.9.0
type IntegrationTestContextForVCSim struct {
TestContextForVCSim
Suite *TestSuite
NSInfo WorkloadNamespaceInfo
}
func NewIntegrationTestContextForVCSim ¶ added in v1.9.0
func NewIntegrationTestContextForVCSim( ctx context.Context, config VCSimTestConfig, addToManagerFn pkgmgr.AddToManagerFunc, initProvidersFn pkgmgr.InitializeProvidersFunc, initEnvFn InitVCSimEnvFn) *IntegrationTestContextForVCSim
func (*IntegrationTestContextForVCSim) AfterEach ¶ added in v1.9.0
func (c *IntegrationTestContextForVCSim) AfterEach()
func (*IntegrationTestContextForVCSim) BeforeEach ¶ added in v1.9.0
func (c *IntegrationTestContextForVCSim) BeforeEach()
type NetworkEnv ¶ added in v1.8.1
type NetworkEnv string
type NewReconcilerFunc ¶
type NewReconcilerFunc func() Reconciler
NewReconcilerFunc is a base type for functions that return a reconciler.
type TestContextForVCSim ¶
type TestContextForVCSim struct {
// NOTE: Unit test in the context of test suite framework means we use
// the fake k8s client, which is sufficient for our needs. Otherwise,
// unit testing is a little misleading here since we're using vcsim.
*UnitTestContext
PodNamespace string
VCClient *govmomi.Client
VCClientConfig pkgclient.Config
Datacenter *object.Datacenter
Finder *find.Finder
RestClient *rest.Client
Recorder record.Recorder
Datastore *object.Datastore
ZoneCount int
ClustersPerZone int
ZoneNames []string
// When WithContentLibrary is true:
LocalContentLibraryID string
ContentLibraryImageName string
ContentLibraryID string
ContentLibraryItemID string
ContentLibraryItemVersion string
ContentLibraryItemDiskPath string
ContentLibraryItemNVRAMPath string
ContentLibraryIsoImageName string
ContentLibraryIsoItemID string
ContentLibraryIsoItemVersion string
// When WithoutStorageClass is false:
StorageClassName string
StorageProfileID string
EncryptedStorageClassName string
EncryptedStorageProfileID string
// When WithoutEncryptionClass is false:
EncryptionClass1Name string
EncryptionClass1ProviderID string
EncryptionClass2Name string
EncryptionClass2ProviderID string
// When WithoutNativeKeyProvider is false:
NativeKeyProviderID string
NetworkRef object.NetworkReference
NetworkRefs []object.NetworkReference
// contains filtered or unexported fields
}
func NewTestContextForVCSim ¶ added in v1.9.0
func NewTestContextForVCSim( parentCtx context.Context, config VCSimTestConfig, initObjects ...ctrlclient.Object) *TestContextForVCSim
func (*TestContextForVCSim) AfterEach ¶
func (c *TestContextForVCSim) AfterEach()
AfterEach is a comment just to silence the linter TODO: Once we update ginkgo, this is more suitable as an AfterAll().
func (*TestContextForVCSim) ContentLibraryItemTemplate ¶
func (c *TestContextForVCSim) ContentLibraryItemTemplate(srcVMName, templateName string)
func (*TestContextForVCSim) CreateVirtualMachineSetResourcePolicy ¶
func (c *TestContextForVCSim) CreateVirtualMachineSetResourcePolicy( name string, nsInfo WorkloadNamespaceInfo) (*vmopv1.VirtualMachineSetResourcePolicy, *object.Folder)
func (*TestContextForVCSim) CreateWorkloadNamespace ¶
func (c *TestContextForVCSim) CreateWorkloadNamespace() WorkloadNamespaceInfo
func (*TestContextForVCSim) GetAZClusterComputes ¶
func (c *TestContextForVCSim) GetAZClusterComputes(azName string) []*object.ClusterComputeResource
func (*TestContextForVCSim) GetFirstClusterFromFirstZone ¶ added in v1.8.6
func (c *TestContextForVCSim) GetFirstClusterFromFirstZone() *object.ClusterComputeResource
func (*TestContextForVCSim) GetFirstZoneName ¶ added in v1.8.6
func (c *TestContextForVCSim) GetFirstZoneName() string
func (*TestContextForVCSim) GetResourcePoolForNamespace ¶
func (c *TestContextForVCSim) GetResourcePoolForNamespace(namespace, azName, childName string) *object.ResourcePool
func (*TestContextForVCSim) GetVMFromMoID ¶
func (c *TestContextForVCSim) GetVMFromMoID(moID string) *object.VirtualMachine
func (*TestContextForVCSim) SimulatorContext ¶ added in v1.10.0
func (c *TestContextForVCSim) SimulatorContext() *simulator.Context
type TestSuite ¶
type TestSuite struct {
context.Context
// StartErrExpected may be set to true to expect an error from
// manager.Start.
StartErrExpected bool
// contains filtered or unexported fields
}
TestSuite is used for unit and integration testing builder. Each TestSuite contains one independent test environment and a controller manager.
func NewFunctionalTestSuite ¶
func NewFunctionalTestSuite(addToManagerFunc func(ctx *pkgctx.ControllerManagerContext, mgr manager.Manager) error) *TestSuite
NewFunctionalTestSuite returns a new test suite used for functional tests. The functional test starts all the controllers, and creates all the providers so it is a more fully functioning env than an integration test with a single controller running.
func NewTestSuite ¶
func NewTestSuite() *TestSuite
NewTestSuite returns a new test suite used for unit and/or integration test.
func NewTestSuiteForController ¶
func NewTestSuiteForController(addToManagerFn pkgmgr.AddToManagerFunc, initProvidersFn pkgmgr.InitializeProvidersFunc) *TestSuite
NewTestSuiteForController returns a new test suite used for controller integration test.
func NewTestSuiteForControllerWithContext ¶ added in v1.8.6
func NewTestSuiteForControllerWithContext( ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, initProvidersFn pkgmgr.InitializeProvidersFunc) *TestSuite
NewTestSuiteForControllerWithContext returns a new test suite used for controller integration test.
func NewTestSuiteForControllerWithContextAndInitEnvFuncs ¶ added in v1.9.0
func NewTestSuiteForControllerWithContextAndInitEnvFuncs( ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, initProvidersFn pkgmgr.InitializeProvidersFunc, initEnvFuncs []InitEnvFn) *TestSuite
NewTestSuiteForControllerWithContextAndInitEnvFuncs returns a new test suite used for controller integration test.
func NewTestSuiteForMutatingWebhook ¶
func NewTestSuiteForMutatingWebhook( addToManagerFn pkgmgr.AddToManagerFunc, newMutatorFn builder.MutatorFunc, webhookName string) *TestSuite
NewTestSuiteForMutatingWebhook returns a new test suite used for unit and integration testing mutating webhooks created using the "pkg/builder" package.
func NewTestSuiteForMutatingWebhookWithContext ¶ added in v1.8.6
func NewTestSuiteForMutatingWebhookWithContext( ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, newMutatorFn builder.MutatorFunc, webhookName string) *TestSuite
NewTestSuiteForMutatingWebhookWithContext returns a new test suite used for unit and integration testing mutating webhooks created using the "pkg/builder" package.
func NewTestSuiteForValidatingWebhook ¶
func NewTestSuiteForValidatingWebhook( addToManagerFn pkgmgr.AddToManagerFunc, newValidatorFn builder.ValidatorFunc, webhookName string) *TestSuite
NewTestSuiteForValidatingWebhook returns a new test suite used for unit and integration testing validating webhooks created using the "pkg/builder" package.
func NewTestSuiteForValidatingWebhookWithContext ¶ added in v1.8.6
func NewTestSuiteForValidatingWebhookWithContext( ctx context.Context, addToManagerFn pkgmgr.AddToManagerFunc, newValidatorFn builder.ValidatorFunc, webhookName string) *TestSuite
NewTestSuiteForValidatingWebhookWithContext returns a new test suite used for unit and integration testing validating webhooks created using the "pkg/builder" package.
func NewTestSuiteWithContext ¶ added in v1.9.0
NewTestSuiteWithContext returns a new test suite used for unit and/or integration test.
func (*TestSuite) AfterSuite ¶
func (s *TestSuite) AfterSuite()
AfterSuite should be invoked by ginkgo.AfterSuite.
func (*TestSuite) BeforeSuite ¶
func (s *TestSuite) BeforeSuite()
BeforeSuite should be invoked by ginkgo.BeforeSuite.
func (*TestSuite) GetEnvTestConfig ¶
func (*TestSuite) GetInstalledCRD ¶
func (s *TestSuite) GetInstalledCRD(crdName string) *apiextensionsv1.CustomResourceDefinition
func (*TestSuite) GetManager ¶ added in v1.8.6
func (*TestSuite) NewIntegrationTestContext ¶
func (s *TestSuite) NewIntegrationTestContext() *IntegrationTestContext
NewIntegrationTestContext should be invoked by ginkgo.BeforeEach
This function creates a namespace with a random name to separate integration test cases
This function returns a TestSuite context The resources created by this function may be cleaned up by calling AfterEach with the IntegrationTestContext returned by this function.
func (*TestSuite) NewTestContextForVCSim ¶
func (s *TestSuite) NewTestContextForVCSim( config VCSimTestConfig, initObjects ...ctrlclient.Object) *TestContextForVCSim
func (*TestSuite) NewTestContextForVCSimWithParentContext ¶ added in v1.9.0
func (s *TestSuite) NewTestContextForVCSimWithParentContext( ctx context.Context, config VCSimTestConfig, initObjects ...ctrlclient.Object) *TestContextForVCSim
func (*TestSuite) NewUnitTestContextForController ¶
func (s *TestSuite) NewUnitTestContextForController(initObjects ...client.Object) *UnitTestContextForController
NewUnitTestContextForController returns a new unit test context for this suite's reconciler.
Returns nil if unit testing is disabled.
func (*TestSuite) NewUnitTestContextForControllerWithFuncs ¶ added in v1.9.0
func (s *TestSuite) NewUnitTestContextForControllerWithFuncs( funcs interceptor.Funcs, initObjects ...client.Object) *UnitTestContextForController
NewUnitTestContextForControllerWithFuncs returns a new unit test context for this suite's reconciler.
Returns nil if unit testing is disabled.
func (*TestSuite) NewUnitTestContextForMutatingWebhook ¶
func (s *TestSuite) NewUnitTestContextForMutatingWebhook(obj *unstructured.Unstructured) *UnitTestContextForMutatingWebhook
NewUnitTestContextForMutatingWebhook returns a new unit test context for this suite's mutator.
Returns nil if unit testing is disabled.
func (*TestSuite) NewUnitTestContextForValidatingWebhook ¶
func (s *TestSuite) NewUnitTestContextForValidatingWebhook( obj, oldObj *unstructured.Unstructured, initObjects ...client.Object) *UnitTestContextForValidatingWebhook
NewUnitTestContextForValidatingWebhook returns a new unit test context for this suite's validator.
Returns nil if unit testing is disabled.
func (*TestSuite) Register ¶
func (s *TestSuite) Register(t *testing.T, name string, runIntegrationTestsFn, runUnitTestsFn func())
Register should be invoked by the function to which *testing.T is passed.
Use runUnitTestsFn to pass a function that will be invoked if unit testing is enabled with Describe("Unit tests", runUnitTestsFn).
Use runIntegrationTestsFn to pass a function that will be invoked if integration testing is enabled with Describe("Unit tests", runIntegrationTestsFn).
func (*TestSuite) SetManagerNewCacheFunc ¶ added in v1.8.6
func (s *TestSuite) SetManagerNewCacheFunc(f ctrlcache.NewCacheFunc)
func (*TestSuite) UpdateCRDScope ¶
func (s *TestSuite) UpdateCRDScope(oldCrd *apiextensionsv1.CustomResourceDefinition, newScope string)
func (*TestSuite) UpdateCRDStorage ¶ added in v1.10.0
func (s *TestSuite) UpdateCRDStorage(oldCrd *apiextensionsv1.CustomResourceDefinition)
type UnitTestContext ¶
UnitTestContext is used for general purpose unit testing.
func NewUnitTestContext ¶
func NewUnitTestContext(initObjects ...client.Object) *UnitTestContext
NewUnitTestContext returns a new UnitTestContext.
func NewUnitTestContextWithParentContext ¶ added in v1.9.0
func NewUnitTestContextWithParentContext(ctx context.Context, initObjects ...client.Object) *UnitTestContext
func (*UnitTestContext) AfterEach ¶
func (ctx *UnitTestContext) AfterEach()
AfterEach should be invoked by ginkgo.AfterEach to cleanup.
type UnitTestContextForController ¶
type UnitTestContextForController struct {
// context is the pkgctx.ControllerManagerContext for being tested.
pkgctx.ControllerManagerContext
// Client is the k8s client to access resources.
Client client.Client
// reconciler is the reconcile.Reconciler being unit tested.
Reconciler reconcile.Reconciler
// Events is a channel that fake recorder records events to.
Events chan string
}
UnitTestContextForController is used for unit testing controllers.
func NewUnitTestContextForController ¶
func NewUnitTestContextForController( initObjects []client.Object) *UnitTestContextForController
NewUnitTestContextForController returns a new UnitTestContextForController for unit testing controllers.
func NewUnitTestContextForControllerWithFuncs ¶ added in v1.9.0
func NewUnitTestContextForControllerWithFuncs( funcs interceptor.Funcs, initObjects []client.Object) *UnitTestContextForController
NewUnitTestContextForControllerWithFuncs returns a new UnitTestContextForController for unit testing controllers.
func (*UnitTestContextForController) AfterEach ¶
func (ctx *UnitTestContextForController) AfterEach()
AfterEach should be invoked by ginkgo.AfterEach to cleanup.
type UnitTestContextForMutatingWebhook ¶
type UnitTestContextForMutatingWebhook struct {
// WebhookRequestContext is initialized with fake.NewWebhookRequestContext
// and is used for unit testing.
pkgctx.WebhookRequestContext
// Client is the k8s client to access resources.
Client client.Client
// Key may be used to lookup Ctx.Cluster with Ctx.Client.Get.
Key client.ObjectKey
// mutator is the builder.Mutator being unit tested.
builder.Mutator
}
UnitTestContextForMutatingWebhook is used for unit testing mutating webhooks.
func NewUnitTestContextForMutatingWebhook ¶
func NewUnitTestContextForMutatingWebhook( mutatorFn builder.MutatorFunc, obj *unstructured.Unstructured) *UnitTestContextForMutatingWebhook
NewUnitTestContextForMutatingWebhook returns a new UnitTestContextForMutatingWebhook for unit testing mutating webhooks.
type UnitTestContextForValidatingWebhook ¶
type UnitTestContextForValidatingWebhook struct {
// WebhookRequestContext is initialized with fake.NewWebhookRequestContext
// and is used for unit testing.
pkgctx.WebhookRequestContext
// Client is the k8s client to access resources.
Client client.Client
// Key may be used to lookup Ctx.Obj with Ctx.Client.Get.
Key client.ObjectKey
// validator is the builder.Validator being unit tested.
builder.Validator
}
UnitTestContextForValidatingWebhook is used for unit testing validating webhooks.
func NewUnitTestContextForValidatingWebhook ¶
func NewUnitTestContextForValidatingWebhook( validatorFn builder.ValidatorFunc, obj, oldObj *unstructured.Unstructured, initObjects ...client.Object) *UnitTestContextForValidatingWebhook
NewUnitTestContextForValidatingWebhook returns a new UnitTestContextForValidatingWebhook for unit testing validating webhooks.
type VCSimTestConfig ¶
type VCSimTestConfig struct {
// NumFaultDomains is the number of zones.
NumFaultDomains int
// NumNetworks is the number of networks.
NumNetworks int
// WithContentLibrary configures a Content Library, populated with one image's
// name available in the TestContextForVCSim.ContentLibraryImageName.
WithContentLibrary bool
// WithInstanceStorage enables the WCP_INSTANCE_STORAGE FSS.
WithInstanceStorage bool
// WithVMResize enables the FSS_WCP_VMSERVICE_RESIZE FSS.
WithVMResize bool
// WithVMResize enables the FSS_WCP_VMSERVICE_RESIZE_CPU_MEMORY FSS.
WithVMResizeCPUMemory bool
// WithVMIncrementalRestore enables the FSS_WCP_VMSERVICE_INCREMENTAL_RESTORE FSS.
WithVMIncrementalRestore bool
// WithVMSnapshots enables the FSS_WCP_VMSERVICE_VM_SNAPSHOTS FSS.
WithVMSnapshots bool
// WithoutStorageClass disables the storage class required, meaning that the
// Datastore will be used instead. In WCP production the storage class is
// always required; the Datastore is only needed for gce2e.
WithoutStorageClass bool
// WithoutWorkloadDomainIsolation disables the WorkloadDomainIsolation capability.
WithoutWorkloadDomainIsolation bool
// WithJSONExtraConfig enables additional ExtraConfig that is included when
// creating a VM.
WithJSONExtraConfig string
// WithDefaultNetwork string sets the default network VM NICs will use.
// In WCP production this is never set; it only exists for current
// limitations of gce2e.
WithDefaultNetwork string
// WithNetworkEnv is the network environment type.
WithNetworkEnv NetworkEnv
// WithoutEncryptionClass disables the creation of the EncryptionClass
// resource in each workload namespace.
WithoutEncryptionClass bool
// WithoutNativeKeyProvider disables the creation of the native key provider
// in vcsim.
WithoutNativeKeyProvider bool
}
VCSimTestConfig configures the vcsim environment.