test

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckClusterState added in v2.1.2

func CheckClusterState(m *Command, state string, n int) bool

CheckClusterState polls a given cluster for its state until it receives a matching state. It polls up to n times before returning.

func CheckGroupBy

func CheckGroupBy(t *testing.T, expected, results []pilosa.GroupCount)

func CompareTransactions

func CompareTransactions(t *testing.T, trns1, trns2 *pilosa.Transaction)

CompareTransactions errors describing how the transactions differ (if at all). The deadlines need only be close (within deadlineSkew).

func Do

func Do(t testing.TB, method, urlStr string, body string) *httpResponse

Do executes http.Do() with an http.NewRequest().

func MustMarshalJSON

func MustMarshalJSON(v interface{}) []byte

MustMarshalJSON marshals v to JSON. Panic on error.

func MustNewHTTPRequest

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

MustNewHTTPRequest creates a new HTTP request. Panic on error.

func NewBufferLogger

func NewBufferLogger() *bufferLogger

NewBufferLogger returns a new instance of BufferLogger.

func OptAllowedOrigins

func OptAllowedOrigins(origins []string) server.CommandOption

func OptTxSrc added in v2.8.0

func OptTxSrc(src string) server.CommandOption

func RetryUntil

func RetryUntil(timeout time.Duration, fn func() error) (err error)

RetryUntil repeatedly executes fn until it returns nil or timeout occurs.

func TestField_SetCacheSize

func TestField_SetCacheSize(t *testing.T)

Ensure field can set its cache

Types

type Cluster

type Cluster struct {
	Nodes []*Command
}

Cluster represents a Pilosa cluster (multiple Command instances)

func MustNewCluster

func MustNewCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster

MustNewCluster creates a new cluster. If opts contains only one slice of command options, those options are used with every node. If it is empty, default options are used. Otherwise, it must contain size slices of command options, which are used with corresponding nodes.

func MustRunCluster

func MustRunCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster

MustRunCluster creates and starts a new cluster. The opts parameter is slightly magical; see MustNewCluster.

func (*Cluster) AwaitCoordinatorState added in v2.1.2

func (c *Cluster) AwaitCoordinatorState(expectedState string, timeout time.Duration) error

AwaitState waits for the cluster coordinator (assumed to be the first node) to reach a specified state.

func (*Cluster) AwaitState added in v2.1.2

func (c *Cluster) AwaitState(expectedState string, timeout time.Duration) (err error)

AwaitState waits for the whole cluster to reach a specified state.

func (*Cluster) Close

func (c *Cluster) Close() error

Stop stops a Cluster

func (*Cluster) CloseAndRemove added in v2.2.0

func (c *Cluster) CloseAndRemove(n int) error

func (*Cluster) CreateField

func (c *Cluster) CreateField(t testing.TB, index string, iopts pilosa.IndexOptions, field string, fopts ...pilosa.FieldOption) *pilosa.Field

CreateField creates the index (if necessary) and field specified.

func (*Cluster) ExceptionalState added in v2.1.2

func (c *Cluster) ExceptionalState(expectedState string) error

ExceptionalState returns an error if any node in the cluster is not in the expected state.

func (*Cluster) GetHolder added in v2.2.0

func (c *Cluster) GetHolder(n int) *Holder

func (*Cluster) GetNode added in v2.2.0

func (c *Cluster) GetNode(n int) *Command

func (*Cluster) ImportBits

func (c *Cluster) ImportBits(t testing.TB, index, field string, rowcols [][2]uint64)

func (*Cluster) ImportIDKey added in v2.7.0

func (c *Cluster) ImportIDKey(t testing.TB, index, field string, pairs []KeyID)

ImportIDKey imports data into an unkeyed set field in a keyed index.

func (*Cluster) ImportIntID added in v2.8.0

func (c *Cluster) ImportIntID(t testing.TB, index, field string, pairs []IntID)

ImportIntID imports data into an int field in an unkeyed index.

func (*Cluster) ImportIntKey added in v2.7.0

func (c *Cluster) ImportIntKey(t testing.TB, index, field string, pairs []IntKey)

ImportIntKey imports int data into an index which uses string keys.

func (*Cluster) ImportKeyKey added in v2.7.0

