utils

package
v1.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// FakePVName name of PV
	FakePVName = "fake-pv"
	// FakePVCName name of PVC
	FakePVCName = "fake-pvc"
	// FakeSCName name of SC
	FakeSCName = "fake-sc"
	// FakeDriverName name of driver
	FakeDriverName = "fake-csi-driver"
	// FakeRemoteSCName name of remote SC
	FakeRemoteSCName = "fake-remote-sc"
	// FakeRGName name of remote RG
	FakeRGName = "fake-rg"
	// FakeNamespaceName name of namespace
	FakeNamespaceName = "fake-namespace"
	// Self this cluster
	Self = "self"
	// RemoteClusterID id remote cluster
	RemoteClusterID = "remoteCluster"
	// SourceClusterID id source cluster
	SourceClusterID = "sourceCluster"
	// LocalPGID id of local protection group
	LocalPGID = "l-group-id"
	// RemotePGID id of remote protection group
	RemotePGID = "r-group-id"
	// ContextPrefix fake csi replication prefix
	ContextPrefix = "csi-fake"
)
View Source
const PVCName = "test-pvc"

PVCName name of testing PVC

Variables

View Source
var MockServer *grpc.Server

MockServer mock grpc server

View Source
var Scheme = runtime.NewScheme()

Scheme runtime Scheme

Functions

func GetConfigFromFile

func GetConfigFromFile(kubeconfig string) (*rest.Config, error)

GetConfigFromFile creates *rest.Config object from provided config path

func GetFakeClient

func GetFakeClient() client.Client

GetFakeClient returns fake k8s client

func GetFakeClientWithObjects

func GetFakeClientWithObjects(initObjs ...client.Object) client.Client

GetFakeClientWithObjects returns fake k8s client and populates it with given objects

func GetLogger

func GetLogger() logr.Logger

GetLogger returns currently used logger

func GetNonReplicationEnabledSC

func GetNonReplicationEnabledSC(provisionerName, scName string) *storagev1.StorageClass

GetNonReplicationEnabledSC returns usual StorageClass testing object

func GetPVCObj

func GetPVCObj(pvcName string, namespace string, sc string) *v1.PersistentVolumeClaim

GetPVCObj returns PersistentVolumeClaim testing object

func GetPVObj

func GetPVObj(name, volHandle, provisionerName, scName string, volAttributes map[string]string) *v1.PersistentVolume

GetPVObj returns PersistentVolume testing object

func GetParams

func GetParams(remoteClusterID, remoteSCName string) map[string]string

GetParams returns correct map of replication parameters

func GetRGObj

func GetRGObj(name, driverName, remoteClusterID, pgID, remotePGID string, params,
	remoteParams map[string]string,
) *repv1.DellCSIReplicationGroup

GetRGObj returns DellCSIReplicationGroup testing object

func GetReplicationEnabledSC

func GetReplicationEnabledSC(provisionerName, scName, remoteSCName, remoteClusterID string) *storagev1.StorageClass

GetReplicationEnabledSC returns replication enabled StorageClass testing object

func InitializeSchemes

func InitializeSchemes()

InitializeSchemes inits client-go and replication v1 schemes

func RunServer

func RunServer(stubsPath string)

RunServer launches mock grpc server

func StopMockServer

func StopMockServer()

StopMockServer terminates mock grpc server

func ValidateAnnotations

func ValidateAnnotations(annotations map[string]string, t *testing.T)

ValidateAnnotations validates that given annotations are correct

func ValidateRemotePVAnnotations

func ValidateRemotePVAnnotations(annotations map[string]string, t *testing.T)

ValidateRemotePVAnnotations validates that given PV annotations are correct

func ValidateRemoteRGAnnotations

func ValidateRemoteRGAnnotations(annotations map[string]string, t *testing.T)

ValidateRemoteRGAnnotations validates that given RG annotations are correct

func WaitForAllToBeBound

func WaitForAllToBeBound(ctx context.Context, k8sClient client.Client, t *testing.T) error

WaitForAllToBeBound waits for every PVC, that belongs to PVCClient, to be Bound

Types

type Common

type Common struct {
	Namespace string
}

Common contains common resources

type Driver

type Driver struct {
	DriverName      string
	StorageClass    string
	RemoteClusterID string
	RemoteSCName    string
	SourceClusterID string
	Namespace       string
	RGName          string
	PVName          string
}

Driver mock implementation of the driver

func GetDefaultDriver

func GetDefaultDriver() Driver

GetDefaultDriver returns default mock implementation of the driver

type MockUtils

type MockUtils struct {
	FakeClient           *fakeclient.Client
	Specs                Common
	FakeControllerClient client.Client
}

MockUtils contains utils for mocking calls

Jump to

Keyboard shortcuts

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