Documentation

Overview

    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

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type System

    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

      func New() *System

        New creates a new System that is ready for use.

        func (*System) B

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

          B returns the bigmachine session associated with this system.

          func (*System) Event

          func (*System) Event(_ string, _ ...interface{})

            Event is a no-op for the test system, as we do not care about event logs in tests.

            func (*System) Exit

            func (s *System) Exit(int)

              Exit marks the system as exited.

              func (*System) Exited

              func (s *System) Exited() bool

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

                func (*System) HTTPClient

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

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

                  func (*System) Index

                  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

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

                      Init initializes the System.

                      func (*System) KeepaliveConfig

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

                      func (*System) Kill

                      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

                        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

                          func (s *System) Main() error

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

                            func (*System) Maxprocs

                            func (s *System) Maxprocs() int

                              Maxprocs returns 1.

                              func (*System) N

                              func (s *System) N() int

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

                                func (*System) Name

                                func (s *System) Name() string

                                  Name returns the name of the system.

                                  func (*System) Read

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

                                  func (*System) Shutdown

                                  func (s *System) Shutdown()

                                    Shutdown tears down temporary resources allocated by this System.

                                    func (*System) Start

                                    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

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

                                      func (*System) Wait

                                      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.

                                        Source Files