Documentation ¶
Overview ¶
Package mocks contains mock implementation of CSI methods for test purposes
Index ¶
- Variables
- type ACOperationsMock
- func (a *ACOperationsMock) DeleteIfEmpty(ctx context.Context, acLocation string) error
- func (a *ACOperationsMock) RecreateACToLVGSC(ctx context.Context, sc string, acs ...accrd.AvailableCapacity) *accrd.AvailableCapacity
- func (a *ACOperationsMock) SearchAC(ctx context.Context, node string, requiredBytes int64, sc string) *accrd.AvailableCapacity
- type CRHelper
- func (_m *CRHelper) DeleteACsByNodeID(nodeID string) error
- func (_m *CRHelper) DeleteObjectByName(ctx context.Context, name string, namespace string, obj client.Object) error
- func (_m *CRHelper) GetACByLocation(location string) (*accrd.AvailableCapacity, error)
- func (_m *CRHelper) GetACCRs(node ...string) ([]accrd.AvailableCapacity, error)
- func (_m *CRHelper) GetDriveCRAndLVGCRByVolume(volume *volumecrd.Volume) (*drivecrd.Drive, *lvgcrd.LogicalVolumeGroup, error)
- func (_m *CRHelper) GetDriveCRByVolume(volume *volumecrd.Volume) (*drivecrd.Drive, error)
- func (_m *CRHelper) GetDriveCRs(node ...string) ([]drivecrd.Drive, error)
- func (_m *CRHelper) GetLVGByDrive(ctx context.Context, driveUUID string) (*lvgcrd.LogicalVolumeGroup, error)
- func (_m *CRHelper) GetLVGCRs(node ...string) ([]lvgcrd.LogicalVolumeGroup, error)
- func (_m *CRHelper) GetVGNameByLVGCRName(lvgCRName string) (string, error)
- func (_m *CRHelper) GetVolumeByID(volID string) (*volumecrd.Volume, error)
- func (_m *CRHelper) GetVolumeCRs(node ...string) ([]volumecrd.Volume, error)
- func (_m *CRHelper) GetVolumesByLocation(ctx context.Context, location string) ([]*volumecrd.Volume, error)
- func (_m *CRHelper) SetReader(reader k8s.CRReader) k8s.CRHelper
- func (_m *CRHelper) UpdateDrivesStatusOnNode(nodeID string, status string) error
- func (_m *CRHelper) UpdateVolumeCRSpec(volName string, namespace string, newSpec v1api.Volume) error
- func (_m *CRHelper) UpdateVolumeOpStatus(ctx context.Context, volume *volumecrd.Volume, opStatus string) error
- func (_m *CRHelper) UpdateVolumesOpStatusOnNode(nodeID string, opStatus string) error
- type CmdOut
- type EmptyExecutorFail
- type EmptyExecutorSuccess
- type GoMockExecutor
- func (g *GoMockExecutor) OnCommand(cmd string) *mock.Call
- func (g *GoMockExecutor) OnCommandWithAttempts(cmd string, attempts int, timeout time.Duration) *mock.Call
- func (g *GoMockExecutor) RunCmd(cmd interface{}, opts ...command.Options) (string, string, error)
- func (g *GoMockExecutor) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...command.Options) (string, string, error)
- func (g *GoMockExecutor) SetLevel(logrus.Level)
- type K8Client
- func (k *K8Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (k *K8Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (k *K8Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (k *K8Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (k *K8Client) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)
- func (k *K8Client) IsObjectNamespaced(obj runtime.Object) (bool, error)
- func (k *K8Client) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (k *K8Client) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (k *K8Client) RESTMapper() meta.RESTMapper
- func (k *K8Client) Scheme() *runtime.Scheme
- func (k *K8Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type MockCache
- func (c *MockCache) Get(ctx context.Context, key types.NamespacedName, obj client.Object, ...) error
- func (c *MockCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
- func (c *MockCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- type MockDriveMgrClient
- func (m *MockDriveMgrClient) AddDrives(drives ...*api.Drive)
- func (m *MockDriveMgrClient) GetAllDrivesSmartInfo(ctx context.Context, req *api.Empty, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)
- func (m *MockDriveMgrClient) GetDriveSmartInfo(ctx context.Context, req *api.SmartInfoRequest, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)
- func (m *MockDriveMgrClient) GetDrivesList(ctx context.Context, in *api.DrivesRequest, opts ...grpc.CallOption) (*api.DrivesResponse, error)
- func (m *MockDriveMgrClient) Locate(ctx context.Context, in *api.DriveLocateRequest, opts ...grpc.CallOption) (*api.DriveLocateResponse, error)
- func (m *MockDriveMgrClient) LocateNode(ctx context.Context, in *api.NodeLocateRequest, opts ...grpc.CallOption) (*api.Empty, error)
- func (m *MockDriveMgrClient) SetDrives(drives []*api.Drive)
- type MockDriveMgrClientFail
- func (m *MockDriveMgrClientFail) GetAllDrivesSmartInfo(ctx context.Context, req *api.Empty, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)
- func (m *MockDriveMgrClientFail) GetDriveSmartInfo(ctx context.Context, req *api.SmartInfoRequest, opts ...grpc.CallOption) (*api.SmartInfoResponse, error)
- func (m *MockDriveMgrClientFail) GetDrivesList(ctx context.Context, in *api.DrivesRequest, opts ...grpc.CallOption) (*api.DrivesResponse, error)
- func (m *MockDriveMgrClientFail) Locate(ctx context.Context, in *api.DriveLocateRequest, opts ...grpc.CallOption) (*api.DriveLocateResponse, error)
- func (m *MockDriveMgrClientFail) LocateNode(ctx context.Context, in *api.NodeLocateRequest, opts ...grpc.CallOption) (*api.Empty, error)
- type MockExecutor
- func (e *MockExecutor) AddSecondRun(cmd string, res CmdOut)
- func (e *MockExecutor) GetMap() map[string]CmdOut
- func (e *MockExecutor) RunCmd(cmd interface{}, opts ...command.Options) (string, string, error)
- func (e *MockExecutor) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...command.Options) (string, string, error)
- func (*MockExecutor) SetLevel(logrus.Level)
- func (e *MockExecutor) SetMap(m map[string]CmdOut)
- func (e *MockExecutor) SetSuccessIfNotFound(val bool)
- type MockManager
- func (m *MockManager) Add(manager.Runnable) error
- func (m *MockManager) GetCache() cache.Cache
- func (m *MockManager) GetClient() client.Client
- func (m *MockManager) GetConfig() *rest.Config
- func (m *MockManager) GetControllerOptions() config.Controller
- func (m *MockManager) GetFieldIndexer() client.FieldIndexer
- func (m *MockManager) GetLogger() logr.Logger
- func (m *MockManager) GetRESTMapper() meta.RESTMapper
- func (m *MockManager) GetScheme() *runtime.Scheme
- type NoOpRecorder
- type SmartInfo
- type VolumeOperationsMock
- func (vo *VolumeOperationsMock) CreateVolume(ctx context.Context, v api.Volume) (*api.Volume, error)
- func (vo *VolumeOperationsMock) DeleteVolume(ctx context.Context, volumeID string) error
- func (vo *VolumeOperationsMock) ExpandVolume(ctx context.Context, volume *volumecrd.Volume, requiredBytes int64) error
- func (vo *VolumeOperationsMock) UpdateCRsAfterVolumeDeletion(ctx context.Context, volumeID string) error
- func (vo *VolumeOperationsMock) UpdateCRsAfterVolumeExpansion(ctx context.Context, volID string, requiredBytes int64)
- func (vo *VolumeOperationsMock) WaitStatus(ctx context.Context, volumeID string, statuses ...string) error
Constants ¶
This section is empty.
Variables ¶
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} ] }` )
var ( RunCmd = "RunCmd" RunCmdWithAttempts = "RunCmdWithAttempts" )
RunCmd is the name of CmdExecutor method name
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
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
var EmptyOutFail = CmdOut{ Stdout: "", Stderr: "", Err: Err, }
EmptyOutFail var of type CmdOut for test purposes
var EmptyOutSuccess = CmdOut{ Stdout: "", Stderr: "", Err: nil, }
EmptyOutSuccess var of type CmdOut for test purposes
var Err = errors.New("error")
Err var of type error for test purposes
var LsblkDevV2 = `` /* 317-byte string literal not displayed */
LsblkDevV2 provides output for new lsblk version
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
var LsblkListPartitionsStr = `` /* 185-byte string literal not displayed */
LsblkListPartitionsStr imitates lsblk output with block device that has partition
var LsblkTwoDevicesStr = `` /* 175-byte string literal not displayed */
LsblkTwoDevicesStr imitates lsblk output with two block devices
var NoLsblkKeyStr = `{"anotherKey": [{"name": "/dev/sda", "type": "disk"}]}`
NoLsblkKeyStr imitates lsblk output without normal key
Functions ¶
This section is empty.
Types ¶
type ACOperationsMock ¶
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
CRHelper is an autogenerated mock type for the CRHelper type
func (*CRHelper) DeleteACsByNodeID ¶ added in v1.3.0
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
GetDriveCRByVolume provides a mock function with given fields: volume
func (*CRHelper) GetDriveCRs ¶ added in v1.3.0
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
GetVGNameByLVGCRName provides a mock function with given fields: lvgCRName
func (*CRHelper) GetVolumeByID ¶ added in v1.3.0
GetVolumeByID provides a mock function with given fields: volID
func (*CRHelper) GetVolumeCRs ¶ added in v1.3.0
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
SetReader provides a mock function with given fields: reader
func (*CRHelper) UpdateDrivesStatusOnNode ¶ added in v1.3.0
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
type EmptyExecutorFail ¶
type EmptyExecutorFail struct { }
EmptyExecutorFail implements CmdExecutor interface for test purposes, each command will finish with error
func (EmptyExecutorFail) RunCmd ¶
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 ¶
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 ¶
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 ¶
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 ¶
type K8Client struct { client.Reader client.Writer client.StatusClient client.SubResourceClientConstructor mock.Mock }
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
GroupVersionKindFor is mock implementation of GroupVersionKindFor method from client.Client interface
func (*K8Client) IsObjectNamespaced ¶ added in v1.7.0
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
type MockCache ¶ added in v1.7.0
MockCache is a mock implementation of cache.Cache interface from controller-runtime
func (*MockCache) Get ¶ added in v1.7.0
func (c *MockCache) Get(ctx context.Context, key types.NamespacedName, obj client.Object, opts ...client.GetOption) error
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 ¶
func (m *MockDriveMgrClient) Locate(ctx context.Context, in *api.DriveLocateRequest, opts ...grpc.CallOption) (*api.DriveLocateResponse, error)
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 ¶
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 ¶
func (m *MockDriveMgrClientFail) GetDrivesList(ctx context.Context, in *api.DrivesRequest, opts ...grpc.CallOption) (*api.DrivesResponse, error)
GetDrivesList is the simulation of failure during DriveManager's GetDrivesList Returns nil DrivesResponse and non nil error
func (*MockDriveMgrClientFail) Locate ¶
func (m *MockDriveMgrClientFail) Locate(ctx context.Context, in *api.DriveLocateRequest, opts ...grpc.CallOption) (*api.DriveLocateResponse, error)
Locate is a stub for Locate DriveManager's method
func (*MockDriveMgrClientFail) LocateNode ¶
func (m *MockDriveMgrClientFail) LocateNode(ctx context.Context, in *api.NodeLocateRequest, opts ...grpc.CallOption) (*api.Empty, error)
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 ¶
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
MockManager is a mock implementation of manager.Manager interface from controller-runtime
func (*MockManager) Add ¶ added in v1.7.0
func (m *MockManager) Add(manager.Runnable) error
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 VolumeOperationsMock ¶
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