Documentation
¶
Overview ¶
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2021 Molecula Corp. All rights reserved.
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0
Index ¶
- func CheckGroupBy(t *testing.T, expected, results []pilosa.GroupCount)
- func CheckGroupByOnKey(t *testing.T, expected, results []pilosa.GroupCount)
- func CompareTransactions(t *testing.T, trns1, trns2 *pilosa.Transaction)
- func Do(t testing.TB, method, urlStr string, body string) *httpResponse
- func DoProto(t testing.TB, method, urlStr string, body []byte) *gohttp.Response
- func GetPortsGenConfigs(tb DirCleaner, nodes []*Command) error
- func MustMarshalJSON(v interface{}) []byte
- func MustNewHTTPRequest(method, urlStr string, body io.Reader) *gohttp.Request
- func MustOpenIndex(tb testing.TB) (*Holder, *Index)
- func NewWholeTestRun(tb testing.TB) *wholeTestRunWrapper
- func OptAllowedOrigins(origins []string) server.CommandOption
- func RetryUntil(timeout time.Duration, fn func() error) (err error)
- type Cluster
- func MustNewCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster
- func MustRunCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster
- func MustRunUnsharedCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster
- func MustUnsharedCluster(tb testing.TB, size int, opts ...[]server.CommandOption) *Cluster
- type Command
- func (m *Command) AssertState(t testing.TB, expectedState disco.ClusterState, timeout time.Duration)
- func (m *Command) AwaitState(expectedState disco.ClusterState, timeout time.Duration) (err error)
- func (m *Command) Client() *pilosa.InternalClient
- func (m *Command) Close() error
- func (m *Command) ID() string
- func (m *Command) IsPrimary() bool
- func (m *Command) MustCreateField(tb testing.TB, index, field string, opts ...pilosa.FieldOption) *pilosa.Field
- func (m *Command) MustCreateIndex(tb testing.TB, name string, opts pilosa.IndexOptions) *pilosa.Index
- func (m *Command) Query(t testing.TB, index, rawQuery, query string) (string, error)
- func (m *Command) QueryAPI(tb testing.TB, req *pilosa.QueryRequest) pilosa.QueryResponse
- func (m *Command) QueryExpect(t *testing.T, index, rawQuery, query string, expected string)
- func (m *Command) QueryProtobuf(indexName string, query string) (*pilosa.QueryResponse, error)
- func (m *Command) Queryf(t *testing.T, index, rawQuery, query string, params ...interface{}) (string, error)
- func (m *Command) RecalculateCaches(t *testing.T) error
- func (m *Command) Reopen() error
- func (m *Command) URL() string
- type DirCleaner
- type Field
- type Holder
- func (h *Holder) ClearBit(index, field string, rowID, columnID uint64)
- func (h *Holder) Close() error
- func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOptions) *Index
- func (h *Holder) MustSetBits(index, field string, rowID uint64, columnIDs ...uint64)
- func (h *Holder) Range(index, field string, op pql.Token, predicate int64) *pilosa.Row
- func (h *Holder) ReadRow(index, field string, rowID uint64) *pilosa.Row
- func (h *Holder) Reopen() error
- func (h *Holder) Row(index, field string, rowID uint64) *pilosa.Row
- func (h *Holder) RowTime(index, field string, rowID uint64, t time.Time, quantum string) *pilosa.Row
- func (h *Holder) SetBit(index, field string, rowID, columnID uint64)
- func (h *Holder) SetBitTime(index, field string, rowID, columnID uint64, t *time.Time)
- func (h *Holder) SetValue(index, field string, columnID uint64, value int64) *Index
- func (h *Holder) Value(index, field string, columnID uint64) (int64, bool)
- type Index
- type IntID
- type IntKey
- type KeyID
- type Ports
- type ShareableCluster
- func (c *ShareableCluster) AwaitPrimaryState(expectedState disco.ClusterState, timeout time.Duration) error
- func (c *ShareableCluster) AwaitState(expectedState disco.ClusterState, timeout time.Duration) (err error)
- func (c *ShareableCluster) Close() error
- func (c *ShareableCluster) CloseAndRemove(n int) error
- func (c *ShareableCluster) CloseAndRemoveNonPrimary() error
- func (c *ShareableCluster) CreateField(t testing.TB, index string, iopts pilosa.IndexOptions, field string, ...) *pilosa.Field
- func (c *ShareableCluster) ExceptionalState(expectedState disco.ClusterState) error
- func (c *ShareableCluster) GetHolder(n int) *Holder
- func (c *ShareableCluster) GetIdleNode(n int) *Command
- func (c *ShareableCluster) GetNode(n int) *Command
- func (c *ShareableCluster) GetNonPrimaries() []*Command
- func (c *ShareableCluster) GetNonPrimary() *Command
- func (c *ShareableCluster) GetPrimary() *Command
- func (c *ShareableCluster) ImportBits(t testing.TB, index, field string, rowcols [][2]uint64)
- func (c *ShareableCluster) ImportBitsWithTimestamp(t testing.TB, index, field string, rowcols [][2]uint64, timestamps []int64)
- func (c *ShareableCluster) ImportIDKey(t testing.TB, index, field string, pairs []KeyID)
- func (c *ShareableCluster) ImportIntID(t testing.TB, index, field string, pairs []IntID)
- func (c *ShareableCluster) ImportIntKey(t testing.TB, index, field string, pairs []IntKey)
- func (c *ShareableCluster) ImportKeyKey(t testing.TB, index, field string, valAndRecKeys [][2]string)
- func (c *ShareableCluster) ImportTimeQuantumKey(t testing.TB, index, field string, entries []TimeQuantumKey)
- func (c *ShareableCluster) Len() int
- func (c *ShareableCluster) Query(t testing.TB, index, query string) pilosa.QueryResponse
- func (c *ShareableCluster) QueryGRPC(t testing.TB, index, query string) *proto.TableResponse
- func (c *ShareableCluster) QueryHTTP(t testing.TB, index, query string) (string, error)
- func (c *ShareableCluster) Start() error
- type TimeQuantumKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckGroupBy ¶
func CheckGroupBy(t *testing.T, expected, results []pilosa.GroupCount)
func CheckGroupByOnKey ¶
func CheckGroupByOnKey(t *testing.T, expected, results []pilosa.GroupCount)
CheckGroupByOnKey is like CheckGroupBy, but it doen't enforce a match on the GroupBy.Group.RowID value. In cases where the Group has a RowKey, then the value of RowID is not consistently assigned. Instead, it depends on the order of key translation IDs based on shard allocation to the
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 GetPortsGenConfigs ¶
func GetPortsGenConfigs(tb DirCleaner, nodes []*Command) error
GetPortsGenConfigs generates etcd configs for a number of nodes, including cross-references so that every node gets an initial cluster list pointing it at the other nodes, and modifies the configs of the provided Command objects to point to these etcd configs. It uses etcd.GenEtcdConfigs, which in turn creates temporary directories and the like.
func MustMarshalJSON ¶
func MustMarshalJSON(v interface{}) []byte
MustMarshalJSON marshals v to JSON. Panic on error.
func MustNewHTTPRequest ¶
MustNewHTTPRequest creates a new HTTP request. Panic on error.
func MustOpenIndex ¶
MustOpenIndex returns a new, opened index at a temporary path, or fails the test. It also returns the holder containing the index.
func NewWholeTestRun ¶
NewWholeTestRun produces a wholeTestRunWrapper around TB, which overrides a couple of the TB's methods to get whole-test-friendly behaviors.
func OptAllowedOrigins ¶
func OptAllowedOrigins(origins []string) server.CommandOption
Types ¶
type Cluster ¶
type Cluster struct { // contains filtered or unexported fields }
Cluster represents a per-test wrapper of a "real" cluster. Individual tests which request a cluster can get one of these back, wrapped with their test name.
func MustNewCluster ¶
MustNewCluster creates a new cluster or returns an existing one. It never shares a cluster with non-empty opts. 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 ¶
MustRunCluster creates and starts a new cluster. The opts parameter is slightly magical; see MustNewCluster.
func MustRunUnsharedCluster ¶
MustRunUnsharedCluster 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. The new cluster is always unshared. The new cluster is started automatically, or the test is failed.
func MustUnsharedCluster ¶
MustUnsharedCluster 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. The new cluster is always unshared.
func (*Cluster) Format ¶
Format implements Formatter, allowing us to use clusters in format strings to handle the extremely common problem of "I want to embed the index name in this here string". Because we are horrible criminals, we append the rune, so you can use %i and %j to get index-name-plus-i and index-name-plus-j, respectively. We do assume that the rune works as a plain byte, though.
type Command ¶
Command represents a test wrapper for server.Command.
func NewCommandNode ¶
func NewCommandNode(tb DirCleaner, opts ...server.CommandOption) *Command
NewCommandNode returns a new instance of Command with clustering enabled.
func RunCommand ¶
RunCommand returns a new, running Main. Panic on error.
func (*Command) AssertState ¶
func (m *Command) AssertState(t testing.TB, expectedState disco.ClusterState, timeout time.Duration)
AssertState waits for the whole cluster to reach a specified state, or fails the calling test if it can't.
func (*Command) AwaitState ¶
AwaitState waits for the whole cluster to reach a specified state.
func (*Command) Client ¶
func (m *Command) Client() *pilosa.InternalClient
Client returns a client to connect to the 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) 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 ¶
QueryExpect executes a query against the program through the HTTP API, and confirms that it got an expected response.
func (*Command) QueryProtobuf ¶
func (*Command) Queryf ¶
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 ¶
RecalculateCaches is deprecated. Use MustRecalculateCaches.
type DirCleaner ¶
type DirCleaner interface { Helper() Errorf(string, ...interface{}) Fatalf(string, ...interface{}) Fatal(...interface{}) Logf(string, ...interface{}) Name() string TempDir() string Cleanup(func()) Skip(...interface{}) }
DirCleaner represents the subset of the testing.TB interface we care about, allowing us to take objects which behave like that without importing all of testing to get them.
type Holder ¶
Holder is a test wrapper for pilosa.Holder.
func MustOpenHolder ¶
MustOpenHolder creates and opens a holder at a temporary path. Panic on error.
func (*Holder) Close ¶
Close closes the holder. The data should be removed by the cleanup registered when we created the initial tempdir.
func (*Holder) MustCreateIndexIfNotExists ¶
func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOptions) *Index
MustCreateIndexIfNotExists returns a given index. Panic on error.
func (*Holder) MustSetBits ¶
MustSetBits sets columns on a row. Panic on error. This function does not accept a timestamp or quantum.
func (*Holder) ReadRow ¶
ReadRow returns a Row for a given field. If the field does not exist, it fails the holder's test rather than creating the field.
func (*Holder) Reopen ¶
Reopen instantiates and opens a new holder. Note that the holder must be Closed first.
func (*Holder) SetBitTime ¶
SetBitTime sets a bit with timestamp on the given field.
type Index ¶
Index represents a test wrapper for pilosa.Index.
func (*Index) CreateField ¶
func (i *Index) CreateField(name string, requestUserID string, opts ...pilosa.FieldOption) (*Field, error)
CreateField creates a field with the given options.
func (*Index) CreateFieldIfNotExists ¶
func (i *Index) CreateFieldIfNotExists(name string, requestUserID string, opts ...pilosa.FieldOption) (*Field, error)
CreateFieldIfNotExists creates a field with the given options if it doesn't exist.
type KeyID ¶
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 Ports ¶
type Ports struct { LsnC *net.TCPListener PortC int LsnP *net.TCPListener PortP int LsnG *net.TCPListener Grpc int }
type ShareableCluster ¶
type ShareableCluster struct { // contains filtered or unexported fields }
ShareableCluster represents a featurebase cluster (multiple Command instances) without test-specific overhead.
func (*ShareableCluster) AwaitPrimaryState ¶
func (c *ShareableCluster) AwaitPrimaryState(expectedState disco.ClusterState, timeout time.Duration) error
AwaitPrimaryState waits for the cluster primary to reach a specified cluster state. When this happens, we know etcd reached a combination of node states that would imply this cluster state, but some nodes may not have caught up yet; we just test that the coordinator thought the cluster was in the given state.
func (*ShareableCluster) AwaitState ¶
func (c *ShareableCluster) AwaitState(expectedState disco.ClusterState, timeout time.Duration) (err error)
AwaitState waits for the whole cluster to reach a specified state.
func (*ShareableCluster) CloseAndRemove ¶
func (c *ShareableCluster) CloseAndRemove(n int) error
func (*ShareableCluster) CloseAndRemoveNonPrimary ¶
func (c *ShareableCluster) CloseAndRemoveNonPrimary() error
func (*ShareableCluster) CreateField ¶
func (c *ShareableCluster) 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 (*ShareableCluster) ExceptionalState ¶
func (c *ShareableCluster) ExceptionalState(expectedState disco.ClusterState) error
ExceptionalState returns an error if any node in the cluster is not in the expected state.
func (*ShareableCluster) GetHolder ¶
func (c *ShareableCluster) GetHolder(n int) *Holder
func (*ShareableCluster) GetIdleNode ¶
func (c *ShareableCluster) GetIdleNode(n int) *Command
GetIdleNode gets the node at the given index. This method is used (instead of `GetNode()`) when the cluster has yet to be started. In that case, etcd has not assigned each node an ID, and therefore the nodes are not in their final, sorted order. In other words, this method can only be used to retrieve a node when order doesn't matter. An example is if you need to do something like this:
c.GetNode(0).Config.Cluster.ReplicaN = 2 c.GetNode(1).Config.Cluster.ReplicaN = 2
In this example, the test needs the replication factor to be set to 2 before starting; it's ok to reference each node by its index in the pre-sorted node list. It's also safe to use this method after `MustRunCluster()` if the cluster contains only one node.
func (*ShareableCluster) GetNode ¶
func (c *ShareableCluster) GetNode(n int) *Command
GetNode gets the node at the given index; this method assumes the cluster has already been started. Because the node IDs are assigned randomly, they can be in an order that does not align with the test's expectations. For example, a test might create a 3-node cluster and retrieve them using `GetNode(0)`, `GetNode(1)`, and `GetNode(2)` respectively. But if the node IDs are `456`, `123`, `789`, then we actually want `GetNode(0)` to return `c.Nodes[1]`, and `GetNode(1)` to return `c.Nodes[0]`. This method looks at all the node IDs, sorts them, and then returns the node that the test expects.
func (*ShareableCluster) GetNonPrimaries ¶
func (c *ShareableCluster) GetNonPrimaries() []*Command
GetNonPrimaries gets all nodes except the primary.
func (*ShareableCluster) GetNonPrimary ¶
func (c *ShareableCluster) GetNonPrimary() *Command
GetNonPrimary gets first first non-primary node in the list of nodes.
func (*ShareableCluster) GetPrimary ¶
func (c *ShareableCluster) GetPrimary() *Command
GetPrimary gets the node which has been determined to be the primary. This used to be node0 in tests, but since implementing etcd, the primary can be any node in the cluster, so we have to use this method in tests which need to act on the primary.
func (*ShareableCluster) ImportBits ¶
func (c *ShareableCluster) ImportBits(t testing.TB, index, field string, rowcols [][2]uint64)
func (*ShareableCluster) ImportBitsWithTimestamp ¶
func (*ShareableCluster) ImportIDKey ¶
func (c *ShareableCluster) ImportIDKey(t testing.TB, index, field string, pairs []KeyID)
ImportIDKey imports data into an unkeyed set field in a keyed index.
func (*ShareableCluster) ImportIntID ¶
func (c *ShareableCluster) ImportIntID(t testing.TB, index, field string, pairs []IntID)
ImportIntID imports data into an int field in an unkeyed index.
func (*ShareableCluster) ImportIntKey ¶
func (c *ShareableCluster) ImportIntKey(t testing.TB, index, field string, pairs []IntKey)
ImportIntKey imports int data into an index which uses string keys.
func (*ShareableCluster) ImportKeyKey ¶
func (c *ShareableCluster) 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 (*ShareableCluster) ImportTimeQuantumKey ¶
func (c *ShareableCluster) 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 (*ShareableCluster) Len ¶
func (c *ShareableCluster) Len() int
func (*ShareableCluster) Query ¶
func (c *ShareableCluster) 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 (*ShareableCluster) QueryGRPC ¶
func (c *ShareableCluster) 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.
type TimeQuantumKey ¶
TimeQuantumKey is a string key and a string+key value