func (c *Cluster) ImportKeyKey(t testing.TB, index, field string, valAndRecKeys [][2]string)

ImportKeyKey imports data into an index where both the index and the field are using string keys.

func (*Cluster) ImportTimeQuantumKey added in v2.8.0

func (c *Cluster) ImportTimeQuantumKey(t testing.TB, index, field string, entries []TimeQuantumKey)

ImportTimeQuantumKey imports data into an index where the index is keyd and the field is a time-quantum

func (*Cluster) Len added in v2.2.0

func (c *Cluster) Len() int

func (*Cluster) Query

func (c *Cluster) Query(t testing.TB, index, query string) pilosa.QueryResponse

Query executes an API.Query through one of the cluster's node's API. It fails the test if there is an error.

func (*Cluster) QueryGRPC added in v2.7.0

func (c *Cluster) QueryGRPC(t testing.TB, index, query string) *proto.TableResponse

QueryGRPC executes a PQL query through the GRPC endpoint. It fails the test if there is an error.

func (*Cluster) QueryHTTP added in v2.7.0

func (c *Cluster) QueryHTTP(t testing.TB, index, query string) (string, error)

QueryHTTP executes a PQL query through the HTTP endpoint. It fails the test for explicit errors, but returns an error which has the response body if the HTTP call returns a non-OK status.

func (*Cluster) Start

func (c *Cluster) Start() error

Start runs a Cluster

type Command

type Command struct {
	*server.Command
	// contains filtered or unexported fields
}

////////////////////////////////////////////////////////////////////////////////// Command represents a test wrapper for server.Command.

func NewCommandNode

func NewCommandNode(tb testing.TB, isCoordinator bool, opts ...server.CommandOption) *Command

NewCommandNode returns a new instance of Command with clustering enabled.

func RunCommand

func RunCommand(t *testing.T) *Command

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

func (*Command) Client

func (m *Command) Client() *http.InternalClient

Client returns a client to connect to the program.

func (*Command) Close

func (m *Command) Close() error

Close closes the program and removes the underlying data directory.

func (*Command) GossipAddress

func (m *Command) GossipAddress() string

GossipAddress returns the address on which gossip is listening after a Main has been setup. Useful to pass as a seed to other nodes when creating and testing clusters.

func (*Command) ID added in v2.1.2

func (m *Command) ID() string

ID returns the node ID used by the running program.

func (*Command) MustCreateField

func (m *Command) MustCreateField(tb testing.TB, index, field string, opts ...pilosa.FieldOption) *pilosa.Field

MustCreateField uses this command's API to create the field. The index must already exist - it fails the test if there is an error.

func (*Command) MustCreateIndex

func (m *Command) MustCreateIndex(tb testing.TB, name string, opts pilosa.IndexOptions) *pilosa.Index

MustCreateIndex uses this command's API to create an index and fails the test if there is an error.

func (*Command) Query

func (m *Command) Query(t testing.TB, index, rawQuery, query string) (string, error)

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

func (*Command) QueryAPI

func (m *Command) QueryAPI(tb testing.TB, req *pilosa.QueryRequest) pilosa.QueryResponse

QueryAPI uses this command's API to execute the given query request, failing if Query returns a non-nil error, otherwise returning the QueryResponse.

func (*Command) QueryExpect added in v2.1.2

func (m *Command) QueryExpect(t *testing.T, index, rawQuery, query string, expected string)

QueryExpect executes a query against the program through the HTTP API, and confirms that it got an expected response.

func (*Command) QueryProtobuf

func (m *Command) QueryProtobuf(indexName string, query string) (*pilosa.QueryResponse, error)

func (*Command) Queryf added in v2.1.2

func (m *Command) Queryf(t *testing.T, index, rawQuery, query string, params ...interface{}) (string, error)

Queryf is like Query, but with a format string.

func (*Command) RecalculateCaches

func (m *Command) RecalculateCaches(t *testing.T) error

RecalculateCaches is deprecated. Use MustRecalculateCaches.

func (*Command) Reopen

func (m *Command) Reopen() error

Reopen closes the program and reopens it.

func (*Command) SoftOpen

func (m *Command) SoftOpen() error

SoftOpen is like Reopen, but doesn't close the program first. This is useful in the case where a test needs to decouple the close from the re-open (for example, there may need to be actions which take place between those two steps).

func (*Command) URL

func (m *Command) URL() string

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

type Field

type Field struct {
	*pilosa.Field
}

Field represents a test wrapper for pilosa.Field.

type Holder

type Holder struct {
	*pilosa.Holder
}

Holder is a test wrapper for pilosa.Holder.

func MustOpenHolder

func MustOpenHolder(tb testing.TB) *Holder

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

func NewHolder

func NewHolder(tb testing.TB) *Holder

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

func (*Holder) ClearBit

func (h *Holder) ClearBit(index, field string, rowID, columnID uint64)

ClearBit clears a bit on the given field.

func (*Holder) Close

func (h *Holder) Close() error

Close closes the holder. The data should be removed by the

func (*Holder) MustCreateIndexIfNotExists

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

MustCreateIndexIfNotExists returns a given index. Panic on error.

func (*Holder) MustSetBits

func (h *Holder) MustSetBits(index, field string, rowID uint64, columnIDs ...uint64)

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

func (*Holder) Range

func (h *Holder) Range(index, field string, op pql.Token, predicate int64) *pilosa.Row

Range returns a Row (of column IDs) for a field based on the given range.

func (*Holder) ReadRow

func (h *Holder) ReadRow(index, field string, rowID uint64) *pilosa.Row

ReadRow returns a Row for a given field. If the field does not exist, it panics rather than creating the field.

func (*Holder) Reopen

func (h *Holder) Reopen() error

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

func (*Holder) Row

func (h *Holder) Row(index, field string, rowID uint64) *pilosa.Row

Row returns a Row for a given field.

func (*Holder) RowAttrStore

func (h *Holder) RowAttrStore(index, field string) pilosa.AttrStore

func (*Holder) RowTime

func (h *Holder) RowTime(index, field string, rowID uint64, t time.Time, quantum string) *pilosa.Row

func (*Holder) SetBit

func (h *Holder) SetBit(index, field string, rowID, columnID uint64)

SetBit sets a bit on the given field.

func (*Holder) SetBitTime

func (h *Holder) SetBitTime(index, field string, rowID, columnID uint64, t *time.Time)

SetBitTime sets a bit with timestamp on the given field.

func (*Holder) SetValue

func (h *Holder) SetValue(index, field string, columnID uint64, value int64) *Index

SetValue sets an integer value on the given field.

func (*Holder) Value

func (h *Holder) Value(index, field string, columnID uint64) (int64, bool)

Value returns the integer value for a given column.

type Index

type Index struct {
	*pilosa.Index
}

Index represents a test wrapper for pilosa.Index.

func MustOpenIndex

func MustOpenIndex(tb testing.TB) *Index

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

func (*Index) Close

func (i *Index) Close() error

Close closes the index and removes the underlying data.

func (*Index) CreateField

func (i *Index) CreateField(name string, opts ...pilosa.FieldOption) (*Field, error)

CreateField creates a field with the given options.

func (*Index) CreateFieldIfNotExists

func (i *Index) CreateFieldIfNotExists(name string, opts ...pilosa.FieldOption) (*Field, error)

CreateFieldIfNotExists creates a field with the given options if it doesn't exist.

func (*Index) Reopen

func (i *Index) Reopen() error

Reopen closes the index and reopens it.

type IntID added in v2.8.0

type IntID struct {
	Val int64
	ID  uint64
}

type IntKey added in v2.7.0

type IntKey struct {
	Val int64
	Key string
}

IntKey is a string key and a signed integer value.

type KeyID added in v2.7.0

type KeyID struct {
	Key string
	ID  uint64
}

KeyID represents a key and an ID for importing data into an index and field where one uses string keys and the other does not.

type ModHasher

type ModHasher struct{}

modHasher represents a simple, mod-based hashing.

func (*ModHasher) Hash

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

func (*ModHasher) Name added in v2.3.0

func (*ModHasher) Name() string

type TimeQuantumKey added in v2.8.0

type TimeQuantumKey struct {
	RowKey string
	ColKey string
	Ts     int64
}

TimeQuantumKey is a string key and a string+key value

Jump to

Keyboard shortcuts

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