AWS ECS Fargate
This commit is contained in:
parent
e76836b948
commit
a7200a292b
39 changed files with 6240 additions and 1529 deletions
|
@ -29,16 +29,10 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
containerDefinition: &ecs.ContainerDefinition{
|
||||
DockerLabels: map[string]*string{},
|
||||
},
|
||||
machine: &ec2.Instance{
|
||||
State: &ec2.InstanceState{
|
||||
Name: aws.String(ec2.InstanceStateNameRunning),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
},
|
||||
container: &ecs.Container{
|
||||
NetworkBindings: []*ecs.NetworkBinding{{
|
||||
HostPort: aws.Int64(1337),
|
||||
}},
|
||||
machine: &machine{
|
||||
state: ec2.InstanceStateNameRunning,
|
||||
privateIP: "10.0.0.1",
|
||||
port: 1337,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -78,16 +72,10 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: aws.String("/health"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("1s"),
|
||||
}},
|
||||
machine: &ec2.Instance{
|
||||
State: &ec2.InstanceState{
|
||||
Name: aws.String(ec2.InstanceStateNameRunning),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
},
|
||||
container: &ecs.Container{
|
||||
NetworkBindings: []*ecs.NetworkBinding{{
|
||||
HostPort: aws.Int64(1337),
|
||||
}},
|
||||
machine: &machine{
|
||||
state: ec2.InstanceStateNameRunning,
|
||||
privateIP: "10.0.0.1",
|
||||
port: 1337,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -204,16 +192,10 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
label.Prefix + label.BaseFrontendRateLimit + "bar." + label.SuffixRateLimitAverage: aws.String("6"),
|
||||
label.Prefix + label.BaseFrontendRateLimit + "bar." + label.SuffixRateLimitBurst: aws.String("9"),
|
||||
}},
|
||||
machine: &ec2.Instance{
|
||||
State: &ec2.InstanceState{
|
||||
Name: aws.String(ec2.InstanceStateNameRunning),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
},
|
||||
container: &ecs.Container{
|
||||
NetworkBindings: []*ecs.NetworkBinding{{
|
||||
HostPort: aws.Int64(1337),
|
||||
}},
|
||||
machine: &machine{
|
||||
state: ec2.InstanceStateNameRunning,
|
||||
privateIP: "10.0.0.1",
|
||||
port: 1337,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -420,10 +402,10 @@ func TestFilterInstance(t *testing.T) {
|
|||
expected: true,
|
||||
},
|
||||
{
|
||||
desc: "Instance with nil private ip and exposed by default enabled should be filtered",
|
||||
desc: "Instance with empty private ip and exposed by default enabled should be filtered",
|
||||
instanceInfo: func() ecsInstance {
|
||||
nilPrivateIP := simpleEcsInstance(map[string]*string{})
|
||||
nilPrivateIP.machine.PrivateIpAddress = nil
|
||||
nilPrivateIP.machine.privateIP = ""
|
||||
return nilPrivateIP
|
||||
}(),
|
||||
exposedByDefault: true,
|
||||
|
@ -440,30 +422,20 @@ func TestFilterInstance(t *testing.T) {
|
|||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Instance with nil machine state and exposed by default enabled should be filtered",
|
||||
desc: "Instance with empty machine state and exposed by default enabled should be filtered",
|
||||
instanceInfo: func() ecsInstance {
|
||||
nilMachineState := simpleEcsInstance(map[string]*string{})
|
||||
nilMachineState.machine.State = nil
|
||||
nilMachineState.machine.state = ""
|
||||
return nilMachineState
|
||||
}(),
|
||||
exposedByDefault: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Instance with nil machine state name and exposed by default enabled should be filtered",
|
||||
instanceInfo: func() ecsInstance {
|
||||
nilMachineStateName := simpleEcsInstance(map[string]*string{})
|
||||
nilMachineStateName.machine.State.Name = nil
|
||||
return nilMachineStateName
|
||||
}(),
|
||||
exposedByDefault: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Instance with invalid machine state and exposed by default enabled should be filtered",
|
||||
instanceInfo: func() ecsInstance {
|
||||
invalidMachineState := simpleEcsInstance(map[string]*string{})
|
||||
invalidMachineState.machine.State.Name = aws.String(ec2.InstanceStateNameStopped)
|
||||
invalidMachineState.machine.state = ec2.InstanceStateNameStopped
|
||||
return invalidMachineState
|
||||
}(),
|
||||
exposedByDefault: true,
|
||||
|
@ -735,21 +707,13 @@ func makeEcsInstance(containerDef *ecs.ContainerDefinition) ecsInstance {
|
|||
}
|
||||
|
||||
instance := ecsInstance{
|
||||
Name: "foo-http",
|
||||
ID: "123456789abc",
|
||||
task: &ecs.Task{
|
||||
Containers: []*ecs.Container{container},
|
||||
},
|
||||
taskDefinition: &ecs.TaskDefinition{
|
||||
ContainerDefinitions: []*ecs.ContainerDefinition{containerDef},
|
||||
},
|
||||
container: container,
|
||||
Name: "foo-http",
|
||||
ID: "123456789abc",
|
||||
containerDefinition: containerDef,
|
||||
machine: &ec2.Instance{
|
||||
PrivateIpAddress: aws.String("10.0.0.0"),
|
||||
State: &ec2.InstanceState{
|
||||
Name: aws.String(ec2.InstanceStateNameRunning),
|
||||
},
|
||||
machine: &machine{
|
||||
state: ec2.InstanceStateNameRunning,
|
||||
privateIP: "10.0.0.0",
|
||||
port: 1337,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -761,23 +725,21 @@ func makeEcsInstance(containerDef *ecs.ContainerDefinition) ecsInstance {
|
|||
}
|
||||
|
||||
func simpleEcsInstance(labels map[string]*string) ecsInstance {
|
||||
return makeEcsInstance(&ecs.ContainerDefinition{
|
||||
Name: aws.String("http"),
|
||||
PortMappings: []*ecs.PortMapping{{
|
||||
HostPort: aws.Int64(80),
|
||||
ContainerPort: aws.Int64(80),
|
||||
Protocol: aws.String("tcp"),
|
||||
}},
|
||||
instance := makeEcsInstance(&ecs.ContainerDefinition{
|
||||
Name: aws.String("http"),
|
||||
DockerLabels: labels,
|
||||
})
|
||||
instance.machine.port = 80
|
||||
return instance
|
||||
}
|
||||
|
||||
func simpleEcsInstanceNoNetwork(labels map[string]*string) ecsInstance {
|
||||
return makeEcsInstance(&ecs.ContainerDefinition{
|
||||
instance := makeEcsInstance(&ecs.ContainerDefinition{
|
||||
Name: aws.String("http"),
|
||||
PortMappings: []*ecs.PortMapping{},
|
||||
DockerLabels: labels,
|
||||
})
|
||||
instance.machine.port = 0
|
||||
return instance
|
||||
}
|
||||
|
||||
func fakeLoadTraefikLabels(instances []ecsInstance) []ecsInstance {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue