Documentation
¶
Index ¶
- func Bulk(t *testing.T, addr string, docs []string)
- func BulkBuffer(t *testing.T, addr string, b *bytes.Buffer)
- func ChanceValue(prob int, value string) string
- func DocsToStrings(docs []ExampleDoc) []string
- func FetchHTTP(t *testing.T, addr string, ids []string) []*seqproxyapi.Document
- func GenBuffer(docs []string) *bytes.Buffer
- func GenerateDocsJSON(size int, additionalFields bool) [][]byte
- func MergeJSONs(a, b []byte) []byte
- func RandomChanceString(prob, minSize, maxSize int) string
- func RandomDocJSON(sizeScale, addFields int) []byte
- func RandomJSON(size int) string
- func RandomService() string
- func RandomString(minSize, maxSize int) string
- func RandomSymbol() byte
- func RandomText(size int) string
- func RandomWord() string
- func SearchHTTP(t *testing.T, addr string, request *seqproxyapi.SearchRequest) *seqproxyapi.SearchResponse
- type ExampleDoc
- type Ingestor
- type InlineJSON
- type SearchOption
- func NoFetch() SearchOption
- func WithAggQuery(aggQueries ...any) SearchOption
- func WithInterval(interval time.Duration) SearchOption
- func WithOffset(offset int) SearchOption
- func WithOrder(o seq.DocsOrder) SearchOption
- func WithTimeRange(from, to time.Time) SearchOption
- func WithTotal(f bool) SearchOption
- type Stores
- type TestingEnv
- func (t *TestingEnv) Fetch(ids []seq.ID) ([][]byte, error)
- func (t *TestingEnv) Ingestor() *Ingestor
- func (t *TestingEnv) IngestorAddr() string
- func (t *TestingEnv) IngestorBulkAddr() string
- func (t *TestingEnv) IngestorFetchAddr() string
- func (t *TestingEnv) IngestorSearchAddr() string
- func (t *TestingEnv) SealAll()
- func (t *TestingEnv) Search(q string, size int, options ...SearchOption) (*seq.QPR, [][]byte, time.Duration, error)
- func (t *TestingEnv) StopAll()
- func (t *TestingEnv) StopIngestor()
- func (t *TestingEnv) StopStore()
- func (t *TestingEnv) Store(hot bool) *storeapi.Store
- func (t *TestingEnv) WaitIdle()
- type TestingEnvConfig
- func (cfg *TestingEnvConfig) GetColdFactor() int
- func (cfg *TestingEnvConfig) GetColdStoresConfs() []storeapi.StoreConfig
- func (cfg *TestingEnvConfig) GetFracManagerConfig(replicaID string) fracmanager.Config
- func (cfg *TestingEnvConfig) GetHotFactor() int
- func (cfg *TestingEnvConfig) GetHotStoresConfs() []storeapi.StoreConfig
- func (cfg *TestingEnvConfig) GetStoreConfig(replicaID string, cold bool) storeapi.StoreConfig
- func (cfg *TestingEnvConfig) MakeStores(confs []storeapi.StoreConfig, replicas int, s3cli *seqs3.Client) (Stores, [][]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChanceValue ¶
ChanceValue returns given string with probability prob%, or empty string instead
func DocsToStrings ¶
func DocsToStrings(docs []ExampleDoc) []string
func GenerateDocsJSON ¶
GenerateDocsJSON generates random docs straight in json just pass the output to `setup.BulkBytes` to store it faster ~2x if additionalFields=false
func MergeJSONs ¶
func RandomChanceString ¶
RandomChanceString returns random string with probability prob%, or empty string instead
func RandomDocJSON ¶
RandomDocJSON creates random doc and adds to it some additional fields
func RandomJSON ¶
RandomJSON generates json with random string keys and another random json or random string as values
func RandomService ¶
func RandomService() string
func RandomString ¶
RandomString calls common.RandomString it is here, so you could call `setup.RandomSomething`, without exceptions
func RandomSymbol ¶
func RandomSymbol() byte
func RandomText ¶
RandomText generates string with random words and symbols inbetween
func RandomWord ¶
func RandomWord() string
func SearchHTTP ¶
func SearchHTTP(t *testing.T, addr string, request *seqproxyapi.SearchRequest) *seqproxyapi.SearchResponse
Types ¶
type ExampleDoc ¶
type ExampleDoc struct {
Service string `json:"service,omitempty"`
Message string `json:"message,omitempty"`
TraceID string `json:"traceID,omitempty"`
Source string `json:"source,omitempty"`
Zone string `json:"zone,omitempty"`
RequiestObject InlineJSON `json:"requestObject,omitempty"`
Level int `json:"level,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
ExampleDoc is useful for testing and benchmarking instead of hardcoding json docs in code, you can hardcode struct which will be turned in json
func GenerateDocs ¶
func GenerateDocs(size int, generator func(int, *ExampleDoc)) []ExampleDoc
GenerateDocs creates slice of docs and calls generator for each doc to will it with data If timestamp after call is zero, then this function will fill it with deterministic timestamp so you could query each doc by range, if needed
func RandomDoc ¶
func RandomDoc(sizeScale int) *ExampleDoc
type Ingestor ¶
func MakeIngestors ¶
func MakeIngestors(cfg *TestingEnvConfig, hot, cold [][]string) []*Ingestor
type InlineJSON ¶
type InlineJSON string
InlineJSON is a string representing valid json similar as json.RawMessage, but it's a string
func (*InlineJSON) MarshalJSON ¶
func (j *InlineJSON) MarshalJSON() ([]byte, error)
func (*InlineJSON) UnmarshalJSON ¶
func (j *InlineJSON) UnmarshalJSON(v []byte) error
type SearchOption ¶
type SearchOption func(sr *search.SearchRequest)
func NoFetch ¶
func NoFetch() SearchOption
func WithAggQuery ¶
func WithAggQuery(aggQueries ...any) SearchOption
WithAggQuery adds aggregation query to search request. Aggregations parameters are passed as consequent strings of aggregation fields and filters: aggField1, aggFilter1, aggField2, aggFilter2, ..., aggFieldN, aggFilterN.
For example, if two aggregations without filters are needed, this function should be called with args: "agg1", "", "agg2".
If called with single empty string, no aggregation query is added.
func WithInterval ¶
func WithInterval(interval time.Duration) SearchOption
func WithOffset ¶
func WithOffset(offset int) SearchOption
func WithOrder ¶
func WithOrder(o seq.DocsOrder) SearchOption
func WithTimeRange ¶
func WithTimeRange(from, to time.Time) SearchOption
func WithTotal ¶
func WithTotal(f bool) SearchOption
type Stores ¶
func MakeStores ¶
func MakeStores(cfg *TestingEnvConfig, replicas int, cold bool) (Stores, [][]string)
func (Stores) CountInstances ¶
type TestingEnv ¶
type TestingEnv struct {
Ingestors []*Ingestor
HotStores Stores
ColdStores Stores
Config *TestingEnvConfig
// contains filtered or unexported fields
}
func NewTestingEnv ¶
func NewTestingEnv(cfg *TestingEnvConfig) *TestingEnv
func (*TestingEnv) Ingestor ¶
func (t *TestingEnv) Ingestor() *Ingestor
Ingestor returns "random" ingestor managed by TestingEnv but guarantees that each store will return at least once
func (*TestingEnv) IngestorAddr ¶
func (t *TestingEnv) IngestorAddr() string
func (*TestingEnv) IngestorBulkAddr ¶
func (t *TestingEnv) IngestorBulkAddr() string
IngestorBulkAddr returns "random" ingestor HTTP address but guarantees that each store will return at least once
func (*TestingEnv) IngestorFetchAddr ¶
func (t *TestingEnv) IngestorFetchAddr() string
func (*TestingEnv) IngestorSearchAddr ¶
func (t *TestingEnv) IngestorSearchAddr() string
IngestorSearchAddr returns "random" ingestor HTTP address but guarantees that each store will return at least once
func (*TestingEnv) SealAll ¶
func (t *TestingEnv) SealAll()
func (*TestingEnv) Search ¶
func (t *TestingEnv) Search(q string, size int, options ...SearchOption) (*seq.QPR, [][]byte, time.Duration, error)
func (*TestingEnv) StopAll ¶
func (t *TestingEnv) StopAll()
func (*TestingEnv) StopIngestor ¶
func (t *TestingEnv) StopIngestor()
func (*TestingEnv) StopStore ¶
func (t *TestingEnv) StopStore()
func (*TestingEnv) Store ¶
func (t *TestingEnv) Store(hot bool) *storeapi.Store
Store returns random store managed by TestingEnv but guarantees that each store will return at least once
func (*TestingEnv) WaitIdle ¶
func (t *TestingEnv) WaitIdle()
type TestingEnvConfig ¶
type TestingEnvConfig struct {
Name string
DataDir string
IngestorCount int
ColdShards int // number of replicaSets (aka shards)
ColdFactor int // number of replicas in each replicaSet
HotShards int // number of replicaSets (aka shards)
HotFactor int // number of replicas in each replicaSet
HotModeEnabled bool
QueryRateLimit *float64
FracManagerConfig *fracmanager.Config
Mapping seq.Mapping
IndexAllFields bool
S3Cli *seqs3.Client
}
func (*TestingEnvConfig) GetColdFactor ¶
func (cfg *TestingEnvConfig) GetColdFactor() int
func (*TestingEnvConfig) GetColdStoresConfs ¶
func (cfg *TestingEnvConfig) GetColdStoresConfs() []storeapi.StoreConfig
func (*TestingEnvConfig) GetFracManagerConfig ¶
func (cfg *TestingEnvConfig) GetFracManagerConfig(replicaID string) fracmanager.Config
func (*TestingEnvConfig) GetHotFactor ¶
func (cfg *TestingEnvConfig) GetHotFactor() int
func (*TestingEnvConfig) GetHotStoresConfs ¶
func (cfg *TestingEnvConfig) GetHotStoresConfs() []storeapi.StoreConfig
func (*TestingEnvConfig) GetStoreConfig ¶
func (cfg *TestingEnvConfig) GetStoreConfig(replicaID string, cold bool) storeapi.StoreConfig
func (*TestingEnvConfig) MakeStores ¶
func (cfg *TestingEnvConfig) MakeStores( confs []storeapi.StoreConfig, replicas int, s3cli *seqs3.Client, ) (Stores, [][]string)