fakemysqldaemon

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeMysqlDaemon

type FakeMysqlDaemon struct {

	// Running is used by Start / Shutdown
	Running bool

	// StartupTime is used to simulate mysqlds that take some time to respond
	// to a "start" command. It is used by Start.
	StartupTime time.Duration

	// ShutdownTime is used to simulate mysqlds that take some time to respond
	// to a "stop" request (i.e. a wedged systemd unit). It is used by Shutdown.
	ShutdownTime time.Duration

	// MysqlPort will be returned by GetMysqlPort(). Set to -1 to
	// return an error.
	MysqlPort sync2.AtomicInt32

	// Replicating is updated when calling StartReplication / StopReplication
	// (it is not used at all when calling ReplicationStatus, it is the
	// test owner responsibility to have these two match)
	Replicating bool

	// IOThreadRunning is always true except in one testcase
	// where we want to test error handling during SetReplicationSource
	IOThreadRunning bool

	// CurrentPrimaryPosition is returned by PrimaryPosition
	// and ReplicationStatus
	CurrentPrimaryPosition mysql.Position

	// CurrentMasterFilePosition is used to determine the executed file based positioning of the master.
	CurrentMasterFilePosition mysql.Position

	// ReplicationStatusError is used by ReplicationStatus
	ReplicationStatusError error

	// StartReplicationError is used by StartReplication
	StartReplicationError error

	// PrimaryStatusError is used by PrimaryStatus
	PrimaryStatusError error

	// CurrentMasterHost is returned by ReplicationStatus
	CurrentMasterHost string

	// CurrentMasterport is returned by ReplicationStatus
	CurrentMasterPort int

	// SecondsBehindMaster is returned by ReplicationStatus
	SecondsBehindMaster uint

	// ReadOnly is the current value of the flag
	ReadOnly bool

	// SuperReadOnly is the current value of the flag
	SuperReadOnly bool

	// SetReplicationPositionPos is matched against the input of SetReplicationPosition.
	// If it doesn't match, SetReplicationPosition will return an error.
	SetReplicationPositionPos mysql.Position

	// StartReplicationUntilAfterPos is matched against the input
	StartReplicationUntilAfterPos mysql.Position

	// SetReplicationSourceInput is matched against the input of SetReplicationSource
	// (as "%v:%v"). If it doesn't match, SetReplicationSource will return an error.
	SetReplicationSourceInput string

	// SetReplicationSourceError is used by SetReplicationSource
	SetReplicationSourceError error

	// WaitPrimaryPosition is checked by WaitSourcePos, if the
	// same it returns nil, if different it returns an error
	WaitPrimaryPosition mysql.Position

	// PromoteResult is returned by Promote
	PromoteResult mysql.Position

	// PromoteError is used by Promote
	PromoteError error

	// SchemaFunc provides the return value for GetSchema.
	// If not defined, the "Schema" field will be used instead, see below.
	SchemaFunc func() (*tabletmanagerdatapb.SchemaDefinition, error)

	// Schema will be returned by GetSchema. If nil we'll
	// return an error.
	Schema *tabletmanagerdatapb.SchemaDefinition

	// PreflightSchemaChangeResult will be returned by PreflightSchemaChange.
	// If nil we'll return an error.
	PreflightSchemaChangeResult []*tabletmanagerdatapb.SchemaChangeResult

	// ApplySchemaChangeResult will be returned by ApplySchemaChange.
	// If nil we'll return an error.
	ApplySchemaChangeResult *tabletmanagerdatapb.SchemaChangeResult

	// ExpectedExecuteSuperQueryList is what we expect
	// ExecuteSuperQueryList to be called with. If it doesn't
	// match, ExecuteSuperQueryList will return an error.
	// Note each string is just a substring if it begins with SUB,
	// so we support partial queries (useful when queries contain
	// data fields like timestamps)
	ExpectedExecuteSuperQueryList []string

	// ExpectedExecuteSuperQueryCurrent is the current index of the queries
	// we expect
	ExpectedExecuteSuperQueryCurrent int

	// FetchSuperQueryResults is used by FetchSuperQuery
	FetchSuperQueryMap map[string]*sqltypes.Result

	// BinlogPlayerEnabled is used by {Enable,Disable}BinlogPlayer
	BinlogPlayerEnabled sync2.AtomicBool

	// SemiSyncMasterEnabled represents the state of rpl_semi_sync_master_enabled.
	SemiSyncMasterEnabled bool
	// SemiSyncReplicaEnabled represents the state of rpl_semi_sync_slave_enabled.
	SemiSyncReplicaEnabled bool

	// TimeoutHook is a func that can be called at the beginning of any method to fake a timeout.
	// all a test needs to do is make it { return context.DeadlineExceeded }
	TimeoutHook func() error
	// contains filtered or unexported fields
}

FakeMysqlDaemon implements MysqlDaemon and allows the user to fake everything.

func NewFakeMysqlDaemon

func NewFakeMysqlDaemon(db *fakesqldb.DB) *FakeMysqlDaemon

NewFakeMysqlDaemon returns a FakeMysqlDaemon where mysqld appears to be running, based on a fakesqldb.DB. 'db' can be nil if the test doesn't use a database at all.

func (*FakeMysqlDaemon) ApplySchemaChange

func (fmd *FakeMysqlDaemon) ApplySchemaChange(ctx context.Context, dbName string, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error)

ApplySchemaChange is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) CheckSuperQueryList

func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error

CheckSuperQueryList returns an error if all the queries we expected haven't been seen.

func (*FakeMysqlDaemon) Close

func (fmd *FakeMysqlDaemon) Close()

Close is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) CurrentPrimaryPositionLocked added in v0.11.0

func (fmd *FakeMysqlDaemon) CurrentPrimaryPositionLocked(pos mysql.Position)

CurrentPrimaryPositionLocked is thread-safe

func (*FakeMysqlDaemon) DemoteMaster

func (fmd *FakeMysqlDaemon) DemoteMaster() (mysql.Position, error)

DemoteMaster is deprecated: use mysqld.PrimaryPosition() instead

func (*FakeMysqlDaemon) DisableBinlogPlayback

func (fmd *FakeMysqlDaemon) DisableBinlogPlayback() error

DisableBinlogPlayback disable playback of binlog events

func (*FakeMysqlDaemon) EnableBinlogPlayback

func (fmd *FakeMysqlDaemon) EnableBinlogPlayback() error

EnableBinlogPlayback is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) ExecuteSuperQueryList

func (fmd *FakeMysqlDaemon) ExecuteSuperQueryList(ctx context.Context, queryList []string) error

ExecuteSuperQueryList is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) FetchSuperQuery

func (fmd *FakeMysqlDaemon) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error)

FetchSuperQuery returns the results from the map, if any

func (*FakeMysqlDaemon) GetAllPrivsConnection

func (fmd *FakeMysqlDaemon) GetAllPrivsConnection(ctx context.Context) (*dbconnpool.DBConnection, error)

GetAllPrivsConnection is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) GetAppConnection

func (fmd *FakeMysqlDaemon) GetAppConnection(ctx context.Context) (*dbconnpool.PooledDBConnection, error)

GetAppConnection is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) GetColumns

func (fmd *FakeMysqlDaemon) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error)

GetColumns is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) GetDbaConnection

func (fmd *FakeMysqlDaemon) GetDbaConnection(ctx context.Context) (*dbconnpool.DBConnection, error)

GetDbaConnection is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) GetMysqlPort

func (fmd *FakeMysqlDaemon) GetMysqlPort() (int32, error)

GetMysqlPort is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) GetPrimaryKeyColumns

func (fmd *FakeMysqlDaemon) GetPrimaryKeyColumns(ctx context.Context, dbName, table string) ([]string, error)

GetPrimaryKeyColumns is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) GetSchema

func (fmd *FakeMysqlDaemon) GetSchema(ctx context.Context, dbName string, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error)

GetSchema is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) IsReadOnly

func (fmd *FakeMysqlDaemon) IsReadOnly() (bool, error)

IsReadOnly is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) PreflightSchemaChange

func (fmd *FakeMysqlDaemon) PreflightSchemaChange(ctx context.Context, dbName string, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error)

PreflightSchemaChange is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) PrimaryPosition added in v0.11.0

func (fmd *FakeMysqlDaemon) PrimaryPosition() (mysql.Position, error)

PrimaryPosition is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) PrimaryStatus added in v0.11.0

func (fmd *FakeMysqlDaemon) PrimaryStatus(ctx context.Context) (mysql.PrimaryStatus, error)

PrimaryStatus is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) Promote

func (fmd *FakeMysqlDaemon) Promote(hookExtraEnv map[string]string) (mysql.Position, error)

Promote is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) RefreshConfig

func (fmd *FakeMysqlDaemon) RefreshConfig(ctx context.Context, cnf *mysqlctl.Mycnf) error

RefreshConfig is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) ReinitConfig

func (fmd *FakeMysqlDaemon) ReinitConfig(ctx context.Context, cnf *mysqlctl.Mycnf) error

ReinitConfig is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) ReplicationStatus

func (fmd *FakeMysqlDaemon) ReplicationStatus() (mysql.ReplicationStatus, error)

ReplicationStatus is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) ResetReplication

func (fmd *FakeMysqlDaemon) ResetReplication(ctx context.Context) error

ResetReplication is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) RestartReplication

func (fmd *FakeMysqlDaemon) RestartReplication(hookExtraEnv map[string]string) error

RestartReplication is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) RunMysqlUpgrade

func (fmd *FakeMysqlDaemon) RunMysqlUpgrade() error

RunMysqlUpgrade is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) SemiSyncEnabled

func (fmd *FakeMysqlDaemon) SemiSyncEnabled() (master, replica bool)

SemiSyncEnabled is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) SemiSyncReplicationStatus

func (fmd *FakeMysqlDaemon) SemiSyncReplicationStatus() (bool, error)

SemiSyncReplicationStatus is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) SetReadOnly

func (fmd *FakeMysqlDaemon) SetReadOnly(on bool) error

SetReadOnly is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) SetReplicationPosition

func (fmd *FakeMysqlDaemon) SetReplicationPosition(ctx context.Context, pos mysql.Position) error

SetReplicationPosition is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) SetReplicationSource added in v0.11.0

func (fmd *FakeMysqlDaemon) SetReplicationSource(ctx context.Context, masterHost string, masterPort int, stopReplicationBefore bool, startReplicationAfter bool) error

SetReplicationSource is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) SetSemiSyncEnabled

func (fmd *FakeMysqlDaemon) SetSemiSyncEnabled(master, replica bool) error

SetSemiSyncEnabled is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) SetSuperReadOnly

func (fmd *FakeMysqlDaemon) SetSuperReadOnly(on bool) error

SetSuperReadOnly is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) Shutdown

func (fmd *FakeMysqlDaemon) Shutdown(ctx context.Context, cnf *mysqlctl.Mycnf, waitForMysqld bool) error

Shutdown is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) Start

func (fmd *FakeMysqlDaemon) Start(ctx context.Context, cnf *mysqlctl.Mycnf, mysqldArgs ...string) error

Start is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) StartReplication

func (fmd *FakeMysqlDaemon) StartReplication(hookExtraEnv map[string]string) error

StartReplication is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) StartReplicationUntilAfter

func (fmd *FakeMysqlDaemon) StartReplicationUntilAfter(ctx context.Context, pos mysql.Position) error

StartReplicationUntilAfter is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) StopIOThread

func (fmd *FakeMysqlDaemon) StopIOThread(ctx context.Context) error

StopIOThread is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) StopReplication

func (fmd *FakeMysqlDaemon) StopReplication(hookExtraEnv map[string]string) error

StopReplication is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) Wait

func (fmd *FakeMysqlDaemon) Wait(ctx context.Context, cnf *mysqlctl.Mycnf) error

Wait is part of the MysqlDaemon interface.

func (*FakeMysqlDaemon) WaitForReparentJournal

func (fmd *FakeMysqlDaemon) WaitForReparentJournal(ctx context.Context, timeCreatedNS int64) error

WaitForReparentJournal is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) WaitSourcePos added in v0.11.0

func (fmd *FakeMysqlDaemon) WaitSourcePos(_ context.Context, pos mysql.Position) error

WaitSourcePos is part of the MysqlDaemon interface

Jump to

Keyboard shortcuts

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