Merge pull request #82145 from shivi28/fix-controller-nodeipam-ipam-cidrset

nodeipam-controller:fix static check failures
This commit is contained in:
Kubernetes Prow Robot 2019-10-22 23:18:26 -07:00 committed by GitHub
commit 75cd65ae0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 27 deletions

View File

@ -11,7 +11,6 @@ pkg/controller/disruption
pkg/controller/garbagecollector
pkg/controller/namespace/deletion
pkg/controller/nodeipam
pkg/controller/nodeipam/ipam/cidrset
pkg/controller/podautoscaler
pkg/controller/podgc
pkg/controller/replicaset

View File

@ -700,34 +700,39 @@ func TestCIDRSetv6(t *testing.T) {
},
}
for _, tc := range cases {
_, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr)
a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize)
if err != nil {
if tc.expectErr {
continue
t.Run(tc.description, func(t *testing.T) {
_, clusterCIDR, _ := net.ParseCIDR(tc.clusterCIDRStr)
a, err := NewCIDRSet(clusterCIDR, tc.subNetMaskSize)
if gotErr := err != nil; gotErr != tc.expectErr {
t.Fatalf("NewCIDRSet(%v, %v) = %v, %v; gotErr = %t, want %t", clusterCIDR, tc.subNetMaskSize, a, err, gotErr, tc.expectErr)
}
t.Fatalf("Error allocating CIDRSet for %v", tc.description)
}
p, err := a.AllocateNext()
if err == nil && tc.expectErr {
t.Errorf("expected error but got none for %v", tc.description)
continue
}
if err != nil && !tc.expectErr {
t.Errorf("unexpected error: %v for %v", err, tc.description)
continue
}
if !tc.expectErr {
if p.String() != tc.expectedCIDR {
t.Fatalf("unexpected allocated cidr: %s for %v", p.String(), tc.description)
if a == nil {
return
}
}
p2, err := a.AllocateNext()
if !tc.expectErr {
if p2.String() != tc.expectedCIDR2 {
t.Fatalf("unexpected allocated cidr: %s for %v", p2.String(), tc.description)
p, err := a.AllocateNext()
if err == nil && tc.expectErr {
t.Errorf("a.AllocateNext() = nil, want error")
}
}
if err != nil && !tc.expectErr {
t.Errorf("a.AllocateNext() = %+v, want no error", err)
}
if !tc.expectErr {
if p != nil && p.String() != tc.expectedCIDR {
t.Fatalf("a.AllocateNext() got %+v, want %+v", p.String(), tc.expectedCIDR)
}
}
p2, err := a.AllocateNext()
if err == nil && tc.expectErr {
t.Errorf("a.AllocateNext() = nil, want error")
}
if err != nil && !tc.expectErr {
t.Errorf("a.AllocateNext() = %+v, want no error", err)
}
if !tc.expectErr {
if p2 != nil && p2.String() != tc.expectedCIDR2 {
t.Fatalf("a.AllocateNext() got %+v, want %+v", p2.String(), tc.expectedCIDR)
}
}
})
}
}