mock

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 16 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     map[string]fdbv1beta2.None
	KilledAddresses       map[string]fdbv1beta2.None
	Knobs                 map[string]fdbv1beta2.None

	FrozenStatus *fdbv1beta2.FoundationDBStatus
	Backups      map[string]fdbv1beta2.FoundationDBBackupStatusBackupDetails

	VersionProcessGroups map[fdbv1beta2.ProcessGroupID]string
	ReincludedAddresses  map[string]bool

	MaxZoneFailuresWithoutLosingData         *int
	MaxZoneFailuresWithoutLosingAvailability *int
	MaintenanceZone                          fdbv1beta2.FaultDomain

	MockAdditionTimeForGlobalCoordination time.Time

	TeamTracker []fdbv1beta2.FoundationDBStatusTeamTracker
	Logs        []fdbv1beta2.FoundationDBStatusLogInfo

	LagInfo map[string]fdbv1beta2.FoundationDBStatusLagInfo

	RunLoopBusy     map[fdbv1beta2.ProcessGroupID]float64
	ProcessMessages map[fdbv1beta2.ProcessGroupID][]fdbv1beta2.FoundationDBStatusProcessMessage
	// 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) AbortBackup added in v2.14.0

func (client *AdminClient) AbortBackup(_ *fdbv1beta2.FoundationDBBackup) error

AbortBackup will abort a running backup.

func (*AdminClient) ChangeCoordinators

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

ChangeCoordinators changes the coordinator set

func (*AdminClient) ClearReadyForRestart added in v2.3.0

func (client *AdminClient) ClearReadyForRestart() error

ClearReadyForRestart removes all the process group IDs for all the process groups that are ready to be restarted.

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,
) error

ConfigureDatabase changes the database configuration

func (*AdminClient) DeleteBackup added in v2.14.0

func (client *AdminClient) DeleteBackup(_ *fdbv1beta2.FoundationDBBackup) error

DeleteBackup deletes all data related to a backup.

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) ExcludeProcessesWithNoWait

func (client *AdminClient) ExcludeProcessesWithNoWait(
	addresses []fdbv1beta2.ProcessAddress,
	_ bool,
) error

ExcludeProcessesWithNoWait starts evacuating processes so that they can be removed from the database. If noWait is set to true, the exclude command will not block until all data is moved away from the processes.

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) GetExclusions

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

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

func (*AdminClient) GetLimitingDurabilityLag

func (client *AdminClient) GetLimitingDurabilityLag() (fdbv1beta2.FoundationDBStatusLagInfo, bool)

GetLimitingDurabilityLag returns the limiting durability lag of any storage server in the cluster.

func (*AdminClient) GetPendingForExclusion added in v2.3.0

