Skip to content

Commit

Permalink
Merge pull request #5747 from paleozogt/fix/asg-resource-tags-1.24
Browse files Browse the repository at this point in the history
tests for asg resource tags fix 1.24
  • Loading branch information
k8s-ci-robot authored May 16, 2023
2 parents 47ca6e0 + e813167 commit 605a6b0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func TestExtractAllocatableResourcesFromAsg(t *testing.T) {
Key: aws.String("k8s.io/cluster-autoscaler/node-template/resources/ephemeral-storage"),
Value: aws.String("20G"),
},
{
Key: aws.String("k8s.io/cluster-autoscaler/node-template/resources/custom-resource"),
Value: aws.String("5"),
},
}

labels := extractAllocatableResourcesFromAsg(tags)
Expand All @@ -132,6 +136,7 @@ func TestExtractAllocatableResourcesFromAsg(t *testing.T) {
assert.Equal(t, (&expectedMemory).String(), labels["memory"].String())
expectedEphemeralStorage := resource.MustParse("20G")
assert.Equal(t, (&expectedEphemeralStorage).String(), labels["ephemeral-storage"].String())
assert.Equal(t, resource.NewQuantity(5, resource.DecimalSI).String(), labels["custom-resource"].String())
}

func TestGetAsgOptions(t *testing.T) {
Expand Down Expand Up @@ -400,6 +405,8 @@ func TestBuildNodeFromTemplate(t *testing.T) {
// Node with custom resource
ephemeralStorageKey := "ephemeral-storage"
ephemeralStorageValue := int64(20)
customResourceKey := "custom-resource"
customResourceValue := int64(5)
vpcIPKey := "vpc.amazonaws.com/PrivateIPv4Address"
observedNode, observedErr := awsManager.buildNodeFromTemplate(asg, &asgTemplate{
InstanceType: c5Instance,
Expand All @@ -408,12 +415,19 @@ func TestBuildNodeFromTemplate(t *testing.T) {
Key: aws.String(fmt.Sprintf("k8s.io/cluster-autoscaler/node-template/resources/%s", ephemeralStorageKey)),
Value: aws.String(strconv.FormatInt(ephemeralStorageValue, 10)),
},
{
Key: aws.String(fmt.Sprintf("k8s.io/cluster-autoscaler/node-template/resources/%s", customResourceKey)),
Value: aws.String(strconv.FormatInt(customResourceValue, 10)),
},
},
})
assert.NoError(t, observedErr)
esValue, esExist := observedNode.Status.Capacity[apiv1.ResourceName(ephemeralStorageKey)]
assert.True(t, esExist)
assert.Equal(t, int64(20), esValue.Value())
crValue, crExist := observedNode.Status.Capacity[apiv1.ResourceName(customResourceKey)]
assert.True(t, crExist)
assert.Equal(t, int64(5), crValue.Value())
_, ipExist := observedNode.Status.Capacity[apiv1.ResourceName(vpcIPKey)]
assert.False(t, ipExist)

Expand Down

0 comments on commit 605a6b0

Please sign in to comment.