Documentation
¶
Overview ¶
Package testenv configures and controls the local integration services.
Index ¶
- Constants
- func CloseElasticsearch(client *goelasticsearch.TypedClient)
- func CloseLDAP(connection *ldapv3.Conn)
- func CloseMongo(client *mongodriver.Client) error
- func OpenElasticsearch(config ElasticsearchConfig) (*goelasticsearch.TypedClient, error)
- func OpenLDAP(config LDAPConfig) (*ldapv3.Conn, error)
- func OpenMongo(config MongoConfig) (*mongodriver.Client, error)
- func OpenSQL(config SQLConfig) (*sql.DB, error)
- func QueryElasticsearchIDs(ctx context.Context, client *goelasticsearch.TypedClient, ...) ([]string, error)
- func QueryLDAPDNs(ctx context.Context, config LDAPConfig, baseDN string, filter string) ([]string, error)
- func QueryLDAPIDs(ctx context.Context, config LDAPConfig, baseDN string, filter string) ([]string, error)
- func QueryMongoIDs(ctx context.Context, collection *mongodriver.Collection, filter bson.D) ([]string, error)
- func QuerySQLRecords(ctx context.Context, database *sql.DB) ([]fixture.SQLRecord, error)
- func ResetElasticsearch(ctx context.Context, client *goelasticsearch.TypedClient, ...) error
- func ResetLDAP(connection *ldapv3.Conn) error
- func ResetMongo(ctx context.Context, database *mongodriver.Database) error
- func ResetSQL(ctx context.Context, database *sql.DB, repositoryRoot string, backend Backend) error
- func SetElasticsearchExpensiveQueries(ctx context.Context, client *goelasticsearch.TypedClient, ...) error
- func VerifyElasticsearchIndexContract(ctx context.Context, client *goelasticsearch.TypedClient, ...) error
- func WaitForElasticsearch(ctx context.Context, client *goelasticsearch.TypedClient, ...) error
- func WaitForLDAP(ctx context.Context, config LDAPConfig, interval time.Duration) (*ldapv3.Conn, error)
- func WaitForMongo(ctx context.Context, client *mongodriver.Client, interval time.Duration) error
- func WaitForSQL(ctx context.Context, backend Backend, database *sql.DB, interval time.Duration) error
- type Backend
- type ElasticsearchConfig
- type ElasticsearchServerInfo
- type LDAPConfig
- type LDAPServerInfo
- type MongoConfig
- type MongoServerInfo
- type SQLConfig
Constants ¶
const (
// OpenLDAPVersion is the exact server version pinned by compose.yaml.
OpenLDAPVersion = "2.6.10"
)
Variables ¶
This section is empty.
Functions ¶
func CloseElasticsearch ¶
func CloseElasticsearch(client *goelasticsearch.TypedClient)
CloseElasticsearch releases idle HTTP connections held by the typed client.
func CloseMongo ¶
func CloseMongo(client *mongodriver.Client) error
CloseMongo disconnects a Client with a fresh finite cleanup context.
func OpenElasticsearch ¶
func OpenElasticsearch( config ElasticsearchConfig, ) (*goelasticsearch.TypedClient, error)
OpenElasticsearch creates the official typed client without contacting the server. Use WaitForElasticsearch for readiness and exact version checks.
func OpenLDAP ¶
func OpenLDAP(config LDAPConfig) (*ldapv3.Conn, error)
OpenLDAP establishes and binds one finite-timeout connection. Driver errors are deliberately omitted so credentials and connection details cannot leak.
func OpenMongo ¶
func OpenMongo(config MongoConfig) (*mongodriver.Client, error)
OpenMongo creates an official-driver Client without contacting the server. Use WaitForMongo for authenticated readiness.
func OpenSQL ¶
OpenSQL creates a database/sql handle with the public MySQL or pgx driver API. It does not contact the service; use WaitForSQL for readiness.
func QueryElasticsearchIDs ¶
func QueryElasticsearchIDs( ctx context.Context, client *goelasticsearch.TypedClient, config ElasticsearchConfig, query elasticsearch.Query, ) ([]string, error)
QueryElasticsearchIDs executes one compiled typed Query and returns stable hit IDs. Query text and response bodies are omitted from errors.
func QueryLDAPDNs ¶
func QueryLDAPDNs( ctx context.Context, config LDAPConfig, baseDN string, filter string, ) ([]string, error)
QueryLDAPDNs executes a filter below baseDN and returns sorted entry DNs.
func QueryLDAPIDs ¶
func QueryLDAPIDs( ctx context.Context, config LDAPConfig, baseDN string, filter string, ) ([]string, error)
QueryLDAPIDs executes a filter below baseDN and returns stable record IDs in sorted order. Errors never include the filter, values, bind identity, or credentials.
func QueryMongoIDs ¶
func QueryMongoIDs( ctx context.Context, collection *mongodriver.Collection, filter bson.D, ) ([]string, error)
QueryMongoIDs returns string _id values in deterministic order.
func QuerySQLRecords ¶
QuerySQLRecords reads the stable fixture in deterministic ID order.
func ResetElasticsearch ¶
func ResetElasticsearch( ctx context.Context, client *goelasticsearch.TypedClient, config ElasticsearchConfig, root string, ) error
ResetElasticsearch recreates the configured index from the committed settings, explicit mapping, and canonical NDJSON fixture beneath root.
func ResetLDAP ¶
ResetLDAP replaces every testbed-owned record and probe entry with fresh values derived from fixture.LDAPEntries.
func ResetMongo ¶
func ResetMongo(ctx context.Context, database *mongodriver.Database) error
ResetMongo replaces both testbed-owned collections with fresh canonical and regex-probe documents while preserving missing fields as absent keys.
func ResetSQL ¶
func ResetSQL( ctx context.Context, database *sql.DB, repositoryRoot string, backend Backend, ) error
ResetSQL replays the backend DDL and seed files from the repository root.
func SetElasticsearchExpensiveQueries ¶
func SetElasticsearchExpensiveQueries( ctx context.Context, client *goelasticsearch.TypedClient, config ElasticsearchConfig, allowed bool, ) error
SetElasticsearchExpensiveQueries changes the isolated test cluster setting and verifies the acknowledged effective value. It does not mutate Compiler declarations or perform mapping discovery.
func VerifyElasticsearchIndexContract ¶
func VerifyElasticsearchIndexContract( ctx context.Context, client *goelasticsearch.TypedClient, config ElasticsearchConfig, ) error
VerifyElasticsearchIndexContract checks the live explicit mapping and fixed index settings without performing mapping discovery for the Compiler.
func WaitForElasticsearch ¶
func WaitForElasticsearch( ctx context.Context, client *goelasticsearch.TypedClient, interval time.Duration, ) error
WaitForElasticsearch retries the typed Info API until the server answers or ctx expires. Transport errors and response bodies are deliberately omitted.
func WaitForLDAP ¶
func WaitForLDAP( ctx context.Context, config LDAPConfig, interval time.Duration, ) (*ldapv3.Conn, error)
WaitForLDAP retries an authenticated connection and base search until the service is ready or ctx expires.
func WaitForMongo ¶
WaitForMongo retries an authenticated ping until success or context expiry. Driver errors are omitted so credentials and connection details cannot leak.
func WaitForSQL ¶
func WaitForSQL( ctx context.Context, backend Backend, database *sql.DB, interval time.Duration, ) error
WaitForSQL waits until an authenticated PingContext succeeds or the caller's deadline expires. Driver errors are intentionally omitted from the returned message so connection details cannot leak through logs.
Types ¶
type Backend ¶
type Backend string
Backend identifies one supported SQL service.
func ParseBackend ¶
ParseBackend validates a command-line backend name.
func SQLBackends ¶
func SQLBackends() []Backend
SQLBackends returns the supported backends in stable display order.
type ElasticsearchConfig ¶
ElasticsearchConfig contains the loopback endpoint and explicit fixture index used by the search profile.
func LoadElasticsearchConfig ¶
func LoadElasticsearchConfig() (ElasticsearchConfig, error)
LoadElasticsearchConfig reads the documented search-profile environment variables and applies the same defaults as compose.yaml.
func (ElasticsearchConfig) Endpoint ¶
func (config ElasticsearchConfig) Endpoint() string
Endpoint returns the credential-free HTTP endpoint used by the local security-disabled search fixture.
type ElasticsearchServerInfo ¶
ElasticsearchServerInfo is the verified non-secret server identity.
func ReadElasticsearchServerInfo ¶
func ReadElasticsearchServerInfo( ctx context.Context, client *goelasticsearch.TypedClient, ) (ElasticsearchServerInfo, error)
ReadElasticsearchServerInfo verifies the exact server and Lucene versions locked by the search profile.
type LDAPConfig ¶
type LDAPConfig struct {
Host string
Port uint16
BaseDN string
AdminUser string
AdminPassword string
}
LDAPConfig contains the directory endpoint and local test credentials. Callers must not log AdminPassword or a complete Config value.
func LoadLDAPConfig ¶
func LoadLDAPConfig() (LDAPConfig, error)
LoadLDAPConfig reads directory configuration from the documented environment variables and applies the same local-only defaults as Compose.
func (LDAPConfig) BindDN ¶
func (config LDAPConfig) BindDN() string
BindDN returns the local test administrator DN. Do not use it as a log identity in code that accepts externally supplied configuration.
func (LDAPConfig) Endpoint ¶
func (config LDAPConfig) Endpoint() string
Endpoint returns a credential-free directory description suitable for logs.
type LDAPServerInfo ¶
LDAPServerInfo is the non-secret identity of the pinned directory profile after live LDAPv3 and custom-schema verification. The OpenLDAP root DSE does not expose its product version; the profile's container binary is verified separately by the integration workflow.
func ReadLDAPServerInfo ¶
func ReadLDAPServerInfo(connection *ldapv3.Conn) (LDAPServerInfo, error)
ReadLDAPServerInfo validates the live LDAPv3 root DSE and custom schema OIDs. The returned product identity is the exact image profile pinned by Compose; OpenLDAP 2.6.10 does not publish vendorName or vendorVersion in its root DSE.
type MongoConfig ¶
type MongoConfig struct {
Host string
Port uint16
Database string
AuthSource string
User string
Password string
}
MongoConfig contains the MongoDB endpoint and local test credentials. Callers must not log Password.
func LoadMongoConfig ¶
func LoadMongoConfig() (MongoConfig, error)
LoadMongoConfig reads MongoDB configuration from the documented environment variables and applies the same local-only defaults as compose.yaml.
func (MongoConfig) Endpoint ¶
func (config MongoConfig) Endpoint() string
Endpoint returns a credential-free service description suitable for logs.
type MongoServerInfo ¶
MongoServerInfo is the non-secret server identity returned by buildInfo.
func ReadMongoServerInfo ¶
func ReadMongoServerInfo( ctx context.Context, client *mongodriver.Client, ) (MongoServerInfo, error)
ReadMongoServerInfo returns buildInfo and rejects servers older than the MongoDB60Plus profile baseline.
type SQLConfig ¶
type SQLConfig struct {
Backend Backend
Host string
Port uint16
Database string
User string
Password string
}
SQLConfig contains the non-secret service identity and credentials loaded from the documented environment variables. Callers must not log Password.
func LoadSQLConfig ¶
LoadSQLConfig reads one backend configuration from the environment and applies the same local-only defaults as compose.yaml.