testbed

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package testbed is a tool for running redis-server for tests.

Index

Constants

This section is empty.

Variables

View Source
var Binary = func() string { p, _ := exec.LookPath("redis-server"); return p }()

Binary is a path to redis-server

View Source
var Dir = ""

Dir is temporary directory where redis will run.

Functions

func InitDir

func InitDir(base string)

InitDir initiates Dir with temporary directory in base.

func RmDir

func RmDir()

RmDir removes temporary directory.

Types

type Cluster

type Cluster struct {
	Node []Node
}

Cluster is a tool for starting/stopping redis cluster for tests.

func NewCluster

func NewCluster(startport uint16) *Cluster

NewCluster instantiate cluster of 6 nodes (3 masters and 3 slaves). Master are on ports startport, startport+1, startport+2, and slaves are on ports startport+3, startport+4, startport+5

func (*Cluster) AttemptFailover

func (cl *Cluster) AttemptFailover()

AttemptFailover tries to issue CLUSTER FAILOVER FORCE to slaves of falled masters. This is work around replication bug present in Redis till 4.0.9 (including)

func (*Cluster) CancelMoveSlot

func (cl *Cluster) CancelMoveSlot(slot int)

CancelMoveSlot resets slot migration.

func (*Cluster) ClusterOk

func (cl *Cluster) ClusterOk() bool

ClusterOk checks cluster configuration.

func (*Cluster) FinishMoveSlot

func (cl *Cluster) FinishMoveSlot(slot, from, to int)

FinishMoveSlot finalizes slot migration

func (*Cluster) InitMoveSlot

func (cl *Cluster) InitMoveSlot(slot, from, to int)

InitMoveSlot issues start for slot migration.

func (*Cluster) MoveSlot

func (cl *Cluster) MoveSlot(slot, from, to int)

MoveSlot moves slot's keys from host to host.

func (*Cluster) Start

func (cl *Cluster) Start()

Start starts all cluster's servers

func (*Cluster) StartSeventhNode

func (cl *Cluster) StartSeventhNode()

StartSeventhNode start additional node

func (*Cluster) Stop

func (cl *Cluster) Stop()

Stop stops all cluster's servers

func (*Cluster) StopSeventhNode

func (cl *Cluster) StopSeventhNode()

StopSeventhNode stops additional node

func (*Cluster) WaitClusterOk

func (cl *Cluster) WaitClusterOk()

WaitClusterOk wait for cluster configuration to be stable.

type Node

type Node struct {
	Server
	NodeId []byte
}

Node is wrapper for Server with its NodeId

func (*Node) AddSlots

func (n *Node) AddSlots(from, to int)

AddSlots issues CLUSTER ADDSLOTS command.

func (*Node) SetupNodeId

func (n *Node) SetupNodeId()

SetupNodeId learns nodeid of this node

type Server

type Server struct {
	Port   uint16
	Args   []string
	Cmd    *exec.Cmd
	Paused bool
	Conn   redisdumb.Conn
}

Server is a handle for running redis-server.

func (*Server) Addr

func (s *Server) Addr() string

Addr - address + port

func (*Server) Do

func (s *Server) Do(cmd string, args ...interface{}) interface{}

Do executes command on server.

func (*Server) DoSure

func (s *Server) DoSure(cmd string, args ...interface{}) interface{}

DoSure executes command and panics if it returns error.

func (*Server) Pause

func (s *Server) Pause()

Pause pauses server with SIGSTOP.

func (*Server) PortStr

func (s *Server) PortStr() string

PortStr returns server's port as a string

func (*Server) Resume

func (s *Server) Resume()

Resume resumes server with SIGCONT.

func (*Server) Running

func (s *Server) Running() bool

Running returns true if server should be running at the moment.

func (*Server) RunningNow

func (s *Server) RunningNow() bool

RunningNow returns true if server should be running and it is not paused (with SIGSTOP).

func (*Server) Start

func (s *Server) Start()

Start starts redis and waits for its initialization.

func (*Server) Stop

func (s *Server) Stop()

Stop kills server.

Jump to

Keyboard shortcuts

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