bigmachine: github.com/grailbio/bigmachine/testsystem Index | Files

package testsystem

import "github.com/grailbio/bigmachine/testsystem"

Package testsystem implements a bigmachine system that's useful for testing. Unlike other system implementations, testsystem.System does not spawn new processes: instead, machines are launched inside of the same process.

Index

Package Files

testsystem.go

type System Uses

type System struct {
    // Machineprocs is the number of procs per machine.
    Machineprocs int

    // The following can optionally be specified to customize the behavior
    // of Bigmachine's keepalive mechanism.
    KeepalivePeriod, KeepaliveTimeout, KeepaliveRpcTimeout time.Duration
    // contains filtered or unexported fields
}

System implements a bigmachine System for testing. Systems should be instantiated with New().

func New Uses

func New() *System

New creates a new System that is ready for use.

func (*System) B Uses

func (s *System) B() *bigmachine.B

B returns the bigmachine session associated with this system.

func (*System) Exit Uses

func (s *System) Exit(int)

Exit marks the system as exited.

func (*System) Exited Uses

func (s *System) Exited() bool

Exited tells whether exit has been called on (any) machine.

func (*System) HTTPClient Uses

func (s *System) HTTPClient() *http.Client

HTTPClient returns an http.Client that can converse with servers created by this test system.

func (*System) Index Uses

func (s *System) Index(i int) *bigmachine.Machine

Index returns the i'th bigmachine in the system. Index panics if the index is out of range.

func (*System) Init Uses

func (s *System) Init(b *bigmachine.B) error

Init initializes the System.

func (*System) KeepaliveConfig Uses

func (s *System) KeepaliveConfig() (period, timeout, rpcTimeout time.Duration)

func (*System) Kill Uses

func (s *System) Kill(m *bigmachine.Machine) bool

Kill kills the machine m that is under management of this system, returning true if successful. If m is nil, a random machine is chosen.

func (*System) ListenAndServe Uses

func (s *System) ListenAndServe(addr string, handler http.Handler) error

ListenAndServe panics. It should not be called, provided a correct bigmachine implementation.

func (*System) Main Uses

func (s *System) Main() error

Main panics. It should not be called, provided a correct bigmachine implementation.

func (*System) Maxprocs Uses

func (s *System) Maxprocs() int

Maxprocs returns 1.

func (*System) N Uses

func (s *System) N() int

N returns the number of live machines in the test system.

func (*System) Name Uses

func (s *System) Name() string

Name returns the name of the system.

func (*System) Read Uses

func (s *System) Read(ctx context.Context, m *bigmachine.Machine, filename string) (io.Reader, error)

func (*System) Shutdown Uses

func (s *System) Shutdown()

Shutdown tears down temporary resources allocated by this System.

func (*System) Start Uses

func (s *System) Start(_ context.Context, count int) ([]*bigmachine.Machine, error)

Start starts and returns a new Machine. Each new machine is provided with a supervisor. The only difference between the behavior of a supervisor of a test machine and a regular machine is that the test machine supervisor does not exec the process, as this would break testing.

func (*System) Tail Uses

func (s *System) Tail(ctx context.Context, m *bigmachine.Machine) (io.Reader, error)

func (*System) Wait Uses

func (s *System) Wait(n int) int

Wait returns the number of live machines in the test system, blocking until there are at least n.

Package testsystem imports 13 packages (graph). Updated 2019-10-02. Refresh now. Tools for package owners.