Skip to content

Commit

Permalink
chore(applicationautoscaling): add missing PredefinedMetricType enum …
Browse files Browse the repository at this point in the history
…values (#31115)

### Issue # (if applicable)

Closes #31113

### Reason for this change

There are three `PredefinedMetricType` values missing from the enum:

* SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution
* SageMakerVariantConcurrentRequestsPerModelHighResolution
* WorkSpacesAverageUserSessionsCapacityUtilization

https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html

### Description of changes

Adds the missing enums

### Description of how you validated changes

Added unit tests

### Checklist
- [ X ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
shahks authored Aug 19, 2024
1 parent c159e77 commit c1c800e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,19 @@ export enum PredefinedMetric {
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ELASTICACHE_DATABASE_CAPACITY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE = 'ElastiCacheDatabaseCapacityUsageCountedForEvictPercentage',
/**
* SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION = 'SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution',
/**
* SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION = 'SageMakerVariantConcurrentRequestsPerModelHighResolution',
/**
* WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION = 'WorkSpacesAverageUserSessionsCapacityUtilization',
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,66 @@ describe('target tracking', () => {
});
});

test('test setup target tracking on predefined metric for SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION', () => {
// GIVEN
const stack = new cdk.Stack();
const target = createScalableTarget(stack);

// WHEN
target.scaleToTrackMetric('Tracking', {
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION,
targetValue: 0.5,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'SageMakerVariantConcurrentRequestsPerModelHighResolution' },
TargetValue: 0.5,
},
});
});

test('test setup target tracking on predefined metric for SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION', () => {
// GIVEN
const stack = new cdk.Stack();
const target = createScalableTarget(stack);

// WHEN
target.scaleToTrackMetric('Tracking', {
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION,
targetValue: 0.5,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution' },
TargetValue: 0.5,
},
});
});

test('test setup target tracking on predefined metric for WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION', () => {
// GIVEN
const stack = new cdk.Stack();
const target = createScalableTarget(stack);

// WHEN
target.scaleToTrackMetric('Tracking', {
predefinedMetric: appscaling.PredefinedMetric.WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION,
targetValue: 0.5,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'WorkSpacesAverageUserSessionsCapacityUtilization' },
TargetValue: 0.5,
},
});
});

test('test setup target tracking on custom metric', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit c1c800e

Please sign in to comment.