|
15 | 15 | package targetallocator
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "fmt" |
18 | 19 | "testing"
|
19 | 20 |
|
20 | 21 | "github.com/stretchr/testify/assert"
|
@@ -66,35 +67,37 @@ var tests = []test{
|
66 | 67 |
|
67 | 68 | func TestPDBWithValidStrategy(t *testing.T) {
|
68 | 69 | for _, test := range tests {
|
69 |
| - t.Run(test.name, func(t *testing.T) { |
70 |
| - targetAllocator := v1alpha1.TargetAllocator{ |
71 |
| - ObjectMeta: metav1.ObjectMeta{ |
72 |
| - Name: "my-instance", |
73 |
| - }, |
74 |
| - Spec: v1alpha1.TargetAllocatorSpec{ |
75 |
| - OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ |
76 |
| - PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{ |
77 |
| - MinAvailable: test.MinAvailable, |
78 |
| - MaxUnavailable: test.MaxUnavailable, |
| 70 | + for _, strategy := range []v1beta1.TargetAllocatorAllocationStrategy{v1beta1.TargetAllocatorAllocationStrategyPerNode, v1beta1.TargetAllocatorAllocationStrategyConsistentHashing} { |
| 71 | + t.Run(fmt.Sprintf("%s-%s", strategy, test.name), func(t *testing.T) { |
| 72 | + targetAllocator := v1alpha1.TargetAllocator{ |
| 73 | + ObjectMeta: metav1.ObjectMeta{ |
| 74 | + Name: "my-instance", |
| 75 | + }, |
| 76 | + Spec: v1alpha1.TargetAllocatorSpec{ |
| 77 | + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ |
| 78 | + PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{ |
| 79 | + MinAvailable: test.MinAvailable, |
| 80 | + MaxUnavailable: test.MaxUnavailable, |
| 81 | + }, |
79 | 82 | },
|
| 83 | + AllocationStrategy: strategy, |
80 | 84 | },
|
81 |
| - AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategyConsistentHashing, |
82 |
| - }, |
83 |
| - } |
84 |
| - configuration := config.New() |
85 |
| - pdb, err := PodDisruptionBudget(manifests.Params{ |
86 |
| - Log: logger, |
87 |
| - Config: configuration, |
88 |
| - TargetAllocator: targetAllocator, |
89 |
| - }) |
| 85 | + } |
| 86 | + configuration := config.New() |
| 87 | + pdb, err := PodDisruptionBudget(manifests.Params{ |
| 88 | + Log: logger, |
| 89 | + Config: configuration, |
| 90 | + TargetAllocator: targetAllocator, |
| 91 | + }) |
90 | 92 |
|
91 |
| - // verify |
92 |
| - assert.NoError(t, err) |
93 |
| - assert.Equal(t, "my-instance-targetallocator", pdb.Name) |
94 |
| - assert.Equal(t, "my-instance-targetallocator", pdb.Labels["app.kubernetes.io/name"]) |
95 |
| - assert.Equal(t, test.MinAvailable, pdb.Spec.MinAvailable) |
96 |
| - assert.Equal(t, test.MaxUnavailable, pdb.Spec.MaxUnavailable) |
97 |
| - }) |
| 93 | + // verify |
| 94 | + assert.NoError(t, err) |
| 95 | + assert.Equal(t, "my-instance-targetallocator", pdb.Name) |
| 96 | + assert.Equal(t, "my-instance-targetallocator", pdb.Labels["app.kubernetes.io/name"]) |
| 97 | + assert.Equal(t, test.MinAvailable, pdb.Spec.MinAvailable) |
| 98 | + assert.Equal(t, test.MaxUnavailable, pdb.Spec.MaxUnavailable) |
| 99 | + }) |
| 100 | + } |
98 | 101 | }
|
99 | 102 | }
|
100 | 103 |
|
|
0 commit comments