mirror of https://github.com/k3s-io/k3s
Merge pull request #60555 from zhangxiaoyu-zidif/add-unit-test-for-nodenames-slice-comparison
Automatic merge from submit-queue. 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>. add unit test case for nodenames comparison **What this PR does / why we need it**: ref https://github.com/kubernetes/kubernetes/pull/60486 **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 # **Special notes for your reviewer**: please merge it after https://github.com/kubernetes/kubernetes/pull/60486 **Release note**: ```release-note NONE ```pull/6/head
commit
07240b7166
|
@ -777,13 +777,21 @@ func TestServiceCache(t *testing.T) {
|
|||
//Test a utility functions as its not easy to unit test nodeSyncLoop directly
|
||||
func TestNodeSlicesEqualForLB(t *testing.T) {
|
||||
numNodes := 10
|
||||
nArray := make([]*v1.Node, 10)
|
||||
|
||||
nArray := make([]*v1.Node, numNodes)
|
||||
mArray := make([]*v1.Node, numNodes)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
nArray[i] = &v1.Node{}
|
||||
nArray[i].Name = fmt.Sprintf("node1")
|
||||
nArray[i].Name = fmt.Sprintf("node%d", i)
|
||||
}
|
||||
for i := 0; i < numNodes; i++ {
|
||||
mArray[i] = &v1.Node{}
|
||||
mArray[i].Name = fmt.Sprintf("node%d", i+1)
|
||||
}
|
||||
|
||||
if !nodeSlicesEqualForLB(nArray, nArray) {
|
||||
t.Errorf("nodeSlicesEqualForLB() Expected=true Obtained=false")
|
||||
}
|
||||
if nodeSlicesEqualForLB(nArray, mArray) {
|
||||
t.Errorf("nodeSlicesEqualForLB() Expected=false Obtained=true")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue