mocks

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package mocks contains mock implementation of CSI methods for test purposes

Index

Constants

This section is empty.

Variables

View Source
var (
	// HDDBlockDeviceName contains name of HDD device
	HDDBlockDeviceName = "/dev/sdb"
	// LsblkAllV2 provides output for new lsblk version with children
	LsblkAllV2 = `{
   		"blockdevices": [
      		{"name":"` + HDDBlockDeviceName + `", "type":"disk", "size":480103981056, "rota":false, "serial":"PHYH937100WD480K",
"wwn":"0x55cd2e415119aed8", "vendor":"ATA     ", "model":"SSDSCKKB480G8R", "rev":"DL6N", "mountpoint":null, "fstype":null, "partuuid":null,
         		"children": [            
            		{"name":"/dev/sdc", "type":"part", "size":479563087872, "rota":false, "serial":null, "wwn":"0x55cd2e415119aed8",
"vendor":null, "model":null, "rev":null, "mountpoint":null, "fstype":"LVM2_member", "partuuid":"40b8a8aa-54fc-4725-9599-91f55a309c83",
               		"children": [
                		  {"name":"/dev/mapper/root--vg-lv_root", "type":"lvm", "size":53687091200, "rota":false, "serial":null, 
"wwn":null, "vendor":null, "model":null, "rev":null, "mountpoint":null, "fstype":"ext4", "partuuid":null}                  
               		]
            		}
        	 	]
      		},
    	  	{"name":"/dev/sdc", "type":"disk", "size":8001563222016, "rota":true, "serial":"5000cca0bbcea5c7", "wwn":"0x5000cca0bbcea5c7",
"vendor":"ATA     ", "model":"HGST_HUS728T8TAL", "rev":"RT04", "mountpoint":null, "fstype":null, "partuuid":null}
   			]
		}`
)
View Source
var (
	RunCmd             = "RunCmd"
	RunCmdWithAttempts = "RunCmdWithAttempts"
)

RunCmd is the name of CmdExecutor method name

View Source
var DiskCommands = map[string]CmdOut{
	"partprobe -d -s /dev/sda": {
		Stdout: "(no output)",
		Stderr: "",
		Err:    nil,
	},
	"partprobe -d -s /dev/sdb": {
		Stdout: "/dev/sda: msdos partitions 1",
		Stderr: "",
		Err:    nil,
	},
	"partprobe -d -s /dev/sdc": {
		Stdout: "/dev/sda: msdos partitions",
		Stderr: "",
		Err:    nil,
	},
	"partprobe -d -s /dev/sdd": {
		Stdout: "",
		Stderr: "",
		Err:    errors.New("unable to check partition existence for /dev/sdd"),
	},
	"partprobe -d -s /dev/sde":        EmptyOutSuccess,
	"blockdev --rereadpt -v /dev/sde": EmptyOutSuccess,
	"partprobe -d -s /dev/sdqwe": {
		Stdout: "",
		Stderr: "",
		Err:    errors.New("unable to get partition table"),
	},
	"sgdisk /dev/sda -o": EmptyOutSuccess,
	"sgdisk /dev/sdc -o": EmptyOutSuccess,
	"sgdisk -d 1 /dev/sda": {
		Stdout: "The operation has completed successfully.",
		Stderr: "",
		Err:    nil,
	},
	"sgdisk -n 1:0:0 -c 1:CSI -u 1:64be631b-62a5-11e9-a756-00505680d67f /dev/sde": {
		Stdout: `Creating new GPT entries.
Setting name!
partNum is 0
The operation has completed successfully`,
		Stderr: "",
		Err:    nil,
	},
	"sgdisk -n 1:0:0 -c 1:CSI /dev/sde": {
		Stdout: `Creating new GPT entries.
Setting name!
partNum is 0
The operation has completed successfully`,
		Stderr: "",
		Err:    nil,
	},
	"sgdisk /dev/sda --info=1": {
		Stdout: `Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 64BE631B-62A5-11E9-A756-00505680D67F
First sector: 2048 (at 1024.0 KiB)
Last sector: 1953523711 (at 931.5 GiB)
Partition size: 1953521664 sectors (931.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'CSI'`,
		Stderr: "",
		Err:    nil,
	},
	"sgdisk /dev/sdb --info=1": {
		Stdout: `Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition: 64BE631B-62A5-11E9-A756-00505680D67F
First sector: 2048 (at 1024.0 KiB)
Last sector: 1953523711 (at 931.5 GiB)
Partition size: 1953521664 sectors (931.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'CSI'`,
		Stderr: "",
		Err:    nil,
	},
	"sgdisk /dev/sdc --info=1": EmptyOutFail,
}

DiskCommands is the map that contains Linux commands output

View Source
var DriveMgrRespDrives = []*api.Drive{
	{
		SerialNumber: "hdd1",
		Health:       apiV1.HealthGood,
		Type:         apiV1.DriveTypeHDD,
		Size:         1024 * 1024 * 1024 * 50,
	},
	{
		SerialNumber: "hdd2",
		Health:       apiV1.HealthGood,
		Type:         apiV1.DriveTypeHDD,
		Size:         1024 * 1024 * 1024 * 150,
	},
}

DriveMgrRespDrives are the drives for mock GetAllDrives call of DriveManager

View Source
var EmptyOutFail = CmdOut{
	Stdout: "",
	Stderr: "",
	Err:    Err,
}

EmptyOutFail var of type CmdOut for test purposes

View Source
var EmptyOutSuccess = CmdOut{
	Stdout: "",
	Stderr: "",
	Err:    nil,
}

EmptyOutSuccess var of type CmdOut for test purposes

View Source
var Err = errors.New("error")

Err var of type error for test purposes

View Source
var LsblkDevV2 = `` /* 317-byte string literal not displayed */

LsblkDevV2 provides output for new lsblk version

View Source
var LsblkDevWithChildren = CmdOut{
	Stdout: `{
			  "blockdevices":[{
				"name": "/dev/sdb",
				"type": "disk",
				"serial": "hdd2",
				"children": [{"name": "/dev/children1", "mountpoint":""}, 
							 {"name": "/dev/children2", "mountpoint":"/var/lib/kubelet/pods/27cc6e45-61f1-11e9-b966-001e67e6854b/volumes/kubernetes.io~csi/pvc-27cbea1b-61f1-11e9-b966-001e67e6854b/mount"}],
				"size": "213674622976"
				}]
			}`,
	Stderr: "",
	Err:    nil}

LsblkDevWithChildren imitates lsblk output with two block devices with children

View Source
var LsblkListPartitionsStr = `` /* 185-byte string literal not displayed */

LsblkListPartitionsStr imitates lsblk output with block device that has partition

View Source
var LsblkTwoDevicesStr = `` /* 175-byte string literal not displayed */

LsblkTwoDevicesStr imitates lsblk output with two block devices

View Source
var NoLsblkKeyStr = `{"anotherKey": [{"name": "/dev/sda", "type": "disk"}]}`

NoLsblkKeyStr imitates lsblk output without normal key

Functions

This section is empty.

Types

type ACOperationsMock

type ACOperationsMock struct {
	mock.Mock
}

ACOperationsMock is the mock implementation of AvailableCapacityOperations interface for test purposes

func (*ACOperationsMock) DeleteIfEmpty

func (a *ACOperationsMock) DeleteIfEmpty(ctx context.Context, acLocation string) error

DeleteIfEmpty is the mock implementation of DeleteIfEmpty method from AvailableCapacityOperations made for simulating deletion of empty AvailableCapacity which Location is acLocation. Returns error if user simulates error in tests or nil

func (*ACOperationsMock) RecreateACToLVGSC

func (a *ACOperationsMock) RecreateACToLVGSC(ctx context.Context, sc string, acs ...accrd.AvailableCapacity) *accrd.AvailableCapacity

RecreateACToLVGSC is the mock implementation of RecreateACToLVGSC method from AvailableCapacityOperations made for simulating recreation of list of ACs to LVG AC Returns error if user simulates error in tests or nil

func (*ACOperationsMock) SearchAC

func (a *ACOperationsMock) SearchAC(ctx context.Context, node string, requiredBytes int64, sc string) *accrd.AvailableCapacity

SearchAC is the mock implementation of SearchAC method from AvailableCapacityOperations made for simulating searching AvailableCapacity on a cluster. Returns a fake AvailableCapacity instance

type CRHelper added in v1.3.0

type CRHelper struct {
	mock.Mock
}

CRHelper is an autogenerated mock type for the CRHelper type

func (*CRHelper) DeleteACsByNodeID added in v1.3.0

func (_m *CRHelper) DeleteACsByNodeID(nodeID string) error

DeleteACsByNodeID provides a mock function with given fields: nodeID

func (*CRHelper) DeleteObjectByName added in v1.3.0

func (_m *CRHelper) DeleteObjectByName(ctx context.Context, name string, namespace string, obj client.Object) error

DeleteObjectByName provides a mock function with given fields: ctx, name, namespace, obj

func (*CRHelper) GetACByLocation added in v1.3.0

func (_m *CRHelper) GetACByLocation(location string) (*accrd.AvailableCapacity, error)

GetACByLocation provides a mock function with given fields: location

func (*CRHelper) GetACCRs added in v1.3.0

func (_m *CRHelper) GetACCRs(node ...string) ([]accrd.AvailableCapacity, error)

GetACCRs provides a mock function with given fields: node

func (*CRHelper) GetDriveCRAndLVGCRByVolume added in v1.3.0

func (_m *CRHelper) GetDriveCRAndLVGCRByVolume(volume *volumecrd.Volume) (*drivecrd.Drive, *lvgcrd.LogicalVolumeGroup, error)

GetDriveCRAndLVGCRByVolume provides a mock function with given fields: volume

func (*CRHelper) GetDriveCRByVolume added in v1.3.0

func (_m *CRHelper) GetDriveCRByVolume(volume *volumecrd.Volume) (*drivecrd.Drive, error)

GetDriveCRByVolume provides a mock function with given fields: volume

func (*CRHelper) GetDriveCRs added in v1.3.0

func (_m *CRHelper) GetDriveCRs(node ...string) ([]drivecrd.Drive, error)

GetDriveCRs provides a mock function with given fields: node

func (*CRHelper) GetLVGByDrive added in v1.3.0

func (_m *CRHelper) GetLVGByDrive(ctx context.Context, driveUUID string) (*lvgcrd.LogicalVolumeGroup, error)

GetLVGByDrive provides a mock function with given fields: ctx, driveUUID

func (*CRHelper) GetLVGCRs added in v1.3.0

func (_m *CRHelper) GetLVGCRs(node ...string) ([]lvgcrd.LogicalVolumeGroup, error)

GetLVGCRs provides a mock function with given fields: node

func (*CRHelper) GetVGNameByLVGCRName added in v1.3.0

func (_m *CRHelper) GetVGNameByLVGCRName(lvgCRName string) (string, error)

GetVGNameByLVGCRName provides a mock function with given fields: lvgCRName

func (*CRHelper) GetVolumeByID added in v1.3.0

func (_m *CRHelper) GetVolumeByID(volID string) (*volumecrd.Volume, error)

GetVolumeByID provides a mock function with given fields: volID

func (*CRHelper) GetVolumeCRs added in v1.3.0

func (_m *CRHelper) GetVolumeCRs(node ...string) ([]volumecrd.Volume, error)

GetVolumeCRs provides a mock function with given fields: node

func (*CRHelper) GetVolumesByLocation added in v1.3.0

func (_m *CRHelper) GetVolumesByLocation(ctx context.Context, location string) ([]*volumecrd.Volume, error)

GetVolumesByLocation provides a mock function with given fields: ctx, location

func (*CRHelper) SetReader added in v1.3.0

func (_m *CRHelper) SetReader(reader k8s.CRReader) k8s.CRHelper

SetReader provides a mock function with given fields: reader

func (*CRHelper) UpdateDrivesStatusOnNode added in v1.3.0

func (_m *CRHelper) UpdateDrivesStatusOnNode(nodeID string, status string) error

UpdateDrivesStatusOnNode provides a mock function with given fields: nodeID, status

func (*CRHelper) UpdateVolumeCRSpec added in v1.3.0

func (_m *CRHelper) UpdateVolumeCRSpec(volName string, namespace string, newSpec v1api.Volume) error

UpdateVolumeCRSpec provides a mock function with given fields: volName, namespace, newSpec

