@@ -921,7 +921,7 @@ test.each([
921
921
allocationStrategy : strategy ,
922
922
blockDurationMinutes : 1 ,
923
923
timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
924
- timeoutDurationMinutes : 5 ,
924
+ timeout : cdk . Duration . minutes ( 5 ) ,
925
925
} ,
926
926
} ,
927
927
name : 'Main' ,
@@ -1033,7 +1033,7 @@ test('Create Cluster with InstanceFleet for Spot instances', () => {
1033
1033
spotSpecification : {
1034
1034
blockDurationMinutes : 1 ,
1035
1035
timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
1036
- timeoutDurationMinutes : 5 ,
1036
+ timeout : cdk . Duration . minutes ( 5 ) ,
1037
1037
} ,
1038
1038
} ,
1039
1039
name : 'Main' ,
@@ -1219,7 +1219,63 @@ test('Create Cluster with InstanceFleet for On-Demand instances', () => {
1219
1219
} ) ;
1220
1220
} ) ;
1221
1221
1222
- test ( 'Throws if timeoutDurationMinutes for Spot instances is less than 5' , ( ) => {
1222
+ test ( 'Throws if timeout for Spot instances is less than 5 minutes' , ( ) => {
1223
+ // GIVEN
1224
+ const task = new EmrCreateCluster ( stack , 'Task' , {
1225
+ instances : {
1226
+ instanceFleets : [ {
1227
+ instanceFleetType : EmrCreateCluster . InstanceRoleType . MASTER ,
1228
+ launchSpecifications : {
1229
+ spotSpecification : {
1230
+ timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
1231
+ timeout : cdk . Duration . minutes ( 4 ) ,
1232
+ } ,
1233
+ } ,
1234
+ name : 'Main' ,
1235
+ targetSpotCapacity : 1 ,
1236
+ } ] ,
1237
+ } ,
1238
+ clusterRole,
1239
+ name : 'Cluster' ,
1240
+ serviceRole,
1241
+ integrationPattern : sfn . IntegrationPattern . REQUEST_RESPONSE ,
1242
+ } ) ;
1243
+
1244
+ // THEN
1245
+ expect ( ( ) => {
1246
+ task . toStateJson ( ) ;
1247
+ } ) . toThrow ( / t i m e o u t m u s t b e b e t w e e n 5 a n d 1 4 4 0 m i n u t e s , g o t 4 / ) ;
1248
+ } ) ;
1249
+
1250
+ test ( 'Throws if timeout for Spot instances is greater than 1440 minutes' , ( ) => {
1251
+ // GIVEN
1252
+ const task = new EmrCreateCluster ( stack , 'Task' , {
1253
+ instances : {
1254
+ instanceFleets : [ {
1255
+ instanceFleetType : EmrCreateCluster . InstanceRoleType . MASTER ,
1256
+ launchSpecifications : {
1257
+ spotSpecification : {
1258
+ timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
1259
+ timeout : cdk . Duration . minutes ( 1441 ) ,
1260
+ } ,
1261
+ } ,
1262
+ name : 'Main' ,
1263
+ targetSpotCapacity : 1 ,
1264
+ } ] ,
1265
+ } ,
1266
+ clusterRole,
1267
+ name : 'Cluster' ,
1268
+ serviceRole,
1269
+ integrationPattern : sfn . IntegrationPattern . REQUEST_RESPONSE ,
1270
+ } ) ;
1271
+
1272
+ // THEN
1273
+ expect ( ( ) => {
1274
+ task . toStateJson ( ) ;
1275
+ } ) . toThrow ( / t i m e o u t m u s t b e b e t w e e n 5 a n d 1 4 4 0 m i n u t e s , g o t 1 4 4 1 m i n u t e s ./ ) ;
1276
+ } ) ;
1277
+
1278
+ test ( 'Throws if timeoutDurationMinutes for Spot instances is less than 5 minutes' , ( ) => {
1223
1279
// GIVEN
1224
1280
const task = new EmrCreateCluster ( stack , 'Task' , {
1225
1281
instances : {
@@ -1244,10 +1300,10 @@ test('Throws if timeoutDurationMinutes for Spot instances is less than 5', () =>
1244
1300
// THEN
1245
1301
expect ( ( ) => {
1246
1302
task . toStateJson ( ) ;
1247
- } ) . toThrow ( / t i m e o u t D u r a t i o n M i n u t e s m u s t b e b e t w e e n 5 a n d 1 4 4 0 , g o t 4 / ) ;
1303
+ } ) . toThrow ( / t i m e o u t m u s t b e b e t w e e n 5 a n d 1 4 4 0 m i n u t e s , g o t 4 m i n u t e s . / ) ;
1248
1304
} ) ;
1249
1305
1250
- test ( 'Throws if timeoutDurationMinutes for Spot instances is greater than 1440' , ( ) => {
1306
+ test ( 'Throws if timeoutDurationMinutes for Spot instances is greater than 1440 minutes ' , ( ) => {
1251
1307
// GIVEN
1252
1308
const task = new EmrCreateCluster ( stack , 'Task' , {
1253
1309
instances : {
@@ -1272,7 +1328,63 @@ test('Throws if timeoutDurationMinutes for Spot instances is greater than 1440',
1272
1328
// THEN
1273
1329
expect ( ( ) => {
1274
1330
task . toStateJson ( ) ;
1275
- } ) . toThrow ( / t i m e o u t D u r a t i o n M i n u t e s m u s t b e b e t w e e n 5 a n d 1 4 4 0 , g o t 1 4 4 1 / ) ;
1331
+ } ) . toThrow ( / t i m e o u t m u s t b e b e t w e e n 5 a n d 1 4 4 0 m i n u t e s , g o t 1 4 4 1 m i n u t e s ./ ) ;
1332
+ } ) ;
1333
+
1334
+ test ( 'Throws if neither timeout nor timeoutDurationMinutes is specified' , ( ) => {
1335
+ // GIVEN
1336
+ const task = new EmrCreateCluster ( stack , 'Task' , {
1337
+ instances : {
1338
+ instanceFleets : [ {
1339
+ instanceFleetType : EmrCreateCluster . InstanceRoleType . MASTER ,
1340
+ launchSpecifications : {
1341
+ spotSpecification : {
1342
+ timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
1343
+ } ,
1344
+ } ,
1345
+ name : 'Main' ,
1346
+ targetSpotCapacity : 1 ,
1347
+ } ] ,
1348
+ } ,
1349
+ clusterRole,
1350
+ name : 'Cluster' ,
1351
+ serviceRole,
1352
+ integrationPattern : sfn . IntegrationPattern . REQUEST_RESPONSE ,
1353
+ } ) ;
1354
+
1355
+ // THEN
1356
+ expect ( ( ) => {
1357
+ task . toStateJson ( ) ;
1358
+ } ) . toThrow ( / o n e o f t i m e o u t a n d t i m e o u t D u r a t i o n M i n u t e s m u s t b e s p e c i f i e d / ) ;
1359
+ } ) ;
1360
+
1361
+ test ( 'Throws if both timeout and timeoutDurationMinutes are specified' , ( ) => {
1362
+ // WHEN
1363
+ const task = new EmrCreateCluster ( stack , 'Task' , {
1364
+ instances : {
1365
+ instanceFleets : [ {
1366
+ instanceFleetType : EmrCreateCluster . InstanceRoleType . MASTER ,
1367
+ launchSpecifications : {
1368
+ spotSpecification : {
1369
+ timeoutAction : EmrCreateCluster . SpotTimeoutAction . TERMINATE_CLUSTER ,
1370
+ timeout : cdk . Duration . minutes ( 5 ) ,
1371
+ timeoutDurationMinutes : 10 ,
1372
+ } ,
1373
+ } ,
1374
+ name : 'Main' ,
1375
+ targetSpotCapacity : 1 ,
1376
+ } ] ,
1377
+ } ,
1378
+ clusterRole,
1379
+ name : 'Cluster' ,
1380
+ serviceRole,
1381
+ integrationPattern : sfn . IntegrationPattern . REQUEST_RESPONSE ,
1382
+ } ) ;
1383
+
1384
+ // THEN
1385
+ expect ( ( ) => {
1386
+ task . toStateJson ( ) ;
1387
+ } ) . toThrow ( / o n e o f t i m e o u t a n d t i m e o u t D u r a t i o n M i n u t e s m u s t b e s p e c i f i e d / ) ;
1276
1388
} ) ;
1277
1389
1278
1390
test ( 'Throws if both bidPrice and bidPriceAsPercentageOfOnDemandPrice are specified' , ( ) => {
0 commit comments