Skip to content

Commit

Permalink
feat(stepfunctions-tasks): add new allocation strategies for spot ins…
Browse files Browse the repository at this point in the history
…tance fleets in EmrCreateCluster

change unit tests

change unit tests
  • Loading branch information
go-to-k committed Dec 29, 2023
1 parent 9d8b06f commit 7331e32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,20 @@ export namespace EmrCreateCluster {
* Capacity-optimized, which launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching.
*/
CAPACITY_OPTIMIZED = 'capacity-optimized',
/**
* Price-capacity-optimized, which launches instances from Spot Instance pools with the highest capacity availability for the number of instances that are launching.
*
* Recommended.
*/
PRICE_CAPACITY_OPTIMIZED = 'price-capacity-optimized',
/**
* Lowest-price, which launches instances from the lowest priced pool that has available capacity.
*/
LOWEST_PRICE = 'lowest-price',
/**
* Diversified, which launches instances across all Spot capacity pools.
*/
DIVERSIFIED = 'diversified',
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Template, Match } from '../../../assertions';
import { Template } from '../../../assertions';
import * as iam from '../../../aws-iam';
import * as sfn from '../../../aws-stepfunctions';
import * as cdk from '../../../core';
Expand Down Expand Up @@ -883,7 +883,12 @@ test('Create Cluster with Instances configuration', () => {
});
});

test('Create Cluster with InstanceFleet with allocation strategy=capacity-optimized for Spot instances', () => {
test.each([
[EmrCreateCluster.SpotAllocationStrategy.CAPACITY_OPTIMIZED, 'capacity-optimized'],
[EmrCreateCluster.SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED, 'price-capacity-optimized'],
[EmrCreateCluster.SpotAllocationStrategy.LOWEST_PRICE, 'lowest-price'],
[EmrCreateCluster.SpotAllocationStrategy.DIVERSIFIED, 'diversified'],
])('Create Cluster with InstanceFleet with allocation strategy %s for Spot instances', (strategy, expected) => {
// WHEN
const task = new EmrCreateCluster(stack, 'Task', {
instances: {
Expand Down Expand Up @@ -914,7 +919,7 @@ test('Create Cluster with InstanceFleet with allocation strategy=capacity-optimi
}],
launchSpecifications: {
spotSpecification: {
allocationStrategy: EmrCreateCluster.SpotAllocationStrategy.CAPACITY_OPTIMIZED,
allocationStrategy: strategy,
blockDurationMinutes: 1,
timeoutAction: EmrCreateCluster.SpotTimeoutAction.TERMINATE_CLUSTER,
timeoutDurationMinutes: 1,
Expand Down Expand Up @@ -978,7 +983,7 @@ test('Create Cluster with InstanceFleet with allocation strategy=capacity-optimi
}],
LaunchSpecifications: {
SpotSpecification: {
AllocationStrategy: 'capacity-optimized',
AllocationStrategy: expected,
BlockDurationMinutes: 1,
TimeoutAction: 'TERMINATE_CLUSTER',
TimeoutDurationMinutes: 1,
Expand Down

0 comments on commit 7331e32

Please sign in to comment.