testlib

package
v0.0.0-...-3712671 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2014 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package testlib contains utility methods to include in unit tests to deal with topology common tasks, liek fake tablets and action loops.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeTablet

type FakeTablet struct {
	// Tablet and FakeMysqlDaemon are populated at NewFakeTablet time.
	Tablet          *topo.Tablet
	FakeMysqlDaemon *mysqlctl.FakeMysqlDaemon

	// Done is created when we start the event loop for the tablet,
	// and closed / cleared when we stop it.
	Done chan struct{}
}

FakeTablet keeps track of a fake tablet in memory. It has: - a Tablet record (used for creating the tablet, kept for user's information) - a FakeMysqlDaemon (used by the fake event loop) - a 'done' channel (used to terminate the fake event loop)

func NewFakeTablet

func NewFakeTablet(t *testing.T, wr *wrangler.Wrangler, cell string, uid uint32, tabletType topo.TabletType, options ...TabletOption) *FakeTablet

CreateTestTablet creates the test tablet in the topology. 'uid' has to be between 0 and 99. All the tablet info will be derived from that. Look at the implementation if you need values. Use TabletOption implementations if you need to change values at creation.

func (*FakeTablet) StartActionLoop

func (ft *FakeTablet) StartActionLoop(t *testing.T, wr *wrangler.Wrangler)

StartActionLoop will start the action loop for a fake tablet, using ft.FakeMysqlDaemon as the backing mysqld.

func (*FakeTablet) StopActionLoop

func (ft *FakeTablet) StopActionLoop(t *testing.T)

StopActionLoop will stop the Action Loop for the given FakeTablet

type TabletOption

type TabletOption func(tablet *topo.Tablet)

TabletOption is an interface for changing tablet parameters. It's a way to pass multiple parameters to NewFakeTablet without making it too cumbersome.

func TabletKeyspaceShard

func TabletKeyspaceShard(t *testing.T, keyspace, shard string) TabletOption

TabletKeyspaceShard is the option to set the tablet keyspace and shard

func TabletParent

func TabletParent(parent topo.TabletAlias) TabletOption

TabletParent is the tablet option to set the parent alias

Jump to

Keyboard shortcuts

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