Skip to content

Commit b0167ca

Browse files
committed
fix UTs
Signed-off-by: Britania Rodriguez Reyes <[email protected]>
1 parent ea8def1 commit b0167ca

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

pkg/propertychecker/azure/checker_test.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ func TestValidateCapacity(t *testing.T) {
7272
errorSubstring: "invalid capacity value",
7373
},
7474
{
75-
name: "invalid value of zero for capacity",
76-
value: "0",
77-
operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
78-
wantError: true,
79-
errorSubstring: fmt.Sprintf("capacity value cannot be below minimum %d after adjustment", minVMInstanceCapacity),
75+
name: "invalid value of zero for capacity replaced with minimum",
76+
value: "0",
77+
operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
78+
wantValue: 1,
8079
},
8180
{
8281
name: "capacity equal to max limit with GreaterThan operator",
@@ -86,12 +85,10 @@ func TestValidateCapacity(t *testing.T) {
8685
errorSubstring: "exceeds maximum allowed value",
8786
},
8887
{
89-
name: "unsupported operator with capacity of 1",
90-
value: "1",
91-
operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
92-
wantValue: 0,
93-
wantError: true,
94-
errorSubstring: fmt.Sprintf("capacity value cannot be below minimum %d after adjustment", minVMInstanceCapacity),
88+
name: "capacity at minimum limit with GreaterThanOrEqualTo operator",
89+
value: "1",
90+
operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
91+
wantValue: 1,
9592
},
9693
{
9794
name: "capacity equal to max limit with supported operator",
@@ -187,9 +184,8 @@ func TestExtractCapacityRequirements(t *testing.T) {
187184
Operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
188185
Values: []string{"1"},
189186
},
190-
wantSKU: "Standard_B2ms",
191-
wantError: true,
192-
errorSubstring: fmt.Sprintf("capacity value cannot be below minimum %d after adjustment", minVMInstanceCapacity),
187+
wantSKU: "Standard_B2ms",
188+
wantCapacityValue: 1,
193189
},
194190
{
195191
name: "invalid Azure SKU capacity property with decimal",
@@ -421,18 +417,17 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
421417
errorSubstring: "unsupported operator \"Eq\" for SKU capacity property, only GreaterThan (Gt) and GreaterThanOrEqualTo (Ge) are supported",
422418
},
423419
{
424-
name: "invalid value in requirement",
420+
name: "too low value in requirement replaced with minimum capacity",
425421
cluster: cluster,
426422
sku: validSKU,
427-
targetCapacity: 0,
423+
targetCapacity: 1,
428424
req: placementv1beta1.PropertySelectorRequirement{
429425
Name: fmt.Sprintf(azure.CapacityPerSKUPropertyTmpl, validSKU),
430426
Operator: placementv1beta1.PropertySelectorGreaterThanOrEqualTo,
431427
Values: []string{"0"},
432428
},
433429
mockStatusCode: http.StatusOK,
434-
wantError: true,
435-
errorSubstring: fmt.Sprintf("capacity value cannot be below minimum %d after adjustment", minVMInstanceCapacity),
430+
wantAvailable: true,
436431
},
437432
{
438433
name: "cases-insensitive request - available SKU",

pkg/scheduler/framework/plugins/clusteraffinity/types_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ func TestClusterRequirementMatches_WithPropertyChecker(t *testing.T) {
13601360
want: true,
13611361
},
13621362
{
1363-
name: "op >=, not matched (min limit)",
1363+
name: "op >=, matched (min limit)",
13641364
matchExpression: []placementv1beta1.PropertySelectorRequirement{
13651365
{
13661366
Name: validPropertyName,
@@ -1372,8 +1372,8 @@ func TestClusterRequirementMatches_WithPropertyChecker(t *testing.T) {
13721372
},
13731373
cluster: cluster,
13741374
sku: "Standard_D2s_v3",
1375-
targetCapacity: 0,
1376-
wantError: true,
1375+
targetCapacity: 1,
1376+
want: true,
13771377
},
13781378
{
13791379
name: "op >, not matched",

0 commit comments

Comments
 (0)