Documentation
¶
Overview ¶
Package elastictest is a fake Elasticsearch 8 / OpenSearch 2 for the tests of the packages that open an Elasticsearch source (the session, the engine through it): an http.Handler over in-memory documents that answers the requests locklog sends (the root, the privilege checks, _resolve/index, _field_caps, _mapping, _settings, _count and _search with bool filters, sort, search_after and the two aggregation kinds), behind basic or API-key authentication unless Open.
The elastic package's own tests have a richer fake of their own; this one only needs to be faithful to the subset a session reads.
Index ¶
Constants ¶
const ReadOnlyGrants = `` /* 175-byte string literal not displayed */
ReadOnlyGrants is the _privileges answer of a read-only role on logs-* (shape recorded from Elasticsearch 8.15).
const WriteGrants = `` /* 183-byte string literal not displayed */
WriteGrants holds a write privilege on the source's indices.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doc ¶
Doc is one document: its index, id, time, and flat keyword fields (and the message), each a string or a []string.
type Server ¶
type Server struct {
// Pattern is the index segment the source names (default "logs-*").
Pattern string
// Indices are the concrete indices the pattern resolves to (default
// logs-a, logs-b).
Indices []string
Docs []Doc
// OpenSearch answers as OpenSearch 2 (authinfo, no _privileges).
OpenSearch bool
// Grants is the Elasticsearch _privileges answer (default
// ReadOnlyGrants); Roles the OpenSearch roles of the user.
Grants string
Roles []string
// Types are the mapped fields and their types (default: @timestamp
// date, message text, every other field of a document keyword).
Types map[string]string
// User and Password, or APIKey (the encoded key), authenticate a
// request; Open serves every request without credentials.
User, Password, APIKey string
Open bool
// contains filtered or unexported fields
}
Server is the fake. Set its fields before serving.