ecsmock

package
v0.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ecsmock implements mock server for ECS service API. Currently it is only used by ecsobserver extension for unit test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenContainerInstances added in v0.28.0

func GenContainerInstances(arnPrefix string, count int, modifier func(i int, ci *ecs.ContainerInstance)) []*ecs.ContainerInstance

func GenEc2Instances added in v0.28.0

func GenEc2Instances(idPrefix string, count int, modifier func(i int, ins *ec2.Instance)) []*ec2.Instance

func GenServices added in v0.28.0

func GenServices(arnPrefix string, count int, modifier func(i int, s *ecs.Service)) []*ecs.Service

func GenTaskDefinitions added in v0.28.0

func GenTaskDefinitions(arnPrefix string, count int, version int, modifier func(i int, def *ecs.TaskDefinition)) []*ecs.TaskDefinition

GenTaskDefinitions returns tasks with TaskArn set to arnPrefix+offset+version, where offset is [0, count). e.g. foo0:1, foo1:1 the `:` is following the task family version syntax.

func GenTasks

func GenTasks(arnPrefix string, count int, modifier func(i int, task *ecs.Task)) []*ecs.Task

GenTasks returns tasks with TaskArn set to arnPrefix+offset, where offset is [0, count).

Types

type APIStat added in v0.28.0

type APIStat struct {
	Called int
	Error  int
}

APIStat keep track of individual API calls.

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster implements both ECS and EC2 API for a single cluster.

func NewCluster

func NewCluster() *Cluster

NewCluster creates a mock ECS cluster with default limits.

func NewClusterWithName added in v0.30.0

func NewClusterWithName(name string) *Cluster

NewClusterWithName creates a cluster that checks for cluster name if request includes a non empty cluster name.

func (*Cluster) DescribeContainerInstancesWithContext added in v0.28.0

func (c *Cluster) DescribeContainerInstancesWithContext(_ context.Context, input *ecs.DescribeContainerInstancesInput, _ ...request.Option) (*ecs.DescribeContainerInstancesOutput, error)

func (*Cluster) DescribeInstancesWithContext added in v0.28.0

func (c *Cluster) DescribeInstancesWithContext(_ context.Context, input *ec2.DescribeInstancesInput, _ ...request.Option) (*ec2.DescribeInstancesOutput, error)

DescribeInstancesWithContext supports get all the instances and get instance by ids. It does NOT support filter. Result always has a single reservation, which is not the case in actual EC2 API.

func (*Cluster) DescribeServicesWithContext added in v0.28.0

func (c *Cluster) DescribeServicesWithContext(_ context.Context, input *ecs.DescribeServicesInput, _ ...request.Option) (*ecs.DescribeServicesOutput, error)

func (*Cluster) DescribeTaskDefinitionWithContext added in v0.28.0

func (c *Cluster) DescribeTaskDefinitionWithContext(_ context.Context, input *ecs.DescribeTaskDefinitionInput, _ ...request.Option) (*ecs.DescribeTaskDefinitionOutput, error)

func (*Cluster) DescribeTasksWithContext

func (c *Cluster) DescribeTasksWithContext(_ context.Context, input *ecs.DescribeTasksInput, _ ...request.Option) (*ecs.DescribeTasksOutput, error)

func (*Cluster) ListServicesWithContext added in v0.28.0

func (c *Cluster) ListServicesWithContext(_ context.Context, input *ecs.ListServicesInput, _ ...request.Option) (*ecs.ListServicesOutput, error)

func (*Cluster) ListTasksWithContext

func (c *Cluster) ListTasksWithContext(_ context.Context, input *ecs.ListTasksInput, _ ...request.Option) (*ecs.ListTasksOutput, error)

func (*Cluster) SetContainerInstances added in v0.28.0

func (c *Cluster) SetContainerInstances(instances []*ecs.ContainerInstance)

SetContainerInstances updates the list and map.

func (*Cluster) SetEc2Instances added in v0.28.0

func (c *Cluster) SetEc2Instances(instances []*ec2.Instance)

SetEc2Instances updates the list and map.

func (*Cluster) SetServices added in v0.28.0

func (c *Cluster) SetServices(services []*ecs.Service)

SetServices updates the list and map.

func (*Cluster) SetTaskDefinitions added in v0.28.0

func (c *Cluster) SetTaskDefinitions(defs []*ecs.TaskDefinition)

SetTaskDefinitions updates the map. NOTE: we could have both list and map, but we are not using list task def in ecsobserver.

func (*Cluster) SetTasks

func (c *Cluster) SetTasks(tasks []*ecs.Task)

SetTasks update both list and map.

func (*Cluster) Stats added in v0.28.0

func (c *Cluster) Stats() ClusterStats

type ClusterStats added in v0.28.0

type ClusterStats struct {
	DescribeTaskDefinition APIStat
}

ClusterStats keep track of API methods for one ECS cluster. Not all methods are tracked

type PageLimit

type PageLimit struct {
	ListTaskOutput                 int // default 100, max 100
	DescribeTaskInput              int // max 100
	ListServiceOutput              int // default 10, max 100
	DescribeServiceInput           int // max 10
	DescribeContainerInstanceInput int // max 100
	DescribeInstanceOutput         int // max 1000

}

PageLimit defines number of items in a single page for different APIs. Those numbers can be found on the Input and and Output struct comments. Call DefaultPageLimit() to config the mock to use numbers same as the actual AWS API.

func DefaultPageLimit

func DefaultPageLimit() PageLimit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL