Skip to content

Commit

Permalink
Reduce flakes in TestLoadBalancerProfile() (#3129)
Browse files Browse the repository at this point in the history
  • Loading branch information
lranjbar authored Aug 31, 2023
1 parent dcaa1ad commit e4d4c73
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/cluster/loadbalancerprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func TestReconcileLoadBalancerProfile(t *testing.T) {
loadBalancersClient *mock_network.MockLoadBalancersClient,
publicIPAddressClient *mock_network.MockPublicIPAddressesClient,
ctx context.Context)
expectedErr error
expectedErr []error
}{
{
name: "default managed ips",
Expand Down Expand Up @@ -792,7 +792,7 @@ func TestReconcileLoadBalancerProfile(t *testing.T) {
},
},
},
expectedErr: fmt.Errorf("lb update failed"),
expectedErr: []error{fmt.Errorf("lb update failed")},
},
{
name: "managed ip cleanup errors are propagated when cleanup fails",
Expand Down Expand Up @@ -866,7 +866,7 @@ func TestReconcileLoadBalancerProfile(t *testing.T) {
},
},
},
expectedErr: fmt.Errorf("failed to cleanup unused managed ips\ndeletion of unused managed ip uuid1-outbound-pip-v4 failed with error: error\ndeletion of unused managed ip uuid2-outbound-pip-v4 failed with error: error"),
expectedErr: []error{fmt.Errorf("failed to cleanup unused managed ips\ndeletion of unused managed ip uuid1-outbound-pip-v4 failed with error: error\ndeletion of unused managed ip uuid2-outbound-pip-v4 failed with error: error"), fmt.Errorf("failed to cleanup unused managed ips\ndeletion of unused managed ip uuid2-outbound-pip-v4 failed with error: error\ndeletion of unused managed ip uuid1-outbound-pip-v4 failed with error: error")},
},
{
name: "all errors propagated",
Expand Down Expand Up @@ -937,7 +937,7 @@ func TestReconcileLoadBalancerProfile(t *testing.T) {
},
},
},
expectedErr: fmt.Errorf("multiple errors occurred while updating outbound-rule-v4\nfailed to create ip\nfailed to cleanup unused managed ips\ndeletion of unused managed ip uuid1-outbound-pip-v4 failed with error: error"),
expectedErr: []error{fmt.Errorf("multiple errors occurred while updating outbound-rule-v4\nfailed to create ip\nfailed to cleanup unused managed ips\ndeletion of unused managed ip uuid1-outbound-pip-v4 failed with error: error")},
},
} {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -966,7 +966,12 @@ func TestReconcileLoadBalancerProfile(t *testing.T) {

// Run reconcileLoadBalancerProfile and assert the correct results
err = tt.m.reconcileLoadBalancerProfile(ctx)
assert.Equal(t, tt.expectedErr, err, "Unexpected error exception")
// Expect error to be in the array of errors provided or to be nil
if tt.expectedErr != nil {
assert.Contains(t, tt.expectedErr, err, "Unexpected error exception")
} else {
assert.Equal(t, nil, err, "Unexpected error exception")
}
assert.Equal(t, &tt.expectedLoadBalancerProfile, tt.m.doc.OpenShiftCluster.Properties.NetworkProfile.LoadBalancerProfile)
})
}
Expand Down

0 comments on commit e4d4c73

Please sign in to comment.