-
Notifications
You must be signed in to change notification settings - Fork 39.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56918 from feiskyer/azure-probe
Automatic merge from submit-queue (batch tested with PRs 56599, 56824, 56918, 56967, 56959). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Check both name and ports for azure health probes **What this PR does / why we need it**: Check both name and ports for azure health probes, so that probe ports could follow nodePorts changes. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #56898 **Special notes for your reviewer**: Should be cherry-picked in 1.7, 1.8, 1.9. **Release note**: ```release-note BUG FIX: Check both name and ports for azure health probes ```
- Loading branch information
Showing
3 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
pkg/cloudprovider/providers/azure/azure_loadbalancer_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package azure | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/Azure/azure-sdk-for-go/arm/network" | ||
"github.com/Azure/go-autorest/autorest/to" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFindProbe(t *testing.T) { | ||
tests := []struct { | ||
msg string | ||
existingProbe []network.Probe | ||
curProbe network.Probe | ||
expected bool | ||
}{ | ||
{ | ||
msg: "empty existing probes should return false", | ||
expected: false, | ||
}, | ||
{ | ||
msg: "probe names match while ports unmatch should return false", | ||
existingProbe: []network.Probe{ | ||
{ | ||
Name: to.StringPtr("httpProbe"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(1), | ||
}, | ||
}, | ||
}, | ||
curProbe: network.Probe{ | ||
Name: to.StringPtr("httpProbe"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(2), | ||
}, | ||
}, | ||
expected: false, | ||
}, | ||
{ | ||
msg: "probe ports match while names unmatch should return false", | ||
existingProbe: []network.Probe{ | ||
{ | ||
Name: to.StringPtr("probe1"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(1), | ||
}, | ||
}, | ||
}, | ||
curProbe: network.Probe{ | ||
Name: to.StringPtr("probe2"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(1), | ||
}, | ||
}, | ||
expected: false, | ||
}, | ||
{ | ||
msg: "both probe ports and names match should return true", | ||
existingProbe: []network.Probe{ | ||
{ | ||
Name: to.StringPtr("matchName"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(1), | ||
}, | ||
}, | ||
}, | ||
curProbe: network.Probe{ | ||
Name: to.StringPtr("matchName"), | ||
ProbePropertiesFormat: &network.ProbePropertiesFormat{ | ||
Port: to.Int32Ptr(1), | ||
}, | ||
}, | ||
expected: true, | ||
}, | ||
} | ||
|
||
for i, test := range tests { | ||
findResult := findProbe(test.existingProbe, test.curProbe) | ||
assert.Equal(t, test.expected, findResult, fmt.Sprintf("TestCase[%d]: %s", i, test.msg)) | ||
} | ||
} |