Documentation ¶
Index ¶
- func GenerateRandomStr(length int) string
- func GetPublicIP() (string, error)
- func HTTPGet(addr string) ([]byte, error)
- type ClientOpts
- type ConsulClientWrapper
- func (ccw *ConsulClientWrapper) EnsureServiceDeregistration(name string, queryOpts *api.QueryOptions)
- func (ccw *ConsulClientWrapper) EnsureServiceInstances(name string, expectedCount int, queryOpts *api.QueryOptions)
- func (ccw *ConsulClientWrapper) EnsureServiceReadiness(name string, queryOpts *api.QueryOptions)
- type ECSClientWrapper
- func (e *ECSClientWrapper) DescribeTasks(taskIDs []string) (*ecs.DescribeTasksOutput, error)
- func (e *ECSClientWrapper) ExecuteCommandInteractive(t *testing.T, taskARN, container, command string) (string, error)
- func (e *ECSClientWrapper) ListTasksForService(service string) ([]string, error)
- func (e *ECSClientWrapper) StopTask(taskID, reason string) error
- func (e *ECSClientWrapper) UpdateService(serviceName string, desiredCount int32) error
- func (e *ECSClientWrapper) WithClusterARN(clusterARN string) *ECSClientWrapper
- type ECSClientWrapperOpts
- type FakeServiceResponse
- type UpstreamCallResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomStr ¶
GenerateRandomStr generate a random string of a given length from the predefined characterSet.
Note: The resulting string is always lowercased.
func GetPublicIP ¶
This method relies on a third party API to retrieve the public IP of the host where this test runs.
Types ¶
type ClientOpts ¶
func WithToken ¶
func WithToken(token string) ClientOpts
type ConsulClientWrapper ¶
type ConsulClientWrapper struct {
// contains filtered or unexported fields
}
func SetupConsulClient ¶
func SetupConsulClient(t *testing.T, serverAddr string, opts ...ClientOpts) (*ConsulClientWrapper, error)
SetupConsulClient sets up a consul client that can be used to directly interact with the consul server.
func (*ConsulClientWrapper) EnsureServiceDeregistration ¶
func (ccw *ConsulClientWrapper) EnsureServiceDeregistration(name string, queryOpts *api.QueryOptions)
EnsureServiceDeregistration makes sure that a service with a given name is registered as part of Consul's catalog
func (*ConsulClientWrapper) EnsureServiceInstances ¶
func (ccw *ConsulClientWrapper) EnsureServiceInstances(name string, expectedCount int, queryOpts *api.QueryOptions)
EnsureServiceInstances verifies if the number of service instances for a service in Consul catalog matches the expected count.
func (*ConsulClientWrapper) EnsureServiceReadiness ¶
func (ccw *ConsulClientWrapper) EnsureServiceReadiness(name string, queryOpts *api.QueryOptions)
EnsureServiceReadiness makes sure that a service with a given name is registered as part of Consul's catalog and is also healthy.
type ECSClientWrapper ¶
type ECSClientWrapper struct {
// contains filtered or unexported fields
}
func NewECSClient ¶
func NewECSClient(opts ...ECSClientWrapperOpts) (*ECSClientWrapper, error)
func (*ECSClientWrapper) DescribeTasks ¶
func (e *ECSClientWrapper) DescribeTasks(taskIDs []string) (*ecs.DescribeTasksOutput, error)
DescribeTasks returns back a detailed description of all the tasks passed as input.
func (*ECSClientWrapper) ExecuteCommandInteractive ¶
func (e *ECSClientWrapper) ExecuteCommandInteractive(t *testing.T, taskARN, container, command string) (string, error)
ExecuteCommandInteractive runs the provided command inside a container in the ECS task and returns back the results.
Note: Ideally we should try to use the SDK for this but it wasn't straight forward and there was no clear documentation around the same.
func (*ECSClientWrapper) ListTasksForService ¶
func (e *ECSClientWrapper) ListTasksForService(service string) ([]string, error)
ListTasksForService returns back the taskARN list for a given service
func (*ECSClientWrapper) StopTask ¶
func (e *ECSClientWrapper) StopTask(taskID, reason string) error
StopTask stops a given task with a reason
func (*ECSClientWrapper) UpdateService ¶
func (e *ECSClientWrapper) UpdateService(serviceName string, desiredCount int32) error
UpdateService scales the number of tasks governed by the service to the desiredCount.
func (*ECSClientWrapper) WithClusterARN ¶
func (e *ECSClientWrapper) WithClusterARN(clusterARN string) *ECSClientWrapper
type ECSClientWrapperOpts ¶
type ECSClientWrapperOpts func(*ECSClientWrapper)
func WithClusterARN ¶
func WithClusterARN(arn string) ECSClientWrapperOpts
func WithRegion ¶
func WithRegion(region string) ECSClientWrapperOpts
type FakeServiceResponse ¶
type FakeServiceResponse struct { Body string `json:"body"` Code int `json:"code"` UpstreamCalls map[string]UpstreamCallResponse `json:"upstream_calls"` }
func GetFakeServiceResponse ¶
func GetFakeServiceResponse(addr string) (*FakeServiceResponse, error)
GetFakeServiceResponse takes in the client application's address(typically the address of the ALB infront of the client app's ECS task) and performs a HTTP GET against the same. It returns back some fields of the response json which can be used by the caller to validate if the request went through as expected.
type UpstreamCallResponse ¶
type UpstreamCallResponse struct { Name string `json:"name"` Body string `json:"body"` IpAddresses []string `json:"ip_addresses,omitempty"` Code int `json:"code"` }
func ValidateFakeServiceResponse ¶
func ValidateFakeServiceResponse(t *testing.T, lbURL, expectedUpstream string) *UpstreamCallResponse
ValidateFakeServiceResponse takes in the client application's address(typically the address of the ALB infront of the client app's ECS task) and performs a HTTP GET against the same. It also verifies if the response matches the success criteria and also verifies if the expected upstream app was hit.