fakemysqldaemon

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: Apache-2.0 Imports: 14 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 SetMaster
	IOThreadRunning bool

	// CurrentMasterPosition is returned by MasterPosition
	// and ReplicationStatus
	CurrentMasterPosition 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

	// MasterStatusError is used by MasterStatus
	MasterStatusError 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

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

	// SetMasterError is used by SetMaster
	SetMasterError error

	// WaitMasterPosition is checked by WaitMasterPos, if the
	// same it returns nil, if different it returns an error
	WaitMasterPosition 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) DemoteMaster

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

DemoteMaster is deprecated: use mysqld.MasterPosition() 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) MasterPosition

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

MasterPosition is part of the MysqlDaemon interface

func (*FakeMysqlDaemon) MasterStatus

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

MasterStatus 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) 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) SetMaster

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

SetMaster 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) 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) WaitMasterPos

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

WaitMasterPos is part of the MysqlDaemon interface

Jump to

Keyboard shortcuts

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