mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
AWS: Update tests for refactoring
This commit is contained in:
parent
af9efa02b4
commit
f8e6098e4d
@ -928,12 +928,16 @@ type awsInstance struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newAWSInstance creates a new awsInstance object
|
// newAWSInstance creates a new awsInstance object
|
||||||
func newAWSInstance(ec2 EC2, instance *ec2.Instance) *awsInstance {
|
func newAWSInstance(ec2Service EC2, instance *ec2.Instance) *awsInstance {
|
||||||
|
az := ""
|
||||||
|
if instance.Placement != nil {
|
||||||
|
az = aws.StringValue(instance.Placement.AvailabilityZone)
|
||||||
|
}
|
||||||
self := &awsInstance{
|
self := &awsInstance{
|
||||||
ec2: ec2,
|
ec2: ec2Service,
|
||||||
awsID: aws.StringValue(instance.InstanceId),
|
awsID: aws.StringValue(instance.InstanceId),
|
||||||
nodeName: aws.StringValue(instance.PrivateDnsName),
|
nodeName: aws.StringValue(instance.PrivateDnsName),
|
||||||
availabilityZone: aws.StringValue(instance.Placement.AvailabilityZone),
|
availabilityZone: az,
|
||||||
instanceType: aws.StringValue(instance.InstanceType),
|
instanceType: aws.StringValue(instance.InstanceType),
|
||||||
vpcID: aws.StringValue(instance.VpcId),
|
vpcID: aws.StringValue(instance.VpcId),
|
||||||
subnetID: aws.StringValue(instance.SubnetId),
|
subnetID: aws.StringValue(instance.SubnetId),
|
||||||
|
@ -110,14 +110,11 @@ func TestReadAWSCloudConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FakeAWSServices struct {
|
type FakeAWSServices struct {
|
||||||
availabilityZone string
|
region string
|
||||||
instances []*ec2.Instance
|
instances []*ec2.Instance
|
||||||
instanceId string
|
selfInstance *ec2.Instance
|
||||||
privateDnsName string
|
|
||||||
networkInterfacesMacs []string
|
networkInterfacesMacs []string
|
||||||
networkInterfacesVpcIDs []string
|
networkInterfacesVpcIDs []string
|
||||||
internalIP string
|
|
||||||
externalIP string
|
|
||||||
|
|
||||||
ec2 *FakeEC2
|
ec2 *FakeEC2
|
||||||
elb *FakeELB
|
elb *FakeELB
|
||||||
@ -127,7 +124,7 @@ type FakeAWSServices struct {
|
|||||||
|
|
||||||
func NewFakeAWSServices() *FakeAWSServices {
|
func NewFakeAWSServices() *FakeAWSServices {
|
||||||
s := &FakeAWSServices{}
|
s := &FakeAWSServices{}
|
||||||
s.availabilityZone = "us-east-1a"
|
s.region = "us-east-1"
|
||||||
s.ec2 = &FakeEC2{aws: s}
|
s.ec2 = &FakeEC2{aws: s}
|
||||||
s.elb = &FakeELB{aws: s}
|
s.elb = &FakeELB{aws: s}
|
||||||
s.asg = &FakeASG{aws: s}
|
s.asg = &FakeASG{aws: s}
|
||||||
@ -136,14 +133,16 @@ func NewFakeAWSServices() *FakeAWSServices {
|
|||||||
s.networkInterfacesMacs = []string{"aa:bb:cc:dd:ee:00", "aa:bb:cc:dd:ee:01"}
|
s.networkInterfacesMacs = []string{"aa:bb:cc:dd:ee:00", "aa:bb:cc:dd:ee:01"}
|
||||||
s.networkInterfacesVpcIDs = []string{"vpc-mac0", "vpc-mac1"}
|
s.networkInterfacesVpcIDs = []string{"vpc-mac0", "vpc-mac1"}
|
||||||
|
|
||||||
s.instanceId = "i-self"
|
selfInstance := &ec2.Instance{}
|
||||||
s.privateDnsName = "ip-172-20-0-100.ec2.internal"
|
selfInstance.InstanceId = aws.String("i-self")
|
||||||
s.internalIP = "192.168.0.1"
|
selfInstance.Placement = &ec2.Placement{
|
||||||
s.externalIP = "1.2.3.4"
|
AvailabilityZone: aws.String("us-east-1a"),
|
||||||
var selfInstance ec2.Instance
|
}
|
||||||
selfInstance.InstanceId = &s.instanceId
|
selfInstance.PrivateDnsName = aws.String("ip-172-20-0-100.ec2.internal")
|
||||||
selfInstance.PrivateDnsName = &s.privateDnsName
|
selfInstance.PrivateIpAddress = aws.String("192.168.0.1")
|
||||||
s.instances = []*ec2.Instance{&selfInstance}
|
selfInstance.PublicIpAddress = aws.String("1.2.3.4")
|
||||||
|
s.selfInstance = selfInstance
|
||||||
|
s.instances = []*ec2.Instance{selfInstance}
|
||||||
|
|
||||||
var tag ec2.Tag
|
var tag ec2.Tag
|
||||||
tag.Key = aws.String(TagNameKubernetesCluster)
|
tag.Key = aws.String(TagNameKubernetesCluster)
|
||||||
@ -154,12 +153,10 @@ func NewFakeAWSServices() *FakeAWSServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *FakeAWSServices) withAz(az string) *FakeAWSServices {
|
func (s *FakeAWSServices) withAz(az string) *FakeAWSServices {
|
||||||
s.availabilityZone = az
|
if s.selfInstance.Placement == nil {
|
||||||
return s
|
s.selfInstance.Placement = &ec2.Placement{}
|
||||||
}
|
}
|
||||||
|
s.selfInstance.Placement.AvailabilityZone = aws.String(az)
|
||||||
func (s *FakeAWSServices) withInstances(instances []*ec2.Instance) *FakeAWSServices {
|
|
||||||
s.instances = instances
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +202,7 @@ func TestNewAWSCloud(t *testing.T) {
|
|||||||
awsServices AWSServices
|
awsServices AWSServices
|
||||||
|
|
||||||
expectError bool
|
expectError bool
|
||||||
zone string
|
region string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"No config reader",
|
"No config reader",
|
||||||
@ -220,14 +217,13 @@ func TestNewAWSCloud(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"Config specifies valid zone",
|
"Config specifies valid zone",
|
||||||
strings.NewReader("[global]\nzone = eu-west-1a"), NewFakeAWSServices(),
|
strings.NewReader("[global]\nzone = eu-west-1a"), NewFakeAWSServices(),
|
||||||
false, "eu-west-1a",
|
false, "eu-west-1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Gets zone from metadata when not in config",
|
"Gets zone from metadata when not in config",
|
||||||
|
|
||||||
strings.NewReader("[global]\n"),
|
strings.NewReader("[global]\n"),
|
||||||
NewFakeAWSServices(),
|
NewFakeAWSServices(),
|
||||||
false, "us-east-1a",
|
false, "us-east-1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"No zone in config or metadata",
|
"No zone in config or metadata",
|
||||||
@ -247,9 +243,9 @@ func TestNewAWSCloud(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Should succeed for case: %s, got %v", test.name, err)
|
t.Errorf("Should succeed for case: %s, got %v", test.name, err)
|
||||||
} else if c.availabilityZone != test.zone {
|
} else if c.region != test.region {
|
||||||
t.Errorf("Incorrect zone value (%s vs %s) for case: %s",
|
t.Errorf("Incorrect region value (%s vs %s) for case: %s",
|
||||||
c.availabilityZone, test.zone, test.name)
|
c.region, test.region, test.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,8 +305,8 @@ func (self *FakeEC2) DescribeInstances(request *ec2.DescribeInstancesInput) ([]*
|
|||||||
}
|
}
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
for _, instanceId := range request.InstanceIds {
|
for _, instanceID := range request.InstanceIds {
|
||||||
if *instanceId == *instance.InstanceId {
|
if *instanceID == *instance.InstanceId {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -343,16 +339,21 @@ type FakeMetadata struct {
|
|||||||
|
|
||||||
func (self *FakeMetadata) GetMetadata(key string) (string, error) {
|
func (self *FakeMetadata) GetMetadata(key string) (string, error) {
|
||||||
networkInterfacesPrefix := "network/interfaces/macs/"
|
networkInterfacesPrefix := "network/interfaces/macs/"
|
||||||
|
i := self.aws.selfInstance
|
||||||
if key == "placement/availability-zone" {
|
if key == "placement/availability-zone" {
|
||||||
return self.aws.availabilityZone, nil
|
az := ""
|
||||||
|
if i.Placement != nil {
|
||||||
|
az = aws.StringValue(i.Placement.AvailabilityZone)
|
||||||
|
}
|
||||||
|
return az, nil
|
||||||
} else if key == "instance-id" {
|
} else if key == "instance-id" {
|
||||||
return self.aws.instanceId, nil
|
return aws.StringValue(i.InstanceId), nil
|
||||||
} else if key == "local-hostname" {
|
} else if key == "local-hostname" {
|
||||||
return self.aws.privateDnsName, nil
|
return aws.StringValue(i.PrivateDnsName), nil
|
||||||
} else if key == "local-ipv4" {
|
} else if key == "local-ipv4" {
|
||||||
return self.aws.internalIP, nil
|
return aws.StringValue(i.PrivateIpAddress), nil
|
||||||
} else if key == "public-ipv4" {
|
} else if key == "public-ipv4" {
|
||||||
return self.aws.externalIP, nil
|
return aws.StringValue(i.PublicIpAddress), nil
|
||||||
} else if strings.HasPrefix(key, networkInterfacesPrefix) {
|
} else if strings.HasPrefix(key, networkInterfacesPrefix) {
|
||||||
if key == networkInterfacesPrefix {
|
if key == networkInterfacesPrefix {
|
||||||
return strings.Join(self.aws.networkInterfacesMacs, "/\n") + "/\n", nil
|
return strings.Join(self.aws.networkInterfacesMacs, "/\n") + "/\n", nil
|
||||||
@ -499,22 +500,24 @@ func (a *FakeASG) DescribeAutoScalingGroups(*autoscaling.DescribeAutoScalingGrou
|
|||||||
panic("Not implemented")
|
panic("Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockInstancesResp(instances []*ec2.Instance) (*AWSCloud, *FakeAWSServices) {
|
func mockInstancesResp(selfInstance *ec2.Instance, instances []*ec2.Instance) (*AWSCloud, *FakeAWSServices) {
|
||||||
awsServices := NewFakeAWSServices().withInstances(instances)
|
awsServices := NewFakeAWSServices()
|
||||||
return &AWSCloud{
|
awsServices.instances = instances
|
||||||
ec2: awsServices.ec2,
|
awsServices.selfInstance = selfInstance
|
||||||
availabilityZone: awsServices.availabilityZone,
|
awsCloud, err := newAWSCloud(nil, awsServices)
|
||||||
metadata: &FakeMetadata{aws: awsServices},
|
if err != nil {
|
||||||
}, awsServices
|
panic(err)
|
||||||
|
}
|
||||||
|
return awsCloud, awsServices
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockAvailabilityZone(region string, availabilityZone string) *AWSCloud {
|
func mockAvailabilityZone(availabilityZone string) *AWSCloud {
|
||||||
awsServices := NewFakeAWSServices().withAz(availabilityZone)
|
awsServices := NewFakeAWSServices().withAz(availabilityZone)
|
||||||
return &AWSCloud{
|
awsCloud, err := newAWSCloud(nil, awsServices)
|
||||||
ec2: awsServices.ec2,
|
if err != nil {
|
||||||
availabilityZone: awsServices.availabilityZone,
|
panic(err)
|
||||||
region: region,
|
|
||||||
}
|
}
|
||||||
|
return awsCloud
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestList(t *testing.T) {
|
func TestList(t *testing.T) {
|
||||||
@ -532,6 +535,7 @@ func TestList(t *testing.T) {
|
|||||||
instance0.Tags = []*ec2.Tag{&tag0}
|
instance0.Tags = []*ec2.Tag{&tag0}
|
||||||
instance0.InstanceId = aws.String("instance0")
|
instance0.InstanceId = aws.String("instance0")
|
||||||
instance0.PrivateDnsName = aws.String("instance0.ec2.internal")
|
instance0.PrivateDnsName = aws.String("instance0.ec2.internal")
|
||||||
|
instance0.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state0 := ec2.InstanceState{
|
state0 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
@ -545,6 +549,7 @@ func TestList(t *testing.T) {
|
|||||||
instance1.Tags = []*ec2.Tag{&tag1}
|
instance1.Tags = []*ec2.Tag{&tag1}
|
||||||
instance1.InstanceId = aws.String("instance1")
|
instance1.InstanceId = aws.String("instance1")
|
||||||
instance1.PrivateDnsName = aws.String("instance1.ec2.internal")
|
instance1.PrivateDnsName = aws.String("instance1.ec2.internal")
|
||||||
|
instance1.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state1 := ec2.InstanceState{
|
state1 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
@ -558,6 +563,7 @@ func TestList(t *testing.T) {
|
|||||||
instance2.Tags = []*ec2.Tag{&tag2}
|
instance2.Tags = []*ec2.Tag{&tag2}
|
||||||
instance2.InstanceId = aws.String("instance2")
|
instance2.InstanceId = aws.String("instance2")
|
||||||
instance2.PrivateDnsName = aws.String("instance2.ec2.internal")
|
instance2.PrivateDnsName = aws.String("instance2.ec2.internal")
|
||||||
|
instance2.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state2 := ec2.InstanceState{
|
state2 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
@ -571,13 +577,14 @@ func TestList(t *testing.T) {
|
|||||||
instance3.Tags = []*ec2.Tag{&tag3}
|
instance3.Tags = []*ec2.Tag{&tag3}
|
||||||
instance3.InstanceId = aws.String("instance3")
|
instance3.InstanceId = aws.String("instance3")
|
||||||
instance3.PrivateDnsName = aws.String("instance3.ec2.internal")
|
instance3.PrivateDnsName = aws.String("instance3.ec2.internal")
|
||||||
|
instance3.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state3 := ec2.InstanceState{
|
state3 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
instance3.State = &state3
|
instance3.State = &state3
|
||||||
|
|
||||||
instances := []*ec2.Instance{&instance0, &instance1, &instance2, &instance3}
|
instances := []*ec2.Instance{&instance0, &instance1, &instance2, &instance3}
|
||||||
aws, _ := mockInstancesResp(instances)
|
aws, _ := mockInstancesResp(&instance0, instances)
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
input string
|
input string
|
||||||
@ -616,32 +623,35 @@ func TestNodeAddresses(t *testing.T) {
|
|||||||
var instance2 ec2.Instance
|
var instance2 ec2.Instance
|
||||||
|
|
||||||
//0
|
//0
|
||||||
instance0.InstanceId = aws.String("i-self")
|
instance0.InstanceId = aws.String("i-0")
|
||||||
instance0.PrivateDnsName = aws.String("instance-same.ec2.internal")
|
instance0.PrivateDnsName = aws.String("instance-same.ec2.internal")
|
||||||
instance0.PrivateIpAddress = aws.String("192.168.0.1")
|
instance0.PrivateIpAddress = aws.String("192.168.0.1")
|
||||||
instance0.PublicIpAddress = aws.String("1.2.3.4")
|
instance0.PublicIpAddress = aws.String("1.2.3.4")
|
||||||
instance0.InstanceType = aws.String("c3.large")
|
instance0.InstanceType = aws.String("c3.large")
|
||||||
|
instance0.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state0 := ec2.InstanceState{
|
state0 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
instance0.State = &state0
|
instance0.State = &state0
|
||||||
|
|
||||||
//1
|
//1
|
||||||
instance1.InstanceId = aws.String("i-self")
|
instance1.InstanceId = aws.String("i-1")
|
||||||
instance1.PrivateDnsName = aws.String("instance-same.ec2.internal")
|
instance1.PrivateDnsName = aws.String("instance-same.ec2.internal")
|
||||||
instance1.PrivateIpAddress = aws.String("192.168.0.2")
|
instance1.PrivateIpAddress = aws.String("192.168.0.2")
|
||||||
instance1.InstanceType = aws.String("c3.large")
|
instance1.InstanceType = aws.String("c3.large")
|
||||||
|
instance1.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state1 := ec2.InstanceState{
|
state1 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
instance1.State = &state1
|
instance1.State = &state1
|
||||||
|
|
||||||
//2
|
//2
|
||||||
instance2.InstanceId = aws.String("i-self")
|
instance2.InstanceId = aws.String("i-2")
|
||||||
instance2.PrivateDnsName = aws.String("instance-other.ec2.internal")
|
instance2.PrivateDnsName = aws.String("instance-other.ec2.internal")
|
||||||
instance2.PrivateIpAddress = aws.String("192.168.0.1")
|
instance2.PrivateIpAddress = aws.String("192.168.0.1")
|
||||||
instance2.PublicIpAddress = aws.String("1.2.3.4")
|
instance2.PublicIpAddress = aws.String("1.2.3.4")
|
||||||
instance2.InstanceType = aws.String("c3.large")
|
instance2.InstanceType = aws.String("c3.large")
|
||||||
|
instance2.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")}
|
||||||
state2 := ec2.InstanceState{
|
state2 := ec2.InstanceState{
|
||||||
Name: aws.String("running"),
|
Name: aws.String("running"),
|
||||||
}
|
}
|
||||||
@ -649,19 +659,19 @@ func TestNodeAddresses(t *testing.T) {
|
|||||||
|
|
||||||
instances := []*ec2.Instance{&instance0, &instance1, &instance2}
|
instances := []*ec2.Instance{&instance0, &instance1, &instance2}
|
||||||
|
|
||||||
aws1, _ := mockInstancesResp([]*ec2.Instance{})
|
aws1, _ := mockInstancesResp(&instance0, []*ec2.Instance{&instance0})
|
||||||
_, err1 := aws1.NodeAddresses("instance-mismatch.ec2.internal")
|
_, err1 := aws1.NodeAddresses("instance-mismatch.ec2.internal")
|
||||||
if err1 == nil {
|
if err1 == nil {
|
||||||
t.Errorf("Should error when no instance found")
|
t.Errorf("Should error when no instance found")
|
||||||
}
|
}
|
||||||
|
|
||||||
aws2, _ := mockInstancesResp(instances)
|
aws2, _ := mockInstancesResp(&instance2, instances)
|
||||||
_, err2 := aws2.NodeAddresses("instance-same.ec2.internal")
|
_, err2 := aws2.NodeAddresses("instance-same.ec2.internal")
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
t.Errorf("Should error when multiple instances found")
|
t.Errorf("Should error when multiple instances found")
|
||||||
}
|
}
|
||||||
|
|
||||||
aws3, _ := mockInstancesResp(instances[0:1])
|
aws3, _ := mockInstancesResp(&instance0, instances[0:1])
|
||||||
addrs3, err3 := aws3.NodeAddresses("instance-same.ec2.internal")
|
addrs3, err3 := aws3.NodeAddresses("instance-same.ec2.internal")
|
||||||
if err3 != nil {
|
if err3 != nil {
|
||||||
t.Errorf("Should not error when instance found")
|
t.Errorf("Should not error when instance found")
|
||||||
@ -673,12 +683,12 @@ func TestNodeAddresses(t *testing.T) {
|
|||||||
testHasNodeAddress(t, addrs3, api.NodeLegacyHostIP, "192.168.0.1")
|
testHasNodeAddress(t, addrs3, api.NodeLegacyHostIP, "192.168.0.1")
|
||||||
testHasNodeAddress(t, addrs3, api.NodeExternalIP, "1.2.3.4")
|
testHasNodeAddress(t, addrs3, api.NodeExternalIP, "1.2.3.4")
|
||||||
|
|
||||||
aws4, fakeServices := mockInstancesResp([]*ec2.Instance{})
|
// Fetch from metadata
|
||||||
fakeServices.externalIP = "2.3.4.5"
|
aws4, fakeServices := mockInstancesResp(&instance0, []*ec2.Instance{&instance0})
|
||||||
fakeServices.internalIP = "192.168.0.2"
|
fakeServices.selfInstance.PublicIpAddress = aws.String("2.3.4.5")
|
||||||
aws4.selfAWSInstance = &awsInstance{nodeName: fakeServices.instanceId}
|
fakeServices.selfInstance.PrivateIpAddress = aws.String("192.168.0.2")
|
||||||
|
|
||||||
addrs4, err4 := aws4.NodeAddresses(fakeServices.instanceId)
|
addrs4, err4 := aws4.NodeAddresses(*instance0.PrivateDnsName)
|
||||||
if err4 != nil {
|
if err4 != nil {
|
||||||
t.Errorf("unexpected error: %v", err4)
|
t.Errorf("unexpected error: %v", err4)
|
||||||
}
|
}
|
||||||
@ -687,7 +697,7 @@ func TestNodeAddresses(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRegion(t *testing.T) {
|
func TestGetRegion(t *testing.T) {
|
||||||
aws := mockAvailabilityZone("us-west-2", "us-west-2e")
|
aws := mockAvailabilityZone("us-west-2e")
|
||||||
zones, ok := aws.Zones()
|
zones, ok := aws.Zones()
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Unexpected missing zones impl")
|
t.Fatalf("Unexpected missing zones impl")
|
||||||
@ -820,8 +830,6 @@ func TestSubnetIDsinVPC(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vpcID := "vpc-deadbeef"
|
|
||||||
|
|
||||||
// test with 3 subnets from 3 different AZs
|
// test with 3 subnets from 3 different AZs
|
||||||
subnets := make(map[int]map[string]string)
|
subnets := make(map[int]map[string]string)
|
||||||
subnets[0] = make(map[string]string)
|
subnets[0] = make(map[string]string)
|
||||||
@ -842,7 +850,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
||||||
|
|
||||||
result, err := c.listPublicSubnetIDsinVPC(vpcID)
|
result, err := c.listPublicSubnetIDsinVPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error listing subnets: %v", err)
|
t.Errorf("Error listing subnets: %v", err)
|
||||||
return
|
return
|
||||||
@ -868,7 +876,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
|
|||||||
// test implicit routing table - when subnets are not explicitly linked to a table they should use main
|
// test implicit routing table - when subnets are not explicitly linked to a table they should use main
|
||||||
awsServices.ec2.RouteTables = constructRouteTables(map[string]bool{})
|
awsServices.ec2.RouteTables = constructRouteTables(map[string]bool{})
|
||||||
|
|
||||||
result, err = c.listPublicSubnetIDsinVPC(vpcID)
|
result, err = c.listPublicSubnetIDsinVPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error listing subnets: %v", err)
|
t.Errorf("Error listing subnets: %v", err)
|
||||||
return
|
return
|
||||||
@ -900,7 +908,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
|
|||||||
routeTables["subnet-c0000002"] = true
|
routeTables["subnet-c0000002"] = true
|
||||||
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
||||||
|
|
||||||
result, err = c.listPublicSubnetIDsinVPC(vpcID)
|
result, err = c.listPublicSubnetIDsinVPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error listing subnets: %v", err)
|
t.Errorf("Error listing subnets: %v", err)
|
||||||
return
|
return
|
||||||
@ -928,7 +936,7 @@ func TestSubnetIDsinVPC(t *testing.T) {
|
|||||||
routeTables["subnet-d0000001"] = true
|
routeTables["subnet-d0000001"] = true
|
||||||
routeTables["subnet-d0000002"] = true
|
routeTables["subnet-d0000002"] = true
|
||||||
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
awsServices.ec2.RouteTables = constructRouteTables(routeTables)
|
||||||
result, err = c.listPublicSubnetIDsinVPC(vpcID)
|
result, err = c.listPublicSubnetIDsinVPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error listing subnets: %v", err)
|
t.Errorf("Error listing subnets: %v", err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user