Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lb: add DescribeLoadBalancer & CreateLoadBalancer #680

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aws/fake/cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (m *CFClient) UpdateStack(params *cloudformation.UpdateStackInput) (*cloudf
// Update stack needs to use different variable to register change history,
// so createStack and updateStack mocks don't mess with each other states.

m.tagCreationHistory = append(m.tagCreationHistory, params.Tags)
m.paramCreationHistory = append(m.paramCreationHistory, params.Parameters)
m.templateCreationHistory = append(m.templateCreationHistory, *params.TemplateBody)

out, ok := m.Outputs.UpdateStack.response.(*cloudformation.UpdateStackOutput)
if !ok {
return nil, m.Outputs.UpdateStack.err
Expand Down
26 changes: 23 additions & 3 deletions aws/fake/elbv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ type ELBv2Outputs struct {
DescribeTags *APIResponse
DescribeTargetGroups *APIResponse
DescribeTargetHealth *APIResponse
CreateLoadBalancer *APIResponse
DescribeLoadBalancer *APIResponse
}

type ELBv2Client struct {
elbv2iface.ELBV2API
Outputs ELBv2Outputs
Rtinputs []*elbv2.RegisterTargetsInput
Dtinputs []*elbv2.DeregisterTargetsInput
Outputs ELBv2Outputs
Rtinputs []*elbv2.RegisterTargetsInput
Dtinputs []*elbv2.DeregisterTargetsInput
LBinputes []*elbv2.CreateLoadBalancerInput
}

func (m *ELBv2Client) RegisterTargets(in *elbv2.RegisterTargetsInput) (*elbv2.RegisterTargetsOutput, error) {
Expand Down Expand Up @@ -67,6 +70,23 @@ func (m *ELBv2Client) DescribeTargetHealth(*elbv2.DescribeTargetHealthInput) (*e
return out, m.Outputs.DescribeTargetHealth.err
}

func (m *ELBv2Client) CreateLoadBalancer(in *elbv2.CreateLoadBalancerInput) (*elbv2.CreateLoadBalancerOutput, error) {
m.LBinputes = append(m.LBinputes, in)
out, ok := m.Outputs.CreateLoadBalancer.response.(*elbv2.CreateLoadBalancerOutput)
if !ok {
return nil, m.Outputs.CreateLoadBalancer.err
}
return out, m.Outputs.CreateLoadBalancer.err
}

func (m *ELBv2Client) DescribeLoadBalancers(in *elbv2.DescribeLoadBalancersInput) (*elbv2.DescribeLoadBalancersOutput, error) {
out, ok := m.Outputs.DescribeLoadBalancer.response.(*elbv2.DescribeLoadBalancersOutput)
if !ok {
return nil, m.Outputs.DescribeLoadBalancer.err
}
return out, m.Outputs.DescribeLoadBalancer.err
}

func MockDeregisterTargetsOutput() *elbv2.DeregisterTargetsOutput {
return &elbv2.DeregisterTargetsOutput{}
}
9 changes: 8 additions & 1 deletion worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ func TestResourceConversionOneToOne(tt *testing.T) {
clusterID := "aws:123:eu-central-1:kube-1"
vpcID := "1"
securityGroupID := "42"
running := int64(16) // See https://github.com/aws/aws-sdk-go/blob/master/service/ec2/api.go, type InstanceState
// See https://github.com/aws/aws-sdk-go/blob/master/service/ec2/api.go, type InstanceState
// * 0 : pending
// * 16 : running
// * 32 : shutting-down
// * 48 : terminated
// * 64 : stopping
// * 80 : stopped
running := int64(16)

for _, scenario := range []struct {
name string
Expand Down
Loading