|
4 | 4 | package knative |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "strconv" |
8 | 7 | "testing" |
9 | 8 |
|
10 | 9 | "github.com/stretchr/testify/assert" |
@@ -113,6 +112,17 @@ func TestGetPodGroupMetadata(t *testing.T) { |
113 | 112 | } |
114 | 113 |
|
115 | 114 | func TestGetPodGroupMetadata_MinScale(t *testing.T) { |
| 115 | + for minScale, expectedMinAvailable := range map[string]int32{ |
| 116 | + "3": 3, |
| 117 | + "0": 0, // scale-to-zero: no gang requirement |
| 118 | + } { |
| 119 | + t.Run("min-scale="+minScale, func(t *testing.T) { |
| 120 | + testGetPodGroupMetadataMinScale(t, minScale, expectedMinAvailable) |
| 121 | + }) |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | +func testGetPodGroupMetadataMinScale(t *testing.T, minScale string, expectedMinAvailable int32) { |
116 | 126 | service := &unstructured.Unstructured{ |
117 | 127 | Object: map[string]interface{}{ |
118 | 128 | "kind": "Service", |
@@ -156,7 +166,7 @@ func TestGetPodGroupMetadata_MinScale(t *testing.T) { |
156 | 166 | Namespace: "test_namespace", |
157 | 167 | UID: "2", |
158 | 168 | Annotations: map[string]string{ |
159 | | - "autoscaling.knative.dev/min-scale": "3", |
| 169 | + "autoscaling.knative.dev/min-scale": minScale, |
160 | 170 | }, |
161 | 171 | }, |
162 | 172 | Spec: knative.RevisionSpec{}, |
@@ -197,7 +207,7 @@ func TestGetPodGroupMetadata_MinScale(t *testing.T) { |
197 | 207 | assert.Equal(t, "pg-revision-2", metadata.Name) |
198 | 208 | assert.Equal(t, constants.InferencePriorityClass, metadata.PriorityClassName) |
199 | 209 | assert.Equal(t, "test_queue", metadata.Queue) |
200 | | - assert.Equal(t, "3", strconv.Itoa(int(metadata.MinAvailable))) |
| 210 | + assert.Equal(t, expectedMinAvailable, metadata.MinAvailable) |
201 | 211 | } |
202 | 212 |
|
203 | 213 | func TestGetPodGroupMetadataBackwardsCompatibility(t *testing.T) { |
|
0 commit comments