Skip to content

Commit 30992e1

Browse files
committed
Fix flaky integration test
1 parent f0f88b0 commit 30992e1

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

controllers/awscluster_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestAWSClusterReconciler_IntegrationTests(t *testing.T) {
6464
mockCtrl.Finish()
6565
}
6666

67-
t.Run("Should successfully reconcile AWCluster creation with unmanaged VPC", func(t *testing.T) {
67+
t.Run("Should successfully reconcile AWSCluster creation with unmanaged VPC", func(t *testing.T) {
6868
g := NewWithT(t)
6969
mockCtrl = gomock.NewController(t)
7070
ec2Mock := mock_ec2iface.NewMockEC2API(mockCtrl)

controllers/helpers_test.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ var (
6161
},
6262
}
6363
expectedTags = []*elb.Tag{
64+
{
65+
Key: aws.String("Name"),
66+
Value: lbName,
67+
},
6468
{
6569
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/cluster/test-cluster"),
6670
Value: aws.String("owned"),
@@ -69,10 +73,6 @@ var (
6973
Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/role"),
7074
Value: aws.String("apiserver"),
7175
},
72-
{
73-
Key: aws.String("Name"),
74-
Value: lbName,
75-
},
7676
}
7777
)
7878

@@ -162,23 +162,19 @@ func mockedCreateLBCalls(t *testing.T, m *mock_elbiface.MockELBAPIMockRecorder)
162162
LoadBalancerName: aws.String(""),
163163
})).MaxTimes(1)
164164

165-
m.AddTags(gomock.Eq(&elb.AddTagsInput{
166-
LoadBalancerNames: aws.StringSlice([]string{""}),
167-
Tags: expectedTags,
168-
})).Do(func(actual *elb.AddTagsInput) (*elb.AddTagsOutput, error) {
169-
sortTagsByKey := func(tags []*elb.Tag) {
170-
sort.Slice(tags, func(i, j int) bool {
171-
return *(tags[i].Key) < *(tags[j].Key)
172-
})
173-
}
165+
m.AddTags(gomock.AssignableToTypeOf(&elb.AddTagsInput{})).Return(&elb.AddTagsOutput{}, nil).Do(
166+
func(actual *elb.AddTagsInput) {
167+
sortTagsByKey := func(tags []*elb.Tag) {
168+
sort.Slice(tags, func(i, j int) bool {
169+
return *(tags[i].Key) < *(tags[j].Key)
170+
})
171+
}
174172

175-
sortTagsByKey(actual.Tags)
176-
sortTagsByKey(expectedTags)
177-
if !reflect.DeepEqual(expectedTags, actual.Tags) {
178-
t.Fatalf("Actual AddTagsInput did not match expected, Actual : %v, Expected: %v", actual.Tags, expectedTags)
179-
}
180-
return &elb.AddTagsOutput{}, nil
181-
}).AnyTimes()
173+
sortTagsByKey(actual.Tags)
174+
if !reflect.DeepEqual(expectedTags, actual.Tags) {
175+
t.Fatalf("Actual AddTagsInput did not match expected, Actual : %v, Expected: %v", actual.Tags, expectedTags)
176+
}
177+
}).AnyTimes()
182178
m.RemoveTags(gomock.Eq(&elb.RemoveTagsInput{
183179
LoadBalancerNames: aws.StringSlice([]string{""}),
184180
Tags: []*elb.TagKeyOnly{

0 commit comments

Comments
 (0)