Documentation ¶
Index ¶
Constants ¶
const LatestConsulVersion = "1.15.3"
LatestConsulVersion is the most recent version of Consul which is used unless another version is specified in the test config or environment. This will probably go stale as we don't always update it on every release but we rarely rely on specific new Consul functionality so that's probably not a problem.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterStorage ¶ added in v1.14.5
type ClusterStorage struct { // Set these after calling `NewConsulClusterStorage` but before `Start` (or // passing in to NewDockerCluster) to control Consul version specifically in // your test. Leave empty for latest OSS (defined in consulhelper.go). ConsulVersion string ConsulEnterprise bool // contains filtered or unexported fields }
func NewClusterStorage ¶ added in v1.14.5
func NewClusterStorage() *ClusterStorage
func (*ClusterStorage) Cleanup ¶ added in v1.14.5
func (s *ClusterStorage) Cleanup() error
func (*ClusterStorage) Config ¶ added in v1.14.5
func (s *ClusterStorage) Config() *Config
func (*ClusterStorage) Opts ¶ added in v1.14.5
func (s *ClusterStorage) Opts() map[string]interface{}
func (*ClusterStorage) Start ¶ added in v1.14.5
func (s *ClusterStorage) Start(ctx context.Context, opts *testcluster.ClusterOptions) error
func (*ClusterStorage) Type ¶ added in v1.14.5
func (s *ClusterStorage) Type() string
type Config ¶ added in v1.6.0
type Config struct { docker.ServiceHostPort Token string ContainerHTTPAddr string }
func PrepareTestContainer ¶
func PrepareTestContainer(t *testing.T, version string, isEnterprise bool, doBootstrapSetup bool) (func(), *Config)
PrepareTestContainer is a test helper that creates a Consul docker container or fails the test if unsuccessful. See RunContainer for more details on the configuration.
func RunContainer ¶ added in v1.14.5
func RunContainer(ctx context.Context, namePrefix, version string, isEnterprise bool, doBootstrapSetup bool) (func(), *Config, error)
RunContainer runs Consul in a Docker container unless CONSUL_HTTP_ADDR is already found in the environment. Consul version is determined by the version argument. If version is empty string, the CONSUL_DOCKER_VERSION environment variable is used and if that is empty too, LatestConsulVersion is used (defined above). If namePrefix is provided we assume you have chosen a unique enough prefix to avoid collision with other tests that may be running in parallel and so _do not_ add an additional unique ID suffix. We will also ensure previous instances are deleted and leave the container running for debugging. This is useful for using Consul as part of at testcluster (i.e. when Vault is in Docker too). If namePrefix is empty then a unique suffix is added since many older tests rely on a uniq instance of the container. This is used by `PrepareTestContainer` which is used typically in tests that rely on Consul but run tested code within the test process.