func (client *AdminClient) GetPendingForExclusion(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetPendingForExclusion gets the process group IDs for all process groups that should be excluded.

func (*AdminClient) GetPendingForInclusion added in v2.3.0

func (client *AdminClient) GetPendingForInclusion(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetPendingForInclusion gets the process group IDs for all the process groups that should be included.

func (*AdminClient) GetPendingForRemoval added in v2.3.0

func (client *AdminClient) GetPendingForRemoval(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetPendingForRemoval gets the process group IDs for all process groups that are marked for removal.

func (*AdminClient) GetPendingForRestart added in v2.3.0

func (client *AdminClient) GetPendingForRestart(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetPendingForRestart gets the process group IDs for all the process groups that should be restarted.

func (*AdminClient) GetProcessAddresses added in v2.5.0

func (client *AdminClient) GetProcessAddresses(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID][]string, error)

GetProcessAddresses gets the process group IDs and their associated process addresses.

func (*AdminClient) GetProcessesUnderMaintenance

func (client *AdminClient) GetProcessesUnderMaintenance() (map[fdbv1beta2.ProcessGroupID]int64, error)

GetProcessesUnderMaintenance will return all process groups that are currently stored to be under maintenance. The result is a map with the process group ID as key and the start of the maintenance as value.

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) GetReadyForExclusion added in v2.3.0

func (client *AdminClient) GetReadyForExclusion(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetReadyForExclusion gets the process group IDs for all the process groups that are ready to be excluded.

func (*AdminClient) GetReadyForInclusion added in v2.3.0

func (client *AdminClient) GetReadyForInclusion(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetReadyForInclusion gets the process group IDs for all the process groups that are ready to be included.

func (*AdminClient) GetReadyForRestart added in v2.3.0

func (client *AdminClient) GetReadyForRestart(
	prefix string,
) (map[fdbv1beta2.ProcessGroupID]time.Time, error)

GetReadyForRestart gets the process group IDs for all the process groups that are ready to be restarted.

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) GetVersionFromReachableCoordinators

func (client *AdminClient) GetVersionFromReachableCoordinators() string

GetVersionFromReachableCoordinators will return the running version based on the reachable coordinators. This method can be used during version incompatible upgrades and based on the responses of the coordinators, this method will assume the current running version of the cluster. If the fdbcli calls for none of the provided version return a majority of reachable coordinators, the default version from the cluster.Status.RunningVersion will be returned.

func (*AdminClient) GetWorstDataLag

func (client *AdminClient) GetWorstDataLag() (fdbv1beta2.FoundationDBStatusLagInfo, bool)

GetWorstDataLag returns the (mocked) worst data lag of any storage server in the cluster.

func (*AdminClient) GetWorstDurabilityLag

func (client *AdminClient) GetWorstDurabilityLag() (fdbv1beta2.FoundationDBStatusLagInfo, bool)

GetWorstDurabilityLag returns the (mocked) worst durability lag of any storage server in the cluster.

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) KillProcessesForUpgrade

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

KillProcessesForUpgrade restarts processes for upgrades, this will issue 2 kill commands to make sure all processes are restarted.

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) MockError

func (client *AdminClient) MockError(err error)

MockError mocks an error that will be returned when making any calls to the mock client. This can be reset by passing a nil value to this method.

func (*AdminClient) MockIncorrectCommandLine

func (client *AdminClient) MockIncorrectCommandLine(
	processGroupID fdbv1beta2.ProcessGroupID,
	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 fdbv1beta2.ProcessGroupID,
	locality map[string]string,
)

MockLocalityInfo sets mock locality information for a process.

func (*AdminClient) MockMissingLocalities

func (client *AdminClient) MockMissingLocalities(
	processGroupID fdbv1beta2.ProcessGroupID,
	missingLocalities bool,
)

MockMissingLocalities updates the mock to remove the localities for the provided process group.

func (*AdminClient) MockMissingProcessGroup

func (client *AdminClient) MockMissingProcessGroup(
	processGroupID fdbv1beta2.ProcessGroupID,
	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(backup *fdbv1beta2.FoundationDBBackup) error

ModifyBackup reconfigures the backup.

func (*AdminClient) PauseBackups

func (client *AdminClient) PauseBackups() error

PauseBackups pauses backups.

func (*AdminClient) RemoveProcessesUnderMaintenance

func (client *AdminClient) RemoveProcessesUnderMaintenance(ids []fdbv1beta2.ProcessGroupID) error

RemoveProcessesUnderMaintenance will remove the provided process groups from the list of processes that are planned to be taken down for maintenance.

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) SetLimitingDurabilityLag

func (client *AdminClient) SetLimitingDurabilityLag(lagInfo *fdbv1beta2.FoundationDBStatusLagInfo)

SetLimitingDurabilityLag sets/mocks the limiting durability lag of any storage server in the cluster.

func (*AdminClient) SetMaintenanceZone

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

SetMaintenanceZone places zone into maintenance mode

func (*AdminClient) SetProcessesUnderMaintenance

func (client *AdminClient) SetProcessesUnderMaintenance(
	ids []fdbv1beta2.ProcessGroupID,
	timestamp int64,
) error

SetProcessesUnderMaintenance will add the provided process groups to the list of processes that will be taken down for maintenance. The value will be the provided time stamp.

func (*AdminClient) SetTimeout

func (client *AdminClient) SetTimeout(_ time.Duration)

SetTimeout will overwrite the default timeout for interacting the FDB cluster.

func (*AdminClient) SetWorstDataLag

func (client *AdminClient) SetWorstDataLag(lagInfo *fdbv1beta2.FoundationDBStatusLagInfo)

SetWorstDataLag sets/mocks the worst data lag of any storage server in the cluster.

func (*AdminClient) SetWorstDurabilityLag

func (client *AdminClient) SetWorstDurabilityLag(lagInfo *fdbv1beta2.FoundationDBStatusLagInfo)

SetWorstDurabilityLag sets/mocks the worst durability lag of any storage server in the cluster.

func (*AdminClient) StartBackup

func (client *AdminClient) StartBackup(backup *fdbv1beta2.FoundationDBBackup) error

StartBackup starts a new backup.

func (*AdminClient) StartRestore

func (client *AdminClient) StartRestore(
	url string,
	_ fdbv1beta2.FoundationDBRestore,
) error

StartRestore starts a new restore.

func (*AdminClient) StopBackup

func (client *AdminClient) StopBackup(backup *fdbv1beta2.FoundationDBBackup) 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) UpdatePendingForExclusion added in v2.3.0