func (*CRHelper) UpdateVolumeOpStatus added in v1.3.0

func (_m *CRHelper) UpdateVolumeOpStatus(ctx context.Context, volume *volumecrd.Volume, opStatus string) error

UpdateVolumeOpStatus provides a mock function with given fields: ctx, volume, opStatus

func (*CRHelper) UpdateVolumesOpStatusOnNode added in v1.3.0

func (_m *CRHelper) UpdateVolumesOpStatusOnNode(nodeID string, opStatus string) error

UpdateVolumesOpStatusOnNode provides a mock function with given fields: nodeID, opStatus

type CmdOut

type CmdOut struct {
	Stdout string
	Stderr string
	Err    error
}

CmdOut is the struct for command output

type EmptyExecutorFail

type EmptyExecutorFail struct {
}

EmptyExecutorFail implements CmdExecutor interface for test purposes, each command will finish with error

func (EmptyExecutorFail) RunCmd

func (e EmptyExecutorFail) RunCmd(interface{}, ...command.Options) (string, string, error)

RunCmd simulates failed execution of a command Returns "error happened" as stdout, "error" as stderr and errors.New("error") as error

func (EmptyExecutorFail) RunCmdWithAttempts

func (e EmptyExecutorFail) RunCmdWithAttempts(interface{}, int, time.Duration, ...command.Options) (string, string, error)

RunCmdWithAttempts simulates failed execution of a command with attempts and given timeout between attempts Returns "error happened" as stdout, "error" as stderr and errors.New("error") as error

func (EmptyExecutorFail) SetLevel added in v1.3.0

func (EmptyExecutorFail) SetLevel(logrus.Level)

SetLevel implements EmptyExecutorFail interface for test purposes

type EmptyExecutorSuccess

type EmptyExecutorSuccess struct {
}

EmptyExecutorSuccess implements CmdExecutor interface for test purposes, each command will finish success

func (EmptyExecutorSuccess) RunCmd

func (e EmptyExecutorSuccess) RunCmd(interface{}, ...command.Options) (string, string, error)

RunCmd simulates successful execution of a command Returns "" as stdout, "" as stderr and nil as error

func (EmptyExecutorSuccess) RunCmdWithAttempts

func (e EmptyExecutorSuccess) RunCmdWithAttempts(interface{}, int, time.Duration, ...command.Options) (string, string, error)

RunCmdWithAttempts simulates successful execution of a command with attempts and given timeout between attempts Returns "" as stdout, "" as stderr and nil as error

func (EmptyExecutorSuccess) SetLevel added in v1.3.0

func (EmptyExecutorSuccess) SetLevel(logrus.Level)

SetLevel implements EmptyExecutorSuccess interface for test purposes

type GoMockExecutor

type GoMockExecutor struct {
	mock.Mock
}

GoMockExecutor implements CmdExecutor based on stretchr/testify/mock

func (*GoMockExecutor) OnCommand

func (g *GoMockExecutor) OnCommand(cmd string) *mock.Call

OnCommand is the method of mock.Mock where user can set what to return on specified command For example e.OnCommand("/sbin/lvm pvcreate --yes /dev/sda").Return("", "", errors.New("pvcreate failed")) Returns mock.Call where need to set what to return with Return() method

func (*GoMockExecutor) OnCommandWithAttempts

func (g *GoMockExecutor) OnCommandWithAttempts(cmd string, attempts int, timeout time.Duration) *mock.Call

OnCommandWithAttempts is the method of mock.Mock where user can set what to return on specified command For example e.OnCommandWithAttempts("/sbin/lvm pvcreate --yes /dev/sda", 5, time.Second).Return("", "", errors.New("pvcreate failed")) Returns mock.Call where need to set what to return with Return() method

func (*GoMockExecutor) RunCmd

func (g *GoMockExecutor) RunCmd(cmd interface{}, opts ...command.Options) (string, string, error)

RunCmd simulates execution of a command with OnCommand where user can set what the method should return

func (*GoMockExecutor) RunCmdWithAttempts

func (g *GoMockExecutor) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...command.Options) (string, string, error)

RunCmdWithAttempts simulates execution of a command with OnCommandWithAttempts where user can set what the method should return

