Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mneverov committed Jan 3, 2025
1 parent 3a0ac58 commit 1bdc649
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/ipam/multi_cidr_priority_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestLess(t *testing.T) {

func createTestPriorityQueueItem(name, cidr, selectorString string, labelMatchCount, perNodeHostBits int) *PriorityQueueItem {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(cidr)
cidrSet, _ := multicidrset.NewMultiCIDRSet(clusterCIDR, perNodeHostBits)
cidrSet, _ := multicidrset.NewMultiCIDRSet(name, clusterCIDR, perNodeHostBits)

return &PriorityQueueItem{
clusterCIDR: &multicidrset.ClusterCIDR{
Expand Down
24 changes: 12 additions & 12 deletions pkg/controller/ipam/multicidrset/multi_cidr_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestCIDRSetFullyAllocated(t *testing.T) {
}
for _, tc := range cases {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(tc.clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, tc.perNodeHostBits)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, tc.perNodeHostBits)
if err != nil {
t.Fatalf("unexpected error: %v for %v", err, tc.description)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestIndexToCIDRBlock(t *testing.T) {
}
for _, tc := range cases {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(tc.clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, tc.perNodeHostBits)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, tc.perNodeHostBits)
if err != nil {
t.Fatalf("error for %v ", tc.description)
}
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestCIDRSet_RandomishAllocation(t *testing.T) {
}
for _, tc := range cases {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(tc.clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, 8)
if err != nil {
t.Fatalf("Error allocating CIDRSet for %v", tc.description)
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestCIDRSet_AllocationOccupied(t *testing.T) {
}
for _, tc := range cases {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(tc.clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, 8)
if err != nil {
t.Fatalf("Error allocating CIDRSet for %v", tc.description)
}
Expand Down Expand Up @@ -412,7 +412,7 @@ func TestDoubleOccupyRelease(t *testing.T) {
numAllocatable24s := (1 << 8) - 3

_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, 8)
if err != nil {
t.Fatalf("Error allocating CIDRSet")
}
Expand Down Expand Up @@ -575,7 +575,7 @@ func TestGetBitforCIDR(t *testing.T) {
t.Fatalf("unexpected error: %v for %v", err, tc.description)
}

cs, err := NewMultiCIDRSet(clusterCIDR, tc.perNodeHostBits)
cs, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, tc.perNodeHostBits)
if err != nil {
t.Fatalf("Error allocating CIDRSet for %v", tc.description)
}
Expand Down Expand Up @@ -636,7 +636,7 @@ func TestCIDRSetv6(t *testing.T) {
for _, tc := range cases {
t.Run(tc.description, func(t *testing.T) {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(tc.clusterCIDRStr)
a, err := NewMultiCIDRSet(clusterCIDR, tc.perNodeHostBits)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, tc.perNodeHostBits)
if gotErr := err != nil; gotErr != tc.expectErr {
t.Fatalf("NewMultiCIDRSet(%v, %v) = %v, %v; gotErr = %t, want %t", clusterCIDR, tc.perNodeHostBits, a, err, gotErr, tc.expectErr)
}
Expand Down Expand Up @@ -677,7 +677,7 @@ func TestMultiCIDRSetMetrics(t *testing.T) {
clearMetrics(map[string]string{"clusterCIDR": cidr})

// We have 256 free cidrs
a, err := NewMultiCIDRSet(clusterCIDR, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, 8)
if err != nil {
t.Fatalf("unexpected error creating MultiCIDRSet: %v", err)
}
Expand Down Expand Up @@ -737,7 +737,7 @@ func TestMultiCIDRSetMetricsHistogram(t *testing.T) {
clearMetrics(map[string]string{"clusterCIDR": cidr})

// We have 256 free cidrs.
a, err := NewMultiCIDRSet(clusterCIDR, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, 8)
if err != nil {
t.Fatalf("unexpected error creating MultiCIDRSet: %v", err)
}
Expand Down Expand Up @@ -785,7 +785,7 @@ func TestMultiCIDRSetMetricsDual(t *testing.T) {
_, clusterCIDRv4, _ := utilnet.ParseCIDRSloppy(cidrIPv4)
clearMetrics(map[string]string{"clusterCIDR": cidrIPv4})

a, err := NewMultiCIDRSet(clusterCIDRv4, 8)
a, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDRv4, 8)
if err != nil {
t.Fatalf("unexpected error creating MultiCIDRSet: %v", err)
}
Expand All @@ -806,7 +806,7 @@ func TestMultiCIDRSetMetricsDual(t *testing.T) {
_, clusterCIDRv6, _ := utilnet.ParseCIDRSloppy(cidrIPv6)
clearMetrics(map[string]string{"clusterCIDR": cidrIPv6})

b, err := NewMultiCIDRSet(clusterCIDRv6, 64)
b, err := NewMultiCIDRSet("test-cluster-cidr", clusterCIDRv6, 64)
if err != nil {
t.Fatalf("unexpected error creating MultiCIDRSet: %v", err)
}
Expand Down Expand Up @@ -951,7 +951,7 @@ func expectMetrics(t *testing.T, label string, em testMetrics) {
// Benchmarks
func benchmarkAllocateAllIPv6(cidr string, perNodeHostBits int, b *testing.B) {
_, clusterCIDR, _ := utilnet.ParseCIDRSloppy(cidr)
a, _ := NewMultiCIDRSet(clusterCIDR, perNodeHostBits)
a, _ := NewMultiCIDRSet("test-cluster-cidr", clusterCIDR, perNodeHostBits)
for n := 0; n < b.N; n++ {
// Allocate the whole range + 1.
for i := 0; i <= a.MaxCIDRs; i++ {
Expand Down

0 comments on commit 1bdc649

Please sign in to comment.