func (client *AdminClient) UpdatePendingForExclusion(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdatePendingForExclusion updates the set of process groups that should be excluded, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdatePendingForInclusion added in v2.3.0

func (client *AdminClient) UpdatePendingForInclusion(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdatePendingForInclusion updates the set of process groups that should be included, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdatePendingForRemoval added in v2.3.0

func (client *AdminClient) UpdatePendingForRemoval(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdatePendingForRemoval updates the set of process groups that are marked for removal, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdatePendingForRestart added in v2.3.0

func (client *AdminClient) UpdatePendingForRestart(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdatePendingForRestart updates the set of process groups that should be restarted, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdateProcessAddresses added in v2.5.0

func (client *AdminClient) UpdateProcessAddresses(
	updates map[fdbv1beta2.ProcessGroupID][]string,
) error

UpdateProcessAddresses updates the process addresses for the specified process group ID. If the provided slice is empty or nil, the entry will be deleted.

func (*AdminClient) UpdateReadyForExclusion added in v2.3.0

func (client *AdminClient) UpdateReadyForExclusion(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdateReadyForExclusion updates the set of process groups that are ready to be excluded, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdateReadyForInclusion added in v2.3.0

func (client *AdminClient) UpdateReadyForInclusion(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdateReadyForInclusion updates the set of process groups that are ready to be included, an update can be either the addition or removal of a process group.

func (*AdminClient) UpdateReadyForRestart added in v2.3.0

func (client *AdminClient) UpdateReadyForRestart(
	updates map[fdbv1beta2.ProcessGroupID]fdbv1beta2.UpdateAction,
) error

UpdateReadyForRestart updates the set of process groups that are ready to be restarted, an update can be either the addition or removal of a process group

func (*AdminClient) VersionSupported

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

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

func (*AdminClient) WithValues

func (client *AdminClient) WithValues(_ ...interface{})

WithValues will update the logger used by the current AdminClient to contain the provided key value pairs. The provided arguments must be even.

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) GetAdminClientWithLogger

func (p DatabaseClientProvider) GetAdminClientWithLogger(
	cluster *fdbv1beta2.FoundationDBCluster,
	kubernetesClient client.Client,
	_ logr.Logger,
) (fdbadminclient.AdminClient, error)

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

func (DatabaseClientProvider) GetLockClient

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

func (DatabaseClientProvider) GetLockClientWithLogger

func (p DatabaseClientProvider) GetLockClientWithLogger(
	cluster *fdbv1beta2.FoundationDBCluster,
	_ logr.Logger,
) (fdbadminclient.LockClient, error)

GetLockClientWithLogger generates a client for working with locks through the database. The provided logger will be used as logger for the LockClient.

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 []fdbv1beta2.ProcessGroupID,
) 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[fdbv1beta2.ProcessGroupID]bool, error)

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

func (*LockClient) ReleaseLock

func (client *LockClient) ReleaseLock() error

ReleaseLock will release the current lock. The method will only release the lock if the current operator is the lock holder.

func (*LockClient) TakeLock

func (client *LockClient) TakeLock() 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