mock

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearMockAdminClients

func ClearMockAdminClients()

ClearMockAdminClients clears the cache of mock Admin clients

func ClearMockLockClients

func ClearMockLockClients()

ClearMockLockClients clears the cache of mock lock clients

func NewMockAdminClient

func NewMockAdminClient(cluster *fdbv1beta2.FoundationDBCluster, kubeClient client.Client) (fdbadminclient.AdminClient, error)

NewMockAdminClient creates an admin client for a cluster.

func NewMockLockClient

func NewMockLockClient(cluster *fdbv1beta2.FoundationDBCluster) (fdbadminclient.LockClient, error)

NewMockLockClient creates a mock lock client.

Types

type AdminClient

type AdminClient struct {
	Cluster               *fdbv1beta2.FoundationDBCluster
	KubeClient            client.Client
	DatabaseConfiguration *fdbv1beta2.DatabaseConfiguration
	ExcludedAddresses     []string
	KilledAddresses       []string
	Knobs                 []string
	FrozenStatus          *fdbv1beta2.FoundationDBStatus
	Backups               map[string]fdbv1beta2.FoundationDBBackupStatusBackupDetails

	ReincludedAddresses map[string]bool

	MaxZoneFailuresWithoutLosingData         *int
	MaxZoneFailuresWithoutLosingAvailability *int
	MaintenanceZone                          string
	// contains filtered or unexported fields
}

AdminClient provides a mock implementation of the cluster admin interface

func NewMockAdminClientUncast

func NewMockAdminClientUncast(cluster *fdbv1beta2.FoundationDBCluster, kubeClient client.Client) (*AdminClient, error)

NewMockAdminClientUncast creates a mock admin client for a cluster. nolint:unparam is required because we always return a nil error

func (*AdminClient) CanSafelyRemove

func (client *AdminClient) CanSafelyRemove(addresses []fdbv1beta2.ProcessAddress) ([]fdbv1beta2.ProcessAddress, error)

CanSafelyRemove checks whether it is safe to remove the process group from the cluster

The list returned by this method will be the addresses that are *not* safe to remove.

func (*AdminClient) ChangeCoordinators

func (client *AdminClient) ChangeCoordinators(addresses []fdbv1beta2.ProcessAddress) (string, error)

ChangeCoordinators changes the coordinator set

func (*AdminClient) Close

func (client *AdminClient) Close() error

Close shuts down any resources for the client once it is no longer needed.

func (*AdminClient) ConfigureDatabase

func (client *AdminClient) ConfigureDatabase(configuration fdbv1beta2.DatabaseConfiguration, _ bool, version string) error

ConfigureDatabase changes the database configuration

func (*AdminClient) ExcludeProcesses

func (client *AdminClient) ExcludeProcesses(addresses []fdbv1beta2.ProcessAddress) error

ExcludeProcesses starts evacuating processes so that they can be removed from the database.

func (*AdminClient) FreezeStatus

func (client *AdminClient) FreezeStatus() error

FreezeStatus causes the GetStatus method to return its current value until UnfreezeStatus is called, or another method is called which would invalidate the status.

func (*AdminClient) GetBackupStatus

func (client *AdminClient) GetBackupStatus() (*fdbv1beta2.FoundationDBLiveBackupStatus, error)

GetBackupStatus gets the status of the current backup.

func (*AdminClient) GetConnectionString

func (client *AdminClient) GetConnectionString() (string, error)

GetConnectionString fetches the latest connection string.

func (*AdminClient) GetCoordinatorSet

func (client *AdminClient) GetCoordinatorSet() (map[string]struct{}, error)

GetCoordinatorSet gets the current coordinators from the status

func (*AdminClient) GetExclusions

func (client *AdminClient) GetExclusions() ([]fdbv1beta2.ProcessAddress, error)

GetExclusions gets a list of the addresses currently excluded from the database.

func (*AdminClient) GetMaintenanceZone

func (client *AdminClient) GetMaintenanceZone() (string, error)

GetMaintenanceZone gets current maintenance zone, if any

func (*AdminClient) GetProtocolVersion

func (client *AdminClient) GetProtocolVersion(version string) (string, error)

GetProtocolVersion determines the protocol version that is used by a version of FDB.

func (*AdminClient) GetRestoreStatus

func (client *AdminClient) GetRestoreStatus() (string, error)

GetRestoreStatus gets the status of the current restore.

func (*AdminClient) GetStatus

func (client *AdminClient) GetStatus() (*fdbv1beta2.FoundationDBStatus, error)

GetStatus gets the database's status

func (*AdminClient) IncludeProcesses

func (client *AdminClient) IncludeProcesses(addresses []fdbv1beta2.ProcessAddress) error

IncludeProcesses removes processes from the exclusion list and allows them to take on roles again.

func (*AdminClient) KillProcesses

func (client *AdminClient) KillProcesses(addresses []fdbv1beta2.ProcessAddress) error

KillProcesses restarts processes

func (*AdminClient) MockAdditionalProcesses

func (client *AdminClient) MockAdditionalProcesses(processes []fdbv1beta2.ProcessGroupStatus)

MockAdditionalProcesses adds additional processes to the cluster status.

func (*AdminClient) MockClientVersion

func (client *AdminClient) MockClientVersion(version string, clients []string)

MockClientVersion returns a mocked client version

func (*AdminClient) MockIncorrectCommandLine

func (client *AdminClient) MockIncorrectCommandLine(processGroupID string, incorrect bool)

MockIncorrectCommandLine updates the mock for whether a process group should be have an incorrect command-line.

func (*AdminClient) MockLocalityInfo

func (client *AdminClient) MockLocalityInfo(processGroupID string, locality map[string]string)

MockLocalityInfo sets mock locality information for a process.

func (*AdminClient) MockMissingProcessGroup

func (client *AdminClient) MockMissingProcessGroup(processGroupID string, missing bool)

MockMissingProcessGroup updates the mock for whether a process group should be missing from the cluster status.

func (*AdminClient) MockUptimeSecondsForMaintenanceZone

func (client *AdminClient) MockUptimeSecondsForMaintenanceZone(seconds float64)

MockUptimeSecondsForMaintenanceZone mocks the uptime for maintenance zone

func (*AdminClient) ModifyBackup

func (client *AdminClient) ModifyBackup(snapshotPeriodSeconds int) error

ModifyBackup reconfigures the backup.

func (*AdminClient) PauseBackups

func (client *AdminClient) PauseBackups() error

PauseBackups pauses backups.

func (*AdminClient) ResetMaintenanceMode

func (client *AdminClient) ResetMaintenanceMode() error

ResetMaintenanceMode resets the maintenance zone

func (*AdminClient) ResumeBackups

func (client *AdminClient) ResumeBackups() error

ResumeBackups resumes backups.

func (*AdminClient) SetKnobs

func (client *AdminClient) SetKnobs(knobs []string)

SetKnobs sets the Knobs that should be used for the commandline call.

func (*AdminClient) SetMaintenanceZone

func (client *AdminClient) SetMaintenanceZone(zone string, _ int) error

SetMaintenanceZone places zone into maintenance mode

func (*AdminClient) StartBackup

func (client *AdminClient) StartBackup(url string, snapshotPeriodSeconds int) error

StartBackup starts a new backup.

func (*AdminClient) StartRestore

func (client *AdminClient) StartRestore(url string, _ []fdbv1beta2.FoundationDBKeyRange) error

StartRestore starts a new restore.

func (*AdminClient) StopBackup

func (client *AdminClient) StopBackup(url string) error

StopBackup stops a backup.

func (*AdminClient) UnfreezeStatus

func (client *AdminClient) UnfreezeStatus()

UnfreezeStatus causes the admin client to start recalculating the status on every call to GetStatus

func (*AdminClient) VersionSupported

func (client *AdminClient) VersionSupported(versionString string) (bool, error)

VersionSupported reports whether we can support a cluster with a given version.

type DatabaseClientProvider

type DatabaseClientProvider struct{}

DatabaseClientProvider is a DatabaseClientProvider thar provides mocked clients for testing.

func (DatabaseClientProvider) GetAdminClient

func (p DatabaseClientProvider) GetAdminClient(cluster *fdbv1beta2.FoundationDBCluster, kubernetesClient client.Client) (fdbadminclient.AdminClient, error)

GetAdminClient generates a client for performing administrative actions against the database.

func (DatabaseClientProvider) GetLockClient

GetLockClient generates a client for working with locks through the database.

type LockClient

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

LockClient provides a mock client for managing operation locks.

func NewMockLockClientUncast

func NewMockLockClientUncast(cluster *fdbv1beta2.FoundationDBCluster) *LockClient

NewMockLockClientUncast creates a mock lock client.

func (*LockClient) AddPendingUpgrades

func (client *LockClient) AddPendingUpgrades(version fdbv1beta2.Version, processGroupIDs []string) error

AddPendingUpgrades registers information about which process groups are pending an upgrade to a new version.

func (*LockClient) ClearPendingUpgrades

func (client *LockClient) ClearPendingUpgrades() error

ClearPendingUpgrades clears any stored information about pending upgrades.

func (*LockClient) Disabled

func (client *LockClient) Disabled() bool

Disabled determines if the client should automatically grant locks.

func (*LockClient) GetDenyList

func (client *LockClient) GetDenyList() ([]string, error)

GetDenyList retrieves the current deny list from the database.

func (*LockClient) GetPendingUpgrades

func (client *LockClient) GetPendingUpgrades(version fdbv1beta2.Version) (map[string]bool, error)

GetPendingUpgrades returns the stored information about which process groups are pending an upgrade to a new version.

func (*LockClient) TakeLock

func (client *LockClient) TakeLock() (bool, error)

TakeLock attempts to acquire a lock.

func (*LockClient) UpdateDenyList

func (client *LockClient) UpdateDenyList(locks []fdbv1beta2.LockDenyListEntry) error

UpdateDenyList updates the deny list to match a list of entries. This will return the complete deny list after these changes are made.

Jump to

Keyboard shortcuts

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