Documentation ¶
Index ¶
- Constants
- Variables
- func DNSLookup(t *testing.T, suite *Suite, protocol string, serverIP string, serverPort int, ...) []string
- func ExpectHTTPAccess(t *testing.T, ip string, port int)
- func ExpectNoHTTPAccess(t *testing.T, ip string, port int)
- func GenerateServerTLS(t *testing.T, suite *Suite)
- func GetEnvoyClusters(t *testing.T, ip string, port int)
- func GetMetrics(t *testing.T, ip string, port int) string
- func TCP(n int) nat.Port
- func UDP(n int) nat.Port
- type AuthMethod
- type ConsulServer
- type Container
- type ContainerRequest
- type DataplaneConfig
- type Pod
- type Suite
- type SuiteOptions
- type Volume
Constants ¶
const ( // SyntheticNodeName is the name given to the "synthetic" node services are // registered to. SyntheticNodeName = "synthetic-node" )
Variables ¶
var EnvoyAdminPort = TCP(30000)
EnvoyAdminPort is the port Consul Dataplane will bind the Envoy admin server to.
Functions ¶
func GenerateServerTLS ¶
GenerateServerTLS generates CA and server certificates/key material and copies them to the suite volume to be used by the server and dataplanes.
Types ¶
type AuthMethod ¶
type AuthMethod struct { Name string // contains filtered or unexported fields }
AuthMethod is a JWT ACL auth-method, that allows us to easily generate bearer tokens in tests.
func NewAuthMethod ¶
func NewAuthMethod(t *testing.T) *AuthMethod
func (*AuthMethod) GenerateToken ¶
func (am *AuthMethod) GenerateToken(t *testing.T, service string) string
GenerateToken generates a JWT bearer token for the given service's identity.
func (*AuthMethod) Register ¶
func (am *AuthMethod) Register(t *testing.T, server *ConsulServer)
Register the auth-method and binding rules with the Consul server.
type ConsulServer ¶
func RunServer ¶
func RunServer(t *testing.T, suite *Suite) *ConsulServer
RunServer runs a Consul server.
func (*ConsulServer) RegisterService ¶
func (s *ConsulServer) RegisterService(t *testing.T, service *api.AgentService)
func (*ConsulServer) RegisterSyntheticNode ¶
func (s *ConsulServer) RegisterSyntheticNode(t *testing.T)
func (*ConsulServer) SetConfigEntry ¶
func (s *ConsulServer) SetConfigEntry(t *testing.T, entry api.ConfigEntry)
type Container ¶
type Container struct { testcontainers.Container Name string HostIP string ContainerIP string MappedPorts map[nat.Port]int }
func RunDataplane ¶
RunDataplane runs consul-dataplane in the given pod's network. It captures the Envoy proxy's config as an artifact at the end of the test.
func RunService ¶
RunService runs an HTTP echo server in the given pod's network, running on port :8080.
func (*Container) ContainerLogs ¶
ContainerLogs returns the container's logs.
func (*Container) Network ¶
func (c *Container) Network() container.NetworkMode
Network returns the container's network that can be used to join other containers to it.
type ContainerRequest ¶
type ContainerRequest = testcontainers.ContainerRequest
type DataplaneConfig ¶
type DataplaneConfig struct { Addresses string ServiceNodeName string ProxyServiceID string LoginAuthMethod string LoginBearerToken string DNSBindPort string ServiceMetricsURL string ShutdownGracePeriodSeconds string ShutdownDrainListenersEnabled bool DumpEnvoyConfigOnExitEnabled bool }
func (DataplaneConfig) ToArgs ¶
func (cfg DataplaneConfig) ToArgs() []string
type Pod ¶
type Pod struct { *Container // contains filtered or unexported fields }
func RunPod ¶
RunPod runs a "pause" container with the given ports mapped to the host, the network namespace of which will be joined by other containers. This allows us to know the IP address before starting the "real" container (as is needed to register a sidecar proxy before running consul-dataplane).
func (*Pod) ExposeInternalPorts ¶
ExposeInternalPorts creates iptables rules to forward traffic from public-facing ports to those bound only on the loopback interface. This is useful for testing our DNS proxy which can **only** be bound to the loopback interace.
type Suite ¶
type Suite struct { // Name is used as a prefix in container and volume names. Name string // contains filtered or unexported fields }
Suite handles the lifecycle of resources (e.g. containers) created during a test, and writes artifacts to disk when the test finishes.
func (*Suite) CaptureArtifact ¶
CaptureArtifact stores the given data to be written to disk when the test finishes.
func (*Suite) RunContainer ¶
func (s *Suite) RunContainer(t *testing.T, name string, captureLogs bool, req ContainerRequest) *Container
RunContainer runs a container, capturing its logs as artifacts, and stopping the container when the test finishes.
type SuiteOptions ¶
type SuiteOptions struct { // OutputDir is the directory artifacts will be written to. It can be configured // using the -output-dir flag. OutputDir string // DisableReaper controls whether the container reaper is enabled. It can be // configured using the -disable-reaper flag. // // See: https://hub.docker.com/r/testcontainers/ryuk DisableReaper bool // ServerImage is the container image reference for the Consul server. It can // be configured using the -server-image flag. ServerImage string // ServerVersion is the Consul semver (e.g. v1.x.x-prerelease) used in the image. // It is used to determine the capabilities allowed for the version of Consul under test. // It can be configured sing the -server-version flag. ServerVersion string // DataplaneImage is the container image reference for Consul Dataplane. It // can be configured using the -dataplane-image flag. DataplaneImage string }