mirror of https://github.com/kubernetes/kops.git
Add missing cloudmock functionality for enabling lifecycle integration test on complex cluster
This commit is contained in:
parent
839a1185cf
commit
11bf3ff202
|
|
@ -50,3 +50,20 @@ func (m *MockAutoscaling) AttachLoadBalancersRequest(*autoscaling.AttachLoadBala
|
||||||
klog.Fatalf("Not implemented")
|
klog.Fatalf("Not implemented")
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockAutoscaling) AttachLoadBalancerTargetGroups(request *autoscaling.AttachLoadBalancerTargetGroupsInput) (*autoscaling.AttachLoadBalancerTargetGroupsOutput, error) {
|
||||||
|
m.mutex.Lock()
|
||||||
|
defer m.mutex.Unlock()
|
||||||
|
|
||||||
|
klog.Infof("AttachLoadBalancers: %v", request)
|
||||||
|
|
||||||
|
name := *request.AutoScalingGroupName
|
||||||
|
|
||||||
|
asg := m.Groups[name]
|
||||||
|
if asg == nil {
|
||||||
|
return nil, fmt.Errorf("Group %q not found", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
asg.TargetGroupARNs = request.TargetGroupARNs
|
||||||
|
return &autoscaling.AttachLoadBalancerTargetGroupsOutput{}, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,7 @@ func (m *MockAutoscaling) CreateAutoScalingGroup(input *autoscaling.CreateAutoSc
|
||||||
NewInstancesProtectedFromScaleIn: input.NewInstancesProtectedFromScaleIn,
|
NewInstancesProtectedFromScaleIn: input.NewInstancesProtectedFromScaleIn,
|
||||||
PlacementGroup: input.PlacementGroup,
|
PlacementGroup: input.PlacementGroup,
|
||||||
// Status: input.Status,
|
// Status: input.Status,
|
||||||
// SuspendedProcesses: input.SuspendedProcesses,
|
SuspendedProcesses: make([]*autoscaling.SuspendedProcess, 0),
|
||||||
// Tags: input.Tags,
|
|
||||||
TargetGroupARNs: input.TargetGroupARNs,
|
TargetGroupARNs: input.TargetGroupARNs,
|
||||||
TerminationPolicies: input.TerminationPolicies,
|
TerminationPolicies: input.TerminationPolicies,
|
||||||
VPCZoneIdentifier: input.VPCZoneIdentifier,
|
VPCZoneIdentifier: input.VPCZoneIdentifier,
|
||||||
|
|
@ -126,6 +125,34 @@ func (m *MockAutoscaling) EnableMetricsCollection(request *autoscaling.EnableMet
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockAutoscaling) SuspendProcesses(input *autoscaling.ScalingProcessQuery) (*autoscaling.SuspendProcessesOutput, error) {
|
||||||
|
m.mutex.Lock()
|
||||||
|
defer m.mutex.Unlock()
|
||||||
|
|
||||||
|
klog.Infof("EnableMetricsCollection: %v", input)
|
||||||
|
|
||||||
|
g := m.Groups[*input.AutoScalingGroupName]
|
||||||
|
if g == nil {
|
||||||
|
return nil, fmt.Errorf("AutoScalingGroup not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range input.ScalingProcesses {
|
||||||
|
found := false
|
||||||
|
for _, asgProc := range g.SuspendedProcesses {
|
||||||
|
if aws.StringValue(asgProc.ProcessName) == aws.StringValue(p) {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
g.SuspendedProcesses = append(g.SuspendedProcesses, &autoscaling.SuspendedProcess{
|
||||||
|
ProcessName: p,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &autoscaling.SuspendProcessesOutput{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MockAutoscaling) DescribeAutoScalingGroups(input *autoscaling.DescribeAutoScalingGroupsInput) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
|
func (m *MockAutoscaling) DescribeAutoScalingGroups(input *autoscaling.DescribeAutoScalingGroupsInput) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
|
||||||
m.mutex.Lock()
|
m.mutex.Lock()
|
||||||
defer m.mutex.Unlock()
|
defer m.mutex.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,11 @@ func (m *MockIAM) CreateRole(request *iam.CreateRoleInput) (*iam.CreateRoleOutpu
|
||||||
AssumeRolePolicyDocument: request.AssumeRolePolicyDocument,
|
AssumeRolePolicyDocument: request.AssumeRolePolicyDocument,
|
||||||
Description: request.Description,
|
Description: request.Description,
|
||||||
Path: request.Path,
|
Path: request.Path,
|
||||||
RoleName: request.RoleName,
|
PermissionsBoundary: &iam.AttachedPermissionsBoundary{
|
||||||
RoleId: &roleID,
|
PermissionsBoundaryArn: request.PermissionsBoundary,
|
||||||
|
},
|
||||||
|
RoleName: request.RoleName,
|
||||||
|
RoleId: &roleID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Roles == nil {
|
if m.Roles == nil {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ go_library(
|
||||||
"//util/pkg/vfs:go_default_library",
|
"//util/pkg/vfs:go_default_library",
|
||||||
"//vendor/github.com/aws/aws-sdk-go/aws:go_default_library",
|
"//vendor/github.com/aws/aws-sdk-go/aws:go_default_library",
|
||||||
"//vendor/github.com/aws/aws-sdk-go/service/ec2:go_default_library",
|
"//vendor/github.com/aws/aws-sdk-go/service/ec2:go_default_library",
|
||||||
|
"//vendor/github.com/aws/aws-sdk-go/service/elbv2:go_default_library",
|
||||||
"//vendor/github.com/aws/aws-sdk-go/service/route53:go_default_library",
|
"//vendor/github.com/aws/aws-sdk-go/service/route53:go_default_library",
|
||||||
"//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors:go_default_library",
|
"//vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/flavors:go_default_library",
|
||||||
"//vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones:go_default_library",
|
"//vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones:go_default_library",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
"github.com/aws/aws-sdk-go/service/elbv2"
|
||||||
"github.com/aws/aws-sdk-go/service/route53"
|
"github.com/aws/aws-sdk-go/service/route53"
|
||||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
|
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
|
||||||
"github.com/gophercloud/gophercloud/openstack/dns/v2/zones"
|
"github.com/gophercloud/gophercloud/openstack/dns/v2/zones"
|
||||||
|
|
@ -245,6 +246,9 @@ func (h *IntegrationTestHarness) SetupMockAWS() *awsup.MockAWSCloud {
|
||||||
AllocationId: aws.String("eipalloc-b2345678"),
|
AllocationId: aws.String("eipalloc-b2345678"),
|
||||||
}, "nat-b2345678")
|
}, "nat-b2345678")
|
||||||
|
|
||||||
|
mockELBV2.CreateTargetGroup(&elbv2.CreateTargetGroupInput{
|
||||||
|
Name: aws.String("my-external-tg"),
|
||||||
|
})
|
||||||
return cloud
|
return cloud
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
"my-other-elb"
|
"my-other-elb"
|
||||||
],
|
],
|
||||||
"TargetGroupARNs": [
|
"TargetGroupARNs": [
|
||||||
"aws:arn:elasticloadbalancing:us-test-1a:123456789012:targetgroup/my-tg/0123456789abcdef"
|
"arn:aws:elasticloadbalancing:us-test-1:000000000000:targetgroup/my-external-tg/1"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ spec:
|
||||||
subnets:
|
subnets:
|
||||||
- us-test-1a
|
- us-test-1a
|
||||||
externalLoadBalancers:
|
externalLoadBalancers:
|
||||||
- targetGroupArn: aws:arn:elasticloadbalancing:us-test-1a:123456789012:targetgroup/my-tg/0123456789abcdef
|
- targetGroupArn: arn:aws:elasticloadbalancing:us-test-1:000000000000:targetgroup/my-external-tg/1
|
||||||
- loadBalancerName: my-other-elb
|
- loadBalancerName: my-other-elb
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ resource "aws_autoscaling_group" "master-us-test-1a-masters-externallb-example-c
|
||||||
propagate_at_launch = true
|
propagate_at_launch = true
|
||||||
value = "owned"
|
value = "owned"
|
||||||
}
|
}
|
||||||
target_group_arns = ["aws:arn:elasticloadbalancing:us-test-1a:123456789012:targetgroup/my-tg/0123456789abcdef"]
|
target_group_arns = ["arn:aws:elasticloadbalancing:us-test-1:000000000000:targetgroup/my-external-tg/1"]
|
||||||
vpc_zone_identifier = [aws_subnet.us-test-1a-externallb-example-com.id]
|
vpc_zone_identifier = [aws_subnet.us-test-1a-externallb-example-com.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue