unittestcommon

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFakeContainerOrchestratorInterface

func GetFakeContainerOrchestratorInterface(orchestratorType int) (commonco.COCommonInterface, error)

GetFakeContainerOrchestratorInterface returns a dummy CO interface based on the CO type

func InitFakeVolumeOperationRequestInterface

func InitFakeVolumeOperationRequestInterface() (cnsvolumeoperationrequest.VolumeOperationRequest, error)

InitFakeVolumeOperationRequestInterface returns a fake implementation of the VolumeOperationRequest interface.

Types

type FakeK8SOrchestrator

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

FakeK8SOrchestrator is used to mock common K8S Orchestrator instance to store FSS values

func (*FakeK8SOrchestrator) AnnotateVolumeSnapshot

func (c *FakeK8SOrchestrator) AnnotateVolumeSnapshot(ctx context.Context, volumeSnapshotName string,
	volumeSnapshotNamespace string, annotations map[string]string) (bool, error)

AnnotateVolumeSnapshot annotates the volumesnapshot CR in k8s cluster

func (*FakeK8SOrchestrator) ClearFakeAttached

func (c *FakeK8SOrchestrator) ClearFakeAttached(ctx context.Context, volumeID string) error

ClearFakeAttached checks if the volume was fake attached, and unmark it as not fake attached.

func (*FakeK8SOrchestrator) CreateConfigMap

func (c *FakeK8SOrchestrator) CreateConfigMap(ctx context.Context, name string, namespace string,
	data map[string]string, isImmutable bool) error

CreateConfigMap creates the ConfigMap with given name, namespace, data and immutable parameter values.

func (*FakeK8SOrchestrator) GetAllK8sVolumes

func (c *FakeK8SOrchestrator) GetAllK8sVolumes() []string

GetAllK8sVolumes returns list of volumes in a bound state, present in the K8s cluster

func (*FakeK8SOrchestrator) GetAllVolumes

func (c *FakeK8SOrchestrator) GetAllVolumes() []string

GetAllVolumes returns list of volumes in a bound state

func (*FakeK8SOrchestrator) GetCSINodeTopologyInstanceByName

func (c *FakeK8SOrchestrator) GetCSINodeTopologyInstanceByName(nodeName string) (
	item interface{}, exists bool, err error)

GetCSINodeTopologyInstanceByName fetches the CSINodeTopology instance for a given node name in the cluster.

func (*FakeK8SOrchestrator) GetCSINodeTopologyInstancesList

func (c *FakeK8SOrchestrator) GetCSINodeTopologyInstancesList() []interface{}

GetCSINodeTopologyInstancesList lists CSINodeTopology instances for a given cluster.

func (*FakeK8SOrchestrator) GetConfigMap

func (c *FakeK8SOrchestrator) GetConfigMap(ctx context.Context, name string,
	namespace string) (map[string]string, error)

GetConfigMap checks if ConfigMap with given name exists in the given namespace. If it exists, this function returns ConfigMap data, otherwise returns error.

func (*FakeK8SOrchestrator) GetFakeAttachedVolumes

func (c *FakeK8SOrchestrator) GetFakeAttachedVolumes(ctx context.Context, volumeID []string) map[string]bool

GetFakeAttachedVolumes returns a map of volumeIDs to a bool, which is set to true if volumeID key is fake attached else false

func (*FakeK8SOrchestrator) GetNodeIDtoNameMap

func (c *FakeK8SOrchestrator) GetNodeIDtoNameMap(ctx context.Context) map[string]string

GetNodeIDtoNameMap returns a map containing the nodeID to node name

func (*FakeK8SOrchestrator) GetNodesForVolumes

func (c *FakeK8SOrchestrator) GetNodesForVolumes(ctx context.Context, volumeID []string) map[string][]string

GetNodesForVolumes returns nodeNames to which the given volumeIDs are attached

func (*FakeK8SOrchestrator) GetPVNameFromCSIVolumeID added in v3.0.3

func (c *FakeK8SOrchestrator) GetPVNameFromCSIVolumeID(volumeID string) (string, bool)

GetPVNameFromCSIVolumeID retrieves the pv name from volumeID.

func (*FakeK8SOrchestrator) GetVolumeAttachment

func (c *FakeK8SOrchestrator) GetVolumeAttachment(ctx context.Context, volumeId string, nodeName string) (
	*storagev1.VolumeAttachment, error)

GetVolumeAttachment returns the VA object by using the given volumeId & nodeName

func (*FakeK8SOrchestrator) InitTopologyServiceInController

func (c *FakeK8SOrchestrator) InitTopologyServiceInController(ctx context.Context) (
	commoncotypes.ControllerTopologyService, error)

InitTopologyServiceInController returns a singleton implementation of the commoncotypes.ControllerTopologyService interface for the FakeK8SOrchestrator.

func (*FakeK8SOrchestrator) InitTopologyServiceInNode

func (c *FakeK8SOrchestrator) InitTopologyServiceInNode(ctx context.Context) (
	commoncotypes.NodeTopologyService, error)

InitTopologyServiceInNode returns a singleton implementation of the commoncotypes.NodeTopologyService interface for the FakeK8SOrchestrator.

func (*FakeK8SOrchestrator) InitializeCSINodes added in v3.2.0

func (c *FakeK8SOrchestrator) InitializeCSINodes(ctx context.Context) error

InitializeCSINodes creates CSINode instances for each K8s node with the appropriate topology keys.

func (*FakeK8SOrchestrator) IsFSSEnabled

func (c *FakeK8SOrchestrator) IsFSSEnabled(ctx context.Context, featureName string) bool

IsFSSEnabled returns the FSS values for a given feature

func (*FakeK8SOrchestrator) IsFakeAttachAllowed

func (c *FakeK8SOrchestrator) IsFakeAttachAllowed(
	ctx context.Context,
	volumeID string,
	volumeManager cnsvolume.Manager,
) (bool, error)

IsFakeAttachAllowed checks if the passed volume can be fake attached and mark it as fake attached.

func (*FakeK8SOrchestrator) MarkFakeAttached

func (c *FakeK8SOrchestrator) MarkFakeAttached(ctx context.Context, volumeID string) error

MarkFakeAttached marks the volume as fake attached.

type MockVolumeMigrationService

type MockVolumeMigrationService interface {
	// GetVolumeID returns VolumeID for given migration volumeSpec
	// Returns an error if not able to retrieve VolumeID.
	GetVolumeID(ctx context.Context, volumeSpec *migration.VolumeSpec) (string, error)

	// GetVolumePath returns VolumePath for given VolumeID
	// Returns an error if not able to retrieve VolumePath.
	GetVolumePath(ctx context.Context, volumeID string) (string, error)

	// DeleteVolumeInfo helps delete mapping of volumePath to VolumeID for specified volumeID
	DeleteVolumeInfo(ctx context.Context, volumeID string) error
}

MockVolumeMigrationService is a mocked VolumeMigrationService needed for CSI migration feature

func GetFakeVolumeMigrationService

func GetFakeVolumeMigrationService(
	ctx context.Context,
	volumeManager *cnsvolume.Manager,
	cnsConfig *cnsconfig.Config,
) (MockVolumeMigrationService, error)

GetFakeVolumeMigrationService returns the mocked VolumeMigrationService

Jump to

Keyboard shortcuts

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