Documentation
¶
Overview ¶
Package emutest starts an in-process gcpemu instance for Go tests (FR-CI-009). Every port is allocated dynamically and state is ephemeral.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RelayStreams ¶ added in v0.6.0
RelayStreams returns the VM relay's per-target stream counts (vmrelay.Relay.Streams), or nil when the Instance runs no relay. Tests use it to check that the relay carried a path.
func RequireRelayStream ¶ added in v0.6.0
RequireRelayStream fails the test when the Instance runs a VM relay and no stream it carried matches: a target equal to key, or ending in key when key starts with ":" (a port).
func RequireRuntime ¶
RequireRuntime skips the test unless a container runtime is available (and GCPEMU_SKIP_CONTAINER_TESTS is unset), and makes a static gcpemu binary available for in-container agents.
func RequireRuntimeOS ¶ added in v0.6.0
RequireRuntimeOS skips the test where an Instance cannot use a container runtime at all (native Windows, ADR 0008), so it refuses the Runtime Services even for control-plane tests that need no runtime.
Types ¶
type Instance ¶
Instance is a running test emulator.
func Start ¶
Start launches an instance running services (plus dependencies) and stops it when the test ends. Set GCPEMU_TEST_LOG=1 to see emulator logs.
func (*Instance) Endpoint ¶
Endpoint returns the address (host:port) of a named listener, e.g. "gateway", "gcs", "pubsub".
func (*Instance) GatewayURL ¶
GatewayURL returns "http://<gateway>".
type Option ¶
Option customises the configuration before start.
func WithDeterministic ¶
func WithDeterministic() Option
WithDeterministic enables deterministic IDs and the fake clock.
func WithSQLHostClients ¶ added in v0.8.0
func WithSQLHostClients() Option
WithSQLHostClients has Cloud SQL instances with a public IP serve host clients on a loopback address on a VM runtime (ADR 0005), as gcpemu does, for tests that dial the address an instance reports (the Cloud SQL connector, pgx or psql to its PRIMARY IP). Without it they serve none, and the host reaches each instance only on its published port (GCPEMU_SQL_<INSTANCE>). On a host without loopback aliases every instance would serve on 127.0.0.1, so the test then holds a lock shared by the user's test binaries for as long as its emulator runs, and its instances must serve one at a time.