func (*GoMockExecutor) SetLevel added in v1.3.0

func (g *GoMockExecutor) SetLevel(logrus.Level)

SetLevel implements GoMockExecutor interface for test purposes

type K8Client

K8Client is a mock implementation of client.Client interface from controller-runtime

func (*K8Client) Create

func (k *K8Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

Create is mock implementation of Create method from client.Writer interface

func (*K8Client) Delete

func (k *K8Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

Delete is mock implementation of Delete method from client.Writer interface

func (*K8Client) DeleteAllOf

func (k *K8Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

DeleteAllOf is mock implementation of DeleteAllOf method from client.Writer interface

func (*K8Client) Get

func (k *K8Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opt ...client.GetOption) error

Get is mock implementation of Get method from client.Reader interface

func (*K8Client) GroupVersionKindFor added in v1.7.0

func (k *K8Client) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)

GroupVersionKindFor is mock implementation of GroupVersionKindFor method from client.Client interface

func (*K8Client) IsObjectNamespaced added in v1.7.0

func (k *K8Client) IsObjectNamespaced(obj runtime.Object) (bool, error)

IsObjectNamespaced is mock implementation of IsObjectNamespaced method from client.Client interface

func (*K8Client) List

func (k *K8Client) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

List is mock implementation of List method from client.Reader interface

func (*K8Client) Patch

func (k *K8Client) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

Patch is mock implementation of Patch method from client.Writer interface

func (*K8Client) RESTMapper added in v1.3.0

func (k *K8Client) RESTMapper() meta.RESTMapper

RESTMapper is mock implementation of DeleteAllOf method from client.Writer interface

func (*K8Client) Scheme added in v1.3.0

func (k *K8Client) Scheme() *runtime.Scheme

Scheme is mock implementation of DeleteAllOf method from client.Writer interface

func (*K8Client) Update

func (k *K8Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

Update is mock implementation of Update method from client.Writer interface

type MockCache added in v1.7.0

type MockCache struct {
	client.Reader
	cache.Informers
	mock.Mock
}

MockCache is a mock implementation of cache.Cache interface from controller-runtime

func (*MockCache) Get added in v1.7.0

Get is mock implementation of Get method from cache.Cache interface

func (*MockCache) GetInformer added in v1.7.0

func (c *MockCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)

GetInformer is mock implementation of GetInformer method from cache.Cache interface

func (*MockCache) List added in v1.7.0

func (c *MockCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

List is mock implementation of List method from cache.Cache interface

type MockDriveMgrClient

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

MockDriveMgrClient is the implementation of DriveManager interface to imitate success state

func NewMockDriveMgrClient

func NewMockDriveMgrClient(drives []*api.Drive, smartInfo SmartInfo) *MockDriveMgrClient

NewMockDriveMgrClient returns new instance of MockDriveMgrClient Receives slice of api.Drive which would be used in imitation of GetDrivesList

func (*MockDriveMgrClient) AddDrives

func (m *MockDriveMgrClient) AddDrives(drives ...*api.Drive)

AddDrives extends drives slice

func (*MockDriveMgrClient) GetAllDrivesSmartInfo added in v1.6.1

func (m *MockDriveMgrClient) GetAllDrivesSmartInfo(ctx context.Context, req *api.Empty, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)

GetAllDrivesSmartInfo is a stub for GetAllDrivesSmartInfo DriveManager's method

func (*MockDriveMgrClient) GetDriveSmartInfo added in v1.6.1

func (m *MockDriveMgrClient) GetDriveSmartInfo(ctx context.Context, req *api.SmartInfoRequest, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)

GetDriveSmartInfo is a stub for GetDriveSmartInfo DriveManager's method

func (*MockDriveMgrClient) GetDrivesList

func (m *MockDriveMgrClient) GetDrivesList(ctx context.Context, in *api.DrivesRequest, opts ...grpc.CallOption) (*api.DrivesResponse, error)

GetDrivesList returns provided to MockDriveMgrClient drives to imitate working of DriveManager

func (*MockDriveMgrClient) Locate

Locate is a stub for Locate DriveManager's method

func (*MockDriveMgrClient) LocateNode

func (m *MockDriveMgrClient) LocateNode(ctx context.Context, in *api.NodeLocateRequest, opts ...grpc.CallOption) (*api.Empty, error)

LocateNode is a stub for LocateNode DriveManager's method

func (*MockDriveMgrClient) SetDrives

func (m *MockDriveMgrClient) SetDrives(drives []*api.Drive)

SetDrives set drives for current MockDriveMgrClient instance

type MockDriveMgrClientFail

type MockDriveMgrClientFail struct {
	Code codes.Code
}

MockDriveMgrClientFail is the implementation of DriveManager interface to imitate failure state

func (*MockDriveMgrClientFail) GetAllDrivesSmartInfo added in v1.6.1

func (m *MockDriveMgrClientFail) GetAllDrivesSmartInfo(ctx context.Context, req *api.Empty, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)

GetAllDrivesSmartInfo is a stub for GetAllDrivesSmartInfo DriveManager's method

func (*MockDriveMgrClientFail) GetDriveSmartInfo added in v1.6.1

func (m *MockDriveMgrClientFail) GetDriveSmartInfo(ctx context.Context, req *api.SmartInfoRequest, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)

GetDriveSmartInfo is a stub for GetDriveSmartInfo DriveManager's method

func (*MockDriveMgrClientFail) GetDrivesList

GetDrivesList is the simulation of failure during DriveManager's GetDrivesList Returns nil DrivesResponse and non nil error

func (*MockDriveMgrClientFail) Locate

Locate is a stub for Locate DriveManager's method

func (*MockDriveMgrClientFail) LocateNode

LocateNode is a stub for LocateNode DriveManager's method

type MockExecutor

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

MockExecutor implements CmdExecutor interface, each command will return appropriate key from cmdMap map there is ability to return different value for same command if it runs twice, for it add this command and result (that expected on second run) in SecondRun map when cmd runs first result gets from cmdMap, when cmd runs second time and so on results is searching (at first) in SecondRun map

func NewMockExecutor

func NewMockExecutor(m map[string]CmdOut) *MockExecutor

NewMockExecutor is the constructor for MockExecutor struct Receives map which contains commands as keys and their outputs as values Returns an instance of MockExecutor

func (*MockExecutor) AddSecondRun

func (e *MockExecutor) AddSecondRun(cmd string, res CmdOut)

AddSecondRun adds command output - res for command - cmd for the second execution

func (*MockExecutor) GetMap

func (e *MockExecutor) GetMap() map[string]CmdOut

GetMap returns command map from MockExecutor

func (*MockExecutor) RunCmd

func (e *MockExecutor) RunCmd(cmd interface{}, opts ...command.Options) (string, string, error)

RunCmd simulates execution of a command. If a command is in cmdMap then return value as an output for it. If the command ran before then trying to return output from secondRun map if it set. Receives cmd as interface and cast it to a string Returns stdout, stderr, error for a given command

func (*MockExecutor) RunCmdWithAttempts

func (e *MockExecutor) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...command.Options) (string, string, error)

RunCmdWithAttempts simulates execution of a command. Execute RunCmd. Receives cmd as interface, number of attempts, timeout Returns stdout, stderr, error for a given command

func (*MockExecutor) SetLevel added in v1.3.0

func (*MockExecutor) SetLevel(logrus.Level)

SetLevel implements MockExecutor interface for test purposes

func (*MockExecutor) SetMap

func (e *MockExecutor) SetMap(m map[string]CmdOut)

SetMap sets map which contains commands as keys and their outputs as values to the MockExecutor

func (*MockExecutor) SetSuccessIfNotFound

func (e *MockExecutor) SetSuccessIfNotFound(val bool)

SetSuccessIfNotFound sets MockExecutor mode when it returns success output even if a command wasn't found in map

type MockManager added in v1.7.0

type MockManager struct {
	ctrl.Manager
	mock.Mock
}

MockManager is a mock implementation of manager.Manager interface from controller-runtime

func (*MockManager) Add added in v1.7.0

Add is mock implementation of Add method from manager.Manager interface

func (*MockManager) GetCache added in v1.7.0

func (m *MockManager) GetCache() cache.Cache

GetCache is mock implementation of GetCache method from cluster.Cluster interface

func (*MockManager) GetClient added in v1.7.0

func (m *MockManager) GetClient() client.Client

GetClient is mock implementation of GetClient method from cluster.Cluster interface

func (*MockManager) GetConfig added in v1.7.0

func (m *MockManager) GetConfig() *rest.Config

GetConfig is mock implementation of GetConfig method from cluster.Cluster interface

func (*MockManager) GetControllerOptions added in v1.7.0

func (m *MockManager) GetControllerOptions() config.Controller

GetControllerOptions is mock implementation of GetControllerOptions method from manager.Manager interface

func (*MockManager) GetFieldIndexer added in v1.7.0

func (m *MockManager) GetFieldIndexer() client.FieldIndexer

GetFieldIndexer is mock implementation of GetFieldIndexer method from cluster.Cluster interface

func (*MockManager) GetLogger added in v1.7.0

func (m *MockManager) GetLogger() logr.Logger

GetLogger is mock implementation of GetLogger method from manager.Manager interface

func (*MockManager) GetRESTMapper added in v1.7.0

func (m *MockManager) GetRESTMapper() meta.RESTMapper

GetRESTMapper is mock implementation of GetRESTMapper method from cluster.Cluster interface

func (*MockManager) GetScheme added in v1.7.0

func (m *MockManager) GetScheme() *runtime.Scheme

GetScheme is mock implementation of GetScheme method from cluster.Cluster interface

type NoOpRecorder

type NoOpRecorder struct {
	Calls []eventRecorderCalls
	// contains filtered or unexported fields
}

NoOpRecorder is blank implementation of event recorder interface which stores calls to the interface methods

func (*NoOpRecorder) Eventf

func (n *NoOpRecorder) Eventf(object runtime.Object, event *eventing.EventDescription, messageFmt string, args ...interface{})

Eventf do nothing

type SmartInfo added in v1.6.1

type SmartInfo map[string]map[string]map[string]string

SmartInfo is a structure to represent basic Smart metrics

type VolumeOperationsMock

type VolumeOperationsMock struct {
	mock.Mock
}

VolumeOperationsMock is the mock implementation of VolumeOperations interface for test purposes. All of the mock methods based on stretchr/testify/mock.

func (*VolumeOperationsMock) CreateVolume

func (vo *VolumeOperationsMock) CreateVolume(ctx context.Context, v api.Volume) (*api.Volume, error)

CreateVolume is the mock implementation of CreateVolume method from VolumeOperations made for simulating creating of Volume CR on a cluster. Returns a fake api.Volume instance

func (*VolumeOperationsMock) DeleteVolume

func (vo *VolumeOperationsMock) DeleteVolume(ctx context.Context, volumeID string) error

DeleteVolume is the mock implementation of DeleteVolume method from VolumeOperations made for simulating deletion of Volume CR on a cluster. Returns error if user simulates error in tests or nil

func (*VolumeOperationsMock) ExpandVolume

func (vo *VolumeOperationsMock) ExpandVolume(ctx context.Context, volume *volumecrd.Volume, requiredBytes int64) error

ExpandVolume is the mock implementation of ExpandVolume method from VolumeOperations made for simulating Receive golang context, volume CR, requiredBytes as int Return volume spec, error

func (*VolumeOperationsMock) UpdateCRsAfterVolumeDeletion

func (vo *VolumeOperationsMock) UpdateCRsAfterVolumeDeletion(ctx context.Context, volumeID string) error

UpdateCRsAfterVolumeDeletion is the mock implementation of UpdateCRsAfterVolumeDeletion

func (*VolumeOperationsMock) UpdateCRsAfterVolumeExpansion

func (vo *VolumeOperationsMock) UpdateCRsAfterVolumeExpansion(ctx context.Context, volID string, requiredBytes int64)

UpdateCRsAfterVolumeExpansion is the mock implementation of UpdateCRsAfterVolumeExpansion method from VolumeOperations made for simulating Receive golang context, volume spec Return error

func (*VolumeOperationsMock) WaitStatus

func (vo *VolumeOperationsMock) WaitStatus(ctx context.Context, volumeID string, statuses ...string) error

WaitStatus is the mock implementation of WaitStatus. Simulates waiting of Volume to be reached one of provided statuses

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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