test

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SliceWidth = pilosa.SliceWidth

SliceWidth is a helper reference to use when testing.

Variables

View Source
var (
	Network = flag.String("network", "tcp", "network name")
)

Test flags.

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 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 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 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 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 MustOpenAttrStore added in v0.5.0

func MustOpenAttrStore() *AttrStore

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

func NewAttrStore added in v0.5.0

func NewAttrStore() *AttrStore

NewAttrStore returns a new instance of AttrStore.

func (*AttrStore) Close added in v0.5.0

func (s *AttrStore) Close() error

Close closes the database and removes the underlying data.

type Client added in v0.5.0

type Client struct {
	*pilosa.Client
}

Client represents a test wrapper for pilosa.Client.

func MustNewClient added in v0.5.0

func MustNewClient(host string) *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 hostname of the first cluster node.

type Fragment added in v0.5.0

type Fragment struct {
	*pilosa.Fragment
	RowAttrStore *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
	LogOutput bytes.Buffer
}

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 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 returns the NodeState for all nodes in the cluster.

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) LocalStatus added in v0.5.0

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

LocalStatus returns the state of the local node as well as the holder (indexes/frames) according to the local node.

Jump to

Keyboard shortcuts

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