test

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const SliceWidth = pilosa.SliceWidth

SliceWidth is a helper reference to use when testing.

Variables

This section is empty.

Functions

func BenchmarkAttrStore_Duplicate added in v0.5.0

func BenchmarkAttrStore_Duplicate(b *testing.B)

func GenerateImportFill added in v0.5.0

func GenerateImportFill(rowN int, pct float64) (rowIDs, columnIDs []uint64)

GenerateImportFill generates a set of bits pairs that evenly fill a fragment chunk.

func MustDo added in v0.9.0

func MustDo(method, urlStr string, body string) *httpResponse

MustDo executes http.Do() with an http.NewRequest(). Panic on error.

func MustMarshalJSON added in v0.5.0

func MustMarshalJSON(v interface{}) []byte

MustMarshalJSON marshals v to JSON. Panic on error.

func MustNewHTTPRequest added in v0.5.0

func MustNewHTTPRequest(method, urlStr string, body io.Reader) *http.Request

MustNewHTTPRequest creates a new HTTP request. Panic on error.

func MustOpenAttrStore added in v0.5.0

func MustOpenAttrStore() pilosa.AttrStore

MustOpenAttrStore returns a new, opened attribute store at a temporary path. Panic on error.

func MustParse added in v0.5.0

func MustParse(s string) *pql.Query

MustParse parses s into a PQL query. Panic on error.

func MustParseURLHost added in v0.5.0

func MustParseURLHost(rawurl string) string

MustParseURLHost parses rawurl and returns the hostname. Panic on error.

func MustReadAll added in v0.5.0

func MustReadAll(r io.Reader) []byte

MustReadAll reads a reader into a buffer and returns it. Panic on error.

func NewAttrStore added in v0.5.0

func NewAttrStore(string) pilosa.AttrStore

NewAttrStore returns a new instance of AttrStore.

func NewCluster added in v0.5.0

func NewCluster(n int) *pilosa.Cluster

NewCluster returns a cluster with n nodes and uses a mod-based hasher.

func NewURI added in v0.9.0

func NewURI(scheme, host string, port uint16) pilosa.URI

NewURI is a test URI creator that intentionally swallows errors.

func NewURIFromHostPort added in v0.9.0

func NewURIFromHostPort(host string, port uint16) pilosa.URI

func TestFrame_SetCacheSize added in v0.5.0

func TestFrame_SetCacheSize(t *testing.T)

Ensure frame can set its cache

Types

type AttrStore added in v0.5.0

type AttrStore struct {
	pilosa.AttrStore
}

AttrStore represents a test wrapper for pilosa.AttrStore.

func (*AttrStore) Close added in v0.5.0

func (s *AttrStore) Close() error

Close closes the database and removes the underlying data.

type BufferLogger added in v0.9.0

type BufferLogger struct {
	// contains filtered or unexported fields
}

BufferLogger represents a test Logger that holds log messages in a buffer for review.

func NewBufferLogger added in v0.9.0

func NewBufferLogger() *BufferLogger

NewBufferLogger returns a new instance of BufferLogger.

func (*BufferLogger) Debugf added in v0.9.0

func (b *BufferLogger) Debugf(format string, v ...interface{})

func (*BufferLogger) Printf added in v0.9.0

func (b *BufferLogger) Printf(format string, v ...interface{})

func (*BufferLogger) ReadAll added in v0.9.0

func (b *BufferLogger) ReadAll() ([]byte, error)

type Client added in v0.5.0

type Client struct {
	*pilosa.InternalHTTPClient
}

Client represents a test wrapper for pilosa.Client.

func MustNewClient added in v0.5.0

func MustNewClient(host string, h *http.Client) *Client

MustNewClient returns a new instance of Client. Panic on error.

type ConstHasher added in v0.5.0

type ConstHasher struct {
	// contains filtered or unexported fields
}

ConstHasher represents hash that always returns the same index.

func NewConstHasher added in v0.5.0

func NewConstHasher(i int) *ConstHasher

NewConstHasher returns a new instance of ConstHasher that always returns i.

func (*ConstHasher) Hash added in v0.5.0

func (h *ConstHasher) Hash(key uint64, n int) int

type Executor added in v0.5.0

type Executor struct {
	*pilosa.Executor
}

Executor represents a test wrapper for pilosa.Executor.

func NewExecutor added in v0.5.0

func NewExecutor(holder *pilosa.Holder, cluster *pilosa.Cluster) *Executor

NewExecutor returns a new instance of Executor. The executor always matches the uri of the first cluster node.

type Fragment added in v0.5.0

type Fragment struct {
	*pilosa.Fragment
	RowAttrStore pilosa.AttrStore
}

Fragment is a test wrapper for pilosa.Fragment.

func MustOpenFragment added in v0.5.0

func MustOpenFragment(index, frame, view string, slice uint64, cacheType string) *Fragment

MustOpenFragment creates and opens an fragment at a temporary path. Panic on error.

func NewFragment added in v0.5.0

func NewFragment(index, frame, view string, slice uint64, cacheType string) *Fragment

NewFragment returns a new instance of Fragment with a temporary path.

func (*Fragment) Close added in v0.5.0

func (f *Fragment) Close() error

Close closes the fragment and removes all underlying data.

func (*Fragment) MustClearBits added in v0.5.0

func (f *Fragment) MustClearBits(rowID uint64, columnIDs ...uint64)

MustClearBits clears bits on a row. Panic on error.

func (*Fragment) MustSetBits added in v0.5.0

func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64)

MustSetBits sets bits on a row. Panic on error. This function does not accept a timestamp or quantum.

func (*Fragment) Reopen added in v0.5.0

func (f *Fragment) Reopen() error

Reopen closes the fragment and reopens it as a new instance.

type Frame added in v0.5.0

type Frame struct {
	*pilosa.Frame
}

Frame represents a test wrapper for pilosa.Frame.

func MustOpenFrame added in v0.5.0

func MustOpenFrame() *Frame

MustOpenFrame returns a new, opened frame at a temporary path. Panic on error.

func NewFrame added in v0.5.0

func NewFrame() *Frame

NewFrame returns a new instance of Frame d/0.

func (*Frame) Close added in v0.5.0

func (f *Frame) Close() error

Close closes the frame and removes the underlying data.

func (*Frame) MustSetBit added in v0.5.0

func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool)

MustSetBit sets a bit on the frame. Panic on error.

func (*Frame) Reopen added in v0.5.0

func (f *Frame) Reopen() error

Reopen closes the index and reopens it.

type Handler added in v0.5.0

type Handler struct {
	*pilosa.Handler
	Executor HandlerExecutor
}

Handler represents a test wrapper for pilosa.Handler.

func NewHandler added in v0.5.0

func NewHandler() *Handler

NewHandler returns a new instance of Handler.

type HandlerExecutor added in v0.5.0

type HandlerExecutor struct {
	ExecuteFn func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error)
	// contains filtered or unexported fields
}

HandlerExecutor is a mock implementing pilosa.Handler.Executor.

func (*HandlerExecutor) Cluster added in v0.5.0

func (c *HandlerExecutor) Cluster() *pilosa.Cluster

func (*HandlerExecutor) Execute added in v0.5.0

func (c *HandlerExecutor) Execute(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error)

type Holder added in v0.5.0

type Holder struct {
	*pilosa.Holder
}

Holder is a test wrapper for pilosa.Holder.

func MustOpenHolder added in v0.5.0

func MustOpenHolder() *Holder

MustOpenHolder creates and opens a holder at a temporary path. Panic on error.

func NewHolder added in v0.5.0

func NewHolder() *Holder

NewHolder returns a new instance of Holder with a temporary path.

func (*Holder) Close added in v0.5.0

func (h *Holder) Close() error

Close closes the holder and removes all underlying data.

func (*Holder) MustCreateFragmentIfNotExists added in v0.5.0

func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment

MustCreateFragmentIfNotExists returns a given fragment. Panic on error.

func (*Holder) MustCreateFrameIfNotExists added in v0.5.0

func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame

MustCreateFrameIfNotExists returns a given frame. Panic on error.

func (*Holder) MustCreateIndexIfNotExists added in v0.5.0

func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOptions) *Index

MustCreateIndexIfNotExists returns a given index. Panic on error.

func (*Holder) MustCreateRankedFragmentIfNotExists added in v0.5.0

func (h *Holder) MustCreateRankedFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment

MustCreateRankedFragmentIfNotExists returns a given fragment with a ranked cache. Panic on error.

func (*Holder) Reopen added in v0.5.0

func (h *Holder) Reopen() error

Reopen instantiates and opens a new holder. Note that the holder must be Closed first.

type Index added in v0.5.0

type Index struct {
	*pilosa.Index
}

Index represents a test wrapper for pilosa.Index.

func MustOpenIndex added in v0.5.0

func MustOpenIndex() *Index

MustOpenIndex returns a new, opened index at a temporary path. Panic on error.

func NewIndex added in v0.5.0

func NewIndex() *Index

NewIndex returns a new instance of Index.

func (*Index) Close added in v0.5.0

func (i *Index) Close() error

Close closes the index and removes the underlying data.

func (*Index) CreateFrame added in v0.5.0

func (i *Index) CreateFrame(name string, opt pilosa.FrameOptions) (*Frame, error)

CreateFrame creates a frame with the given options.

func (*Index) CreateFrameIfNotExists added in v0.5.0

func (i *Index) CreateFrameIfNotExists(name string, opt pilosa.FrameOptions) (*Frame, error)

CreateFrameIfNotExists creates a frame with the given options if it doesn't exist.

func (*Index) Reopen added in v0.5.0

func (i *Index) Reopen() error

Reopen closes the index and reopens it.

type Main added in v0.9.0

type Main struct {
	*server.Command

	Stdin  bytes.Buffer
	Stdout bytes.Buffer
	Stderr bytes.Buffer
}

////////////////////////////////////////////////////////////////////////////////// Main represents a test wrapper for main.Main.

func MustRunMain added in v0.9.0

func MustRunMain() *Main

MustRunMain returns a new, running Main. Panic on error.

func MustRunMainWithCluster added in v0.9.0

func MustRunMainWithCluster(t *testing.T, size int, opts ...MainOpt) []*Main

MustRunMainWithCluster ruturns a running array of *Main where all nodes are joined via memberlist (i.e. clustering enabled).

func NewMain added in v0.9.0

func NewMain(opts ...MainOpt) *Main

NewMain returns a new instance of Main with a temporary data directory and random port.

func NewMainWithCluster added in v0.9.0

func NewMainWithCluster(isCoordinator bool, opts ...MainOpt) *Main

NewMainWithCluster returns a new instance of Main with clustering enabled.

func (*Main) Client added in v0.9.0

func (m *Main) Client() *pilosa.InternalHTTPClient

Client returns a client to connect to the program.

func (*Main) Close added in v0.9.0

func (m *Main) Close() error

Close closes the program and removes the underlying data directory.

func (*Main) Query added in v0.9.0

func (m *Main) Query(index, rawQuery, query string) (string, error)

Query executes a query against the program through the HTTP API.

func (*Main) RecalculateCaches added in v0.9.0

func (m *Main) RecalculateCaches() error

func (*Main) Reopen added in v0.9.0

func (m *Main) Reopen() error

Reopen closes the program and reopens it.

func (*Main) RunWithTransport added in v0.9.0

func (m *Main) RunWithTransport(host string, bindPort int, joinSeeds []string) (seed string, err error)

RunWithTransport runs Main and returns the dynamically allocated gossip port.

func (*Main) URL added in v0.9.0

func (m *Main) URL() string

URL returns the base URL string for accessing the running program.

type MainOpt added in v0.9.0

type MainOpt func(m *Main) error

func OptAntiEntropyInterval added in v0.9.0

func OptAntiEntropyInterval(dur time.Duration) MainOpt

type ModHasher added in v0.5.0

type ModHasher struct{}

ModHasher represents a simple, mod-based hashing.

func NewModHasher added in v0.5.0

func NewModHasher() *ModHasher

NewModHasher returns a new instance of ModHasher with n buckets.

func (*ModHasher) Hash added in v0.5.0

func (*ModHasher) Hash(key uint64, n int) int

type RowAttrStore added in v0.5.0

type RowAttrStore struct {
	// contains filtered or unexported fields
}

RowAttrStore provides simple storage for attributes.

func NewRowAttrStore added in v0.5.0

func NewRowAttrStore() *RowAttrStore

NewRowAttrStore returns a new instance of RowAttrStore.

func (*RowAttrStore) RowAttrs added in v0.5.0

func (s *RowAttrStore) RowAttrs(id uint64) (map[string]interface{}, error)

RowAttrs returns the attributes set to a row id.

func (*RowAttrStore) SetRowAttrs added in v0.5.0

func (s *RowAttrStore) SetRowAttrs(id uint64, m map[string]interface{})

SetRowAttrs assigns a set of attributes to a row id.

type Server added in v0.5.0

type Server struct {
	*httptest.Server
	Handler *Handler
}

Server represents a test wrapper for httptest.Server.

func NewServer added in v0.5.0

func NewServer() *Server

NewServer returns a test server running on a random port.

func (*Server) ClusterStatus added in v0.5.0

func (s *Server) ClusterStatus() (proto.Message, error)

ClusterStatus exists so that test.Server implements StatusHandler.

func (*Server) HandleRemoteStatus added in v0.5.0

func (s *Server) HandleRemoteStatus(pb proto.Message) error

HandleRemoteStatus just need to implement a nop to complete the Interface

func (*Server) Host added in v0.5.0

func (s *Server) Host() string

Host returns the hostname of the running server.

func (*Server) HostURI added in v0.8.0

func (s *Server) HostURI() pilosa.URI

func (*Server) LocalStatus added in v0.5.0

func (s *Server) LocalStatus() (proto.Message, error)

LocalStatus exists so that test.Server implements StatusHandler.

type TestCluster added in v0.9.0

type TestCluster struct {
	Clusters []*pilosa.Cluster
	// contains filtered or unexported fields
}

TestCluster represents a cluster of test nodes, each of which has a pilosa.Cluster.

func NewTestCluster added in v0.9.0

func NewTestCluster(n int) *TestCluster

NewTestCluster returns a new instance of test.Cluster.

func (*TestCluster) AddNode added in v0.9.0

func (t *TestCluster) AddNode(saveTopology bool) error

AddNode adds a node to the cluster and (potentially) starts a resize job.

func (*TestCluster) Close added in v0.9.0

func (t *TestCluster) Close() error

Close closes all clusters in the test cluster.

func (*TestCluster) CreateFrame added in v0.9.0

func (t *TestCluster) CreateFrame(index, frame string, opt pilosa.FrameOptions) error

func (*TestCluster) CreateIndex added in v0.9.0

func (t *TestCluster) CreateIndex(name string) error

func (*TestCluster) FollowResizeInstruction added in v0.9.0

func (t *TestCluster) FollowResizeInstruction(instr *internal.ResizeInstruction) error

FollowResizeInstruction is a version of cluster.FollowResizeInstruction used for testing.

func (*TestCluster) Open added in v0.9.0

func (t *TestCluster) Open() error

Open opens all clusters in the test cluster.

func (*TestCluster) SendAsync added in v0.9.0

func (t *TestCluster) SendAsync(pb proto.Message) error

SendAsync is a test implemenetation of Broadcaster SendAsync method.

func (*TestCluster) SendSync added in v0.9.0

func (t *TestCluster) SendSync(pb proto.Message) error

SendSync is a test implemenetation of Broadcaster SendSync method.

func (*TestCluster) SendTo added in v0.9.0

func (t *TestCluster) SendTo(to *pilosa.Node, pb proto.Message) error

SendTo is a test implemenetation of Broadcaster SendTo method.

func (*TestCluster) SetBit added in v0.9.0

func (t *TestCluster) SetBit(index, frame, view string, rowID, colID uint64, x *time.Time) error

func (*TestCluster) SetFieldValue added in v0.9.0

func (t *TestCluster) SetFieldValue(index, frame string, columnID uint64, name string, value int64) error

func (*TestCluster) SetState added in v0.9.0

func (t *TestCluster) SetState(state string)

SetState sets the state of the cluster on each node.

func (*TestCluster) WriteTopology added in v0.9.0

func (t *TestCluster) WriteTopology(path string, top *pilosa.Topology) error

WriteTopology writes the given topology to disk.

Jump to

Keyboard shortcuts

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