@@ -1208,3 +1208,55 @@ test('NetworkLoadBalancedFargateService multiple capacity provider strategies ar
12081208 ] ) ,
12091209 } ) ;
12101210} ) ;
1211+
1212+ test ( 'should validate minHealthyPercent' , ( ) => {
1213+ // GIVEN
1214+ const stack = new cdk . Stack ( ) ;
1215+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
1216+ const cluster = new ecs . Cluster ( stack , 'Cluster' , { vpc } ) ;
1217+
1218+ // WHEN
1219+ expect ( ( ) => new ecsPatterns . ApplicationLoadBalancedFargateService ( stack , 'Service' , {
1220+ cluster,
1221+ taskImageOptions : {
1222+ image : ecs . ContainerImage . fromRegistry ( '/aws/aws-example-app' ) ,
1223+ dockerLabels : { label1 : 'labelValue1' , label2 : 'labelValue2' } ,
1224+ } ,
1225+ minHealthyPercent : 0.5 ,
1226+ } ) ) . toThrow ( / M u s t b e a n o n - n e g a t i v e i n t e g e r / ) ;
1227+ } ) ;
1228+
1229+ test ( 'should validate maxHealthyPercent' , ( ) => {
1230+ // GIVEN
1231+ const stack = new cdk . Stack ( ) ;
1232+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
1233+ const cluster = new ecs . Cluster ( stack , 'Cluster' , { vpc } ) ;
1234+
1235+ // WHEN
1236+ expect ( ( ) => new ecsPatterns . ApplicationLoadBalancedFargateService ( stack , 'Service' , {
1237+ cluster,
1238+ taskImageOptions : {
1239+ image : ecs . ContainerImage . fromRegistry ( '/aws/aws-example-app' ) ,
1240+ dockerLabels : { label1 : 'labelValue1' , label2 : 'labelValue2' } ,
1241+ } ,
1242+ maxHealthyPercent : 0.5 ,
1243+ } ) ) . toThrow ( / M u s t b e a n o n - n e g a t i v e i n t e g e r / ) ;
1244+ } ) ;
1245+
1246+ test ( 'minHealthyPercent must be less than maxHealthyPercent' , ( ) => {
1247+ // GIVEN
1248+ const stack = new cdk . Stack ( ) ;
1249+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
1250+ const cluster = new ecs . Cluster ( stack , 'Cluster' , { vpc } ) ;
1251+
1252+ // WHEN
1253+ expect ( ( ) => new ecsPatterns . ApplicationLoadBalancedFargateService ( stack , 'Service' , {
1254+ cluster,
1255+ taskImageOptions : {
1256+ image : ecs . ContainerImage . fromRegistry ( '/aws/aws-example-app' ) ,
1257+ dockerLabels : { label1 : 'labelValue1' , label2 : 'labelValue2' } ,
1258+ } ,
1259+ minHealthyPercent : 100 ,
1260+ maxHealthyPercent : 70 ,
1261+ } ) ) . toThrow ( / m u s t b e l e s s t h a n / ) ;
1262+ } ) ;
0 